[libvirt RFCv9 22/31] tools: add parallel parameter to virsh save command

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

 



Signed-off-by: Claudio Fontana <cfontana@xxxxxxx>
---
 docs/manpages/virsh.rst | 23 +++++++++++++++++------
 tools/virsh-domain.c    | 24 ++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index e73e590754..e9012b85d1 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -3803,15 +3803,18 @@ 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
-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.
+Saves a paused or running domain (RAM, but not disk state) to one or more
+state files, so that 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 state file/s.
+
 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,14 @@ 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 multiple files. The main save file is specified
+with ``state-file``, and a number of additional connections can be
+set using *--parallel-connections*, which will save to files named
+``state-file``.1 , ``state-file``.2 ... up to ``connections``.
+
+Parallel connections may help in speeding up the save operation.
+
 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 8a3c9d53d4..85d18c99a8 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 to files")
+    },
+    {.name = "parallel-connections",
+     .type = VSH_OT_INT,
+     .help = N_("number of connections/files 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.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