]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: use virDomainSaveParams only when necessary
authorPavel Hrdina <phrdina@redhat.com>
Thu, 20 Mar 2025 22:32:17 +0000 (23:32 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 21 Mar 2025 09:56:19 +0000 (10:56 +0100)
We should use the newest API only when user sets parallel-channels.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
tools/virsh-domain.c

index c21cf847c801bd0a5d6248a9c5a8721aaf421ab3..98f0e60ed41690df81494ec2ff81438757d19ab6 100644 (file)
@@ -4590,10 +4590,6 @@ doSave(void *opaque)
 
     if (vshCommandOptString(ctl, cmd, "file", &to) < 0)
         goto out;
-    if (to &&
-        virTypedParamsAddString(&params, &nparams, &maxparams,
-                                VIR_DOMAIN_SAVE_PARAM_FILE, to) < 0)
-        goto out;
 
     if ((rc = vshCommandOptInt(ctl, cmd, "parallel-channels", &nchannels)) < 0)
         goto out;
@@ -4613,13 +4609,21 @@ doSave(void *opaque)
         vshReportError(ctl);
         goto out;
     }
-    if (xml &&
-        virTypedParamsAddString(&params, &nparams, &maxparams,
-                                VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 0)
-        goto out;
 
-    if (flags || xml) {
+    if (nparams > 0) {
+        if (to &&
+            virTypedParamsAddString(&params, &nparams, &maxparams,
+                                    VIR_DOMAIN_SAVE_PARAM_FILE, to) < 0)
+            goto out;
+
+        if (xml &&
+            virTypedParamsAddString(&params, &nparams, &maxparams,
+                                    VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 0)
+            goto out;
+
         rc = virDomainSaveParams(dom, params, nparams, flags);
+    } else if (flags || xml) {
+        rc = virDomainSaveFlags(dom, to, xml, flags);
     } else {
         rc = virDomainSave(dom, to);
     }