[PATCH 19/20] tools: add parallel parameter to virsh save command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Li Zhang <lizhang@xxxxxxx>

Signed-off-by: Claudio Fontana <cfontana@xxxxxxx>
Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 tools/virsh-domain.c | 41 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 50e80689a2..ec0e43ae7b 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4145,6 +4145,14 @@ static const vshCmdOptDef opts_save[] = {
      .type = VSH_OT_BOOL,
      .help = N_("avoid file system cache when saving")
     },
+    {.name = "parallel",
+     .type = VSH_OT_BOOL,
+     .help = N_("enable parallel save")
+    },
+    {.name = "parallel-connections",
+     .type = VSH_OT_INT,
+     .help = N_("number of extra connections to use for parallel save")
+    },
     {.name = "xml",
      .type = VSH_OT_STRING,
      .unwanted_positional = true,
@@ -4175,6 +4183,11 @@ 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;
+    int nchannels = 0;
+    int rv = -1;
     unsigned int flags = 0;
     const char *xmlfile = NULL;
     g_autofree char *xml = NULL;
@@ -4188,15 +4201,29 @@ doSave(void *opaque)
         goto out_sig;
 #endif /* !WIN32 */
 
-    if (vshCommandOptString(ctl, cmd, "file", &to) < 0)
-        goto out;
-
     if (vshCommandOptBool(cmd, "bypass-cache"))
         flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
     if (vshCommandOptBool(cmd, "running"))
         flags |= VIR_DOMAIN_SAVE_RUNNING;
     if (vshCommandOptBool(cmd, "paused"))
         flags |= VIR_DOMAIN_SAVE_PAUSED;
+    if (vshCommandOptBool(cmd, "parallel"))
+        flags |= VIR_DOMAIN_SAVE_PARALLEL;
+
+    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 ((rv = vshCommandOptInt(ctl, cmd, "parallel-connections", &nchannels)) < 0) {
+        goto out;
+    } else if (rv > 0) {
+        if (virTypedParamsAddInt(&params, &nparams, &maxparams,
+                                 VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTIONS, nchannels) < 0)
+            goto out;
+    }
 
     if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0)
         goto out;
@@ -4209,9 +4236,13 @@ 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) {
-        rc = virDomainSaveFlags(dom, to, xml, flags);
+        rc = virDomainSaveParams(dom, params, nparams, flags);
     } else {
         rc = virDomainSave(dom, to);
     }
@@ -4224,6 +4255,8 @@ doSave(void *opaque)
     data->ret = 0;
 
  out:
+    virTypedParamsFree(params, nparams);
+
 #ifndef WIN32
     pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
  out_sig:
-- 
2.35.3



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux