From: Pavel Hrdina <phrdina(a)redhat.com>
There is no need to use extra flag in addition to the new
"parallel.channels" param.
Using the flag without param would result in using uninitialized
variable. Fixing it would result in error that parallel channels cannot
be less then 1 or setting 1 as default.
Using the param without the flag is ignored.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
include/libvirt/libvirt-domain.h | 1 -
src/qemu/qemu_driver.c | 6 ++----
src/qemu/qemu_migration_params.c | 34 +++++++++++++++-----------------
tools/virsh-domain.c | 22 ++++++++-------------
4 files changed, 26 insertions(+), 37 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 233bfd927a..6e11baa3d3 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1655,7 +1655,6 @@ typedef enum {
VIR_DOMAIN_SAVE_RUNNING = 1 << 1, /* Favor running over paused (Since:
0.9.5) */
VIR_DOMAIN_SAVE_PAUSED = 1 << 2, /* Favor paused over running (Since:
0.9.5) */
VIR_DOMAIN_SAVE_RESET_NVRAM = 1 << 3, /* Re-initialize NVRAM from template
(Since: 8.1.0) */
- VIR_DOMAIN_SAVE_PARALLEL = 1 << 4, /* Save and restore using parallel
channels (Since: 10.6.0) */
} virDomainSaveRestoreFlags;
int virDomainSave (virDomainPtr domain,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 21df94961b..3cf21380ed 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2822,8 +2822,7 @@ qemuDomainSaveParams(virDomainPtr dom,
virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE |
VIR_DOMAIN_SAVE_RUNNING |
- VIR_DOMAIN_SAVE_PAUSED |
- VIR_DOMAIN_SAVE_PARALLEL, -1);
+ VIR_DOMAIN_SAVE_PAUSED, -1);
if (virTypedParamsValidate(params, nparams,
VIR_DOMAIN_SAVE_PARAM_FILE,
@@ -5762,8 +5761,7 @@ qemuDomainRestoreInternal(virConnectPtr conn,
virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE |
VIR_DOMAIN_SAVE_RUNNING |
VIR_DOMAIN_SAVE_PAUSED |
- VIR_DOMAIN_SAVE_RESET_NVRAM |
- VIR_DOMAIN_SAVE_PARALLEL, -1);
+ VIR_DOMAIN_SAVE_RESET_NVRAM, -1);
if (flags & VIR_DOMAIN_SAVE_RESET_NVRAM)
reset_nvram = true;
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index b696b0d13e..17d08f4aa5 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -803,11 +803,20 @@ qemuMigrationParamsForSave(virTypedParameterPtr params,
unsigned int flags)
{
g_autoptr(qemuMigrationParams) saveParams = NULL;
+ int nchannels = 0;
+ int rv;
- if (flags & VIR_DOMAIN_SAVE_PARALLEL && !sparse) {
+ if ((rv = virTypedParamsGetInt(params, nparams,
+ VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS,
+ &nchannels)) < 0)
+ return NULL;
+
+ if (rv == 1 && !sparse) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Parallel save is only supported with the 'sparse'
save image format"));
return NULL;
+ } else if (rv == 0) {
+ nchannels = 1;
}
if (!(saveParams = qemuMigrationParamsNew()))
@@ -819,24 +828,13 @@ qemuMigrationParamsForSave(virTypedParameterPtr params,
if (virBitmapSetBit(saveParams->caps, QEMU_MIGRATION_CAP_MULTIFD) < 0)
return NULL;
- if (flags & VIR_DOMAIN_SAVE_PARALLEL) {
- int nchannels;
-
- if (params && virTypedParamsGetInt(params, nparams,
- VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS,
- &nchannels) < 0)
- return NULL;
-
- if (nchannels < 1) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("number of parallel save channels cannot be less
than 1"));
- return NULL;
- }
-
- saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i =
nchannels;
- } else {
- saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i = 1;
+ if (nchannels < 1) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("number of parallel save channels cannot be less than
1"));
+ return NULL;
}
+
+ saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i =
nchannels;
saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].set = true;
if (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) {
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 7adf6c16fa..56ddf4d701 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4597,13 +4597,10 @@ doSave(void *opaque)
if ((rc = vshCommandOptInt(ctl, cmd, "parallel-channels", &nchannels))
< 0)
goto out;
- if (rc == 1) {
- if (virTypedParamsAddInt(¶ms, &nparams, &maxparams,
- VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) <
0)
- goto out;
-
- flags |= VIR_DOMAIN_SAVE_PARALLEL;
- }
+ if (rc == 1 &&
+ virTypedParamsAddInt(¶ms, &nparams, &maxparams,
+ VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) < 0)
+ goto out;
if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0)
goto out;
@@ -5728,13 +5725,10 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
if ((rc = vshCommandOptInt(ctl, cmd, "parallel-channels", &nchannels))
< 0)
return false;
- if (rc == 1) {
- if (virTypedParamsAddInt(¶ms, &nparams, &maxparams,
- VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) <
0)
- return false;
-
- flags |= VIR_DOMAIN_SAVE_PARALLEL;
- }
+ if (rc == 1 &&
+ virTypedParamsAddInt(¶ms, &nparams, &maxparams,
+ VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) < 0)
+ return false;
if (flags || xml) {
rc = virDomainRestoreParams(priv->conn, params, nparams, flags);
--
2.48.1