[libvirt RFCv11 24/33] tools: add parallel parameter to virsh save command

Claudio Fontana cfontana at suse.de
Tue Jun 7 09:19:27 UTC 2022


Signed-off-by: Claudio Fontana <cfontana at suse.de>
---
 docs/manpages/virsh.rst | 11 ++++++++++-
 tools/virsh-domain.c    | 24 ++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index 965b89c99d..9f33b0aaef 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -3803,6 +3803,7 @@ save
 ::
 
    save domain state-file [--bypass-cache] [--xml file]
+      [--parallel] [--parallel-connections connections]
       [{--running | --paused}] [--verbose]
 
 Saves a running domain (RAM, but not disk state) to a state file so that
@@ -3810,8 +3811,10 @@ it can be restored
 later.  Once saved, the domain will no longer be running on the
 system, thus the memory allocated for the domain will be free for
 other domains to use.  ``virsh restore`` restores from this state file.
+
 If *--bypass-cache* is specified, the save will avoid the file system
-cache, although this may slow down the operation.
+cache; depending on the specific scenario this may slow down or speed up
+the operation.
 
 The progress may be monitored using ``domjobinfo`` virsh command and canceled
 with ``domjobabort`` command (sent by another virsh instance). Another option
@@ -3833,6 +3836,12 @@ based on the state the domain was in when the save was done; passing
 either the *--running* or *--paused* flag will allow overriding which
 state the ``restore`` should use.
 
+*--parallel* option will cause the save data to be sent over multiple
+parallel connections to the file. The number of extra connections
+can be set using *--parallel-connections*.
+
+Parallel connections help in speeding up large save operations.
+
 Domain saved state files assume that disk images will be unchanged
 between the creation and restore point.  For a more complete system
 restore point, where the disk state is saved alongside the memory
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a3f007a1d2..7a313cb29e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4174,6 +4174,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,
      .completer = virshCompletePathLocalExisting,
@@ -4206,6 +4214,8 @@ doSave(void *opaque)
     virTypedParameterPtr params = NULL;
     int nparams = 0;
     int maxparams = 0;
+    int intOpt = 0;
+    int rv = -1;
     unsigned int flags = 0;
     const char *xmlfile = NULL;
     g_autofree char *xml = NULL;
@@ -4227,6 +4237,15 @@ doSave(void *opaque)
     }
     if (vshCommandOptBool(cmd, "bypass-cache"))
         flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
+    if (vshCommandOptBool(cmd, "parallel"))
+        flags |= VIR_DOMAIN_SAVE_PARALLEL;
+    if ((rv = vshCommandOptInt(ctl, cmd, "parallel-connections", &intOpt)) < 0) {
+        goto out;
+    } else if (rv > 0) {
+        if (virTypedParamsAddInt(&params, &nparams, &maxparams,
+                                 VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTIONS, intOpt) < 0)
+            goto out;
+    }
     if (vshCommandOptBool(cmd, "running"))
         flags |= VIR_DOMAIN_SAVE_RUNNING;
     if (vshCommandOptBool(cmd, "paused"))
@@ -4247,8 +4266,9 @@ doSave(void *opaque)
             goto out;
         }
     }
-
-    if (flags || xml) {
+    if (flags & VIR_DOMAIN_SAVE_PARALLEL) {
+        rc = virDomainSaveParams(dom, params, nparams, flags);
+    } else if (flags || xml) {
         rc = virDomainSaveFlags(dom, to, xml, flags);
     } else {
         rc = virDomainSave(dom, to);
-- 
2.26.2



More information about the libvir-list mailing list