Signed-off-by: Claudio Fontana <cfont...@suse.de>
---
 tools/virsh-domain.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index bac4cc0fb6..120d0ef5f0 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4203,6 +4203,9 @@ doSave(void *opaque)
     g_autoptr(virshDomain) dom = NULL;
     const char *name = NULL;
     const char *to = NULL;
+    virTypedParameterPtr params = NULL;
+    int nparams = 0;
+    int maxparams = 0;
     unsigned int flags = 0;
     const char *xmlfile = NULL;
     g_autofree char *xml = NULL;
@@ -4216,9 +4219,12 @@ doSave(void *opaque)
         goto out_sig;
 #endif /* !WIN32 */
 
-    if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) {
         goto out;
-
+    } else if (virTypedParamsAddString(&params, &nparams, &maxparams,
+                                       VIR_DOMAIN_SAVE_PARAM_FILE, to) < 0) {
+        goto out;
+    }
     if (vshCommandOptBool(cmd, "bypass-cache"))
         flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
     if (vshCommandOptBool(cmd, "running"))
@@ -4232,10 +4238,14 @@ doSave(void *opaque)
     if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto out;
 
-    if (xmlfile &&
-        virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) {
-        vshReportError(ctl);
-        goto out;
+    if (xmlfile) {
+        if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) {
+            vshReportError(ctl);
+            goto out;
+        } else if (virTypedParamsAddString(&params, &nparams, &maxparams,
+                                           VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 
0) {
+            goto out;
+        }
     }
 
     if (flags || xml) {
@@ -4252,6 +4262,7 @@ doSave(void *opaque)
     data->ret = 0;
 
  out:
+    virTypedParamsFree(params, nparams);
 #ifndef WIN32
     pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
  out_sig:
-- 
2.26.2

Reply via email to