1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-30 18:50:18 +03:00

tools: add parallel parameter to virsh restore command

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Claudio Fontana 2022-04-25 10:32:31 -06:00 committed by Jim Fehlig
parent 380cffda23
commit a274048196
2 changed files with 42 additions and 6 deletions

View File

@ -4125,12 +4125,13 @@ restore
::
restore state-file [--bypass-cache] [--xml file]
[{--running | --paused}] [--reset-nvram]
[{--running | --paused}] [--reset-nvram] [--parallel] [--parallel-channels]
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
@ -4146,6 +4147,10 @@ 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 using the number
of parallel IO channels specified with *--parallel-channels*. Parallel
channels will help speed up large restore operations.
``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

View File

@ -5666,6 +5666,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-channels",
.type = VSH_OT_INT,
.help = N_("number of IO channels to use for parallel restore")
},
{.name = "xml",
.type = VSH_OT_STRING,
.unwanted_positional = true,
@ -5695,13 +5703,16 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
const char *xmlfile = NULL;
g_autofree char *xml = NULL;
virshControl *priv = ctl->privData;
virTypedParameterPtr params = NULL;
int nparams = 0;
int maxparams = 0;
int nchannels = 1;
int rc;
if (vshCommandOptString(ctl, cmd, "file", &from) < 0)
return false;
if (vshCommandOptBool(cmd, "bypass-cache"))
flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
if (vshCommandOptBool(cmd, "parallel"))
flags |= VIR_DOMAIN_SAVE_PARALLEL;
if (vshCommandOptBool(cmd, "running"))
flags |= VIR_DOMAIN_SAVE_RUNNING;
if (vshCommandOptBool(cmd, "paused"))
@ -5709,15 +5720,35 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "reset-nvram"))
flags |= VIR_DOMAIN_SAVE_RESET_NVRAM;
if (vshCommandOptString(ctl, cmd, "file", &from) < 0)
return false;
if (from &&
virTypedParamsAddString(&params, &nparams, &maxparams,
VIR_DOMAIN_SAVE_PARAM_FILE, from) < 0)
return false;
if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0)
return false;
if (xmlfile &&
virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0)
return false;
if (xml &&
virTypedParamsAddString(&params, &nparams, &maxparams,
VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 0)
return false;
if (flags & VIR_DOMAIN_SAVE_PARALLEL) {
if ((rc = vshCommandOptInt(ctl, cmd, "parallel-channels", &nchannels)) < 0)
return false;
if (virTypedParamsAddInt(&params, &nparams, &maxparams,
VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) < 0)
return false;
}
if (flags || xml) {
rc = virDomainRestoreFlags(priv->conn, from, xml, flags);
rc = virDomainRestoreParams(priv->conn, params, nparams, flags);
} else {
rc = virDomainRestore(priv->conn, from);
}