[libvirt RFCv7 30/40] tools: add parallel parameter to virsh restore command

Claudio Fontana cfontana at suse.de
Fri May 6 13:11:14 UTC 2022


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

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index e9012b85d1..3bf9b54806 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -3754,12 +3754,14 @@ restore
 ::
 
    restore state-file [--bypass-cache] [--xml file]
+      [--parallel] [--parallel-connections connections]
       [{--running | --paused}] [--reset-nvram]
 
 Restores a domain from a ``virsh save`` state file. See *save* for more info.
 
 If *--bypass-cache* is specified, the restore 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.
 
 *--xml* ``file`` is usually omitted, but can be used to supply an
 alternative XML file for use on the restored guest with changes only
@@ -3775,6 +3777,13 @@ domain should be started in.
 If *--reset-nvram* is specified, any existing NVRAM file will be deleted
 and re-initialized from its pristine template.
 
+*--parallel* option will cause the save data to be loaded from multiple
+state files over parallel connections. The main save file is specified
+with ``state-file``, and the number of additional channels can be set
+using *--parallel-connections*
+
+Parallel connections may help in speeding up the save operation.
+
 ``Note``: To avoid corrupting file system contents within the domain, you
 should not reuse the saved state file for a second ``restore`` unless you
 have also reverted all storage volumes back to the same contents as when
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 19359683ed..ddedc21573 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5311,6 +5311,14 @@ static const vshCmdOptDef opts_restore[] = {
      .type = VSH_OT_BOOL,
      .help = N_("avoid file system cache when restoring")
     },
+    {.name = "parallel",
+     .type = VSH_OT_BOOL,
+     .help = N_("enable parallel restore")
+    },
+    {.name = "parallel-connections",
+     .type = VSH_OT_INT,
+     .help = N_("number of connections/files for parallel restore")
+    },
     {.name = "xml",
      .type = VSH_OT_STRING,
      .completer = virshCompletePathLocalExisting,
@@ -5338,6 +5346,8 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
     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;
@@ -5354,6 +5364,15 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
 
     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_SAVE_PARAM_PARALLEL_CONNECTIONS, intOpt) < 0)
+            goto out;
+    }
     if (vshCommandOptBool(cmd, "running"))
         flags |= VIR_DOMAIN_SAVE_RUNNING;
     if (vshCommandOptBool(cmd, "paused"))
-- 
2.35.3



More information about the libvir-list mailing list