mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-30 18:50:18 +03:00
tools: add parallel parameter to virsh save 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:
parent
f0169f4d6c
commit
380cffda23
@ -4174,6 +4174,7 @@ save
|
||||
::
|
||||
|
||||
save domain state-file [--bypass-cache] [--xml file]
|
||||
[--parallel] [--parallel-channels channels]
|
||||
[{--running | --paused}] [--verbose]
|
||||
|
||||
Saves a running domain (RAM, but not disk state) to a state file so that
|
||||
@ -4181,8 +4182,11 @@ 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
|
||||
@ -4204,6 +4208,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 written to file
|
||||
over multiple parallel IO channels. The number of channels can be
|
||||
specified using *--parallel-channels*. Using parallel IO channels
|
||||
requires the use of ``sparse`` image save format. Parallel save may
|
||||
significantly reduce the time required to save large memory domains.
|
||||
|
||||
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
|
||||
|
@ -4530,6 +4530,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-channels",
|
||||
.type = VSH_OT_INT,
|
||||
.help = N_("number of extra IO channels to use for parallel save")
|
||||
},
|
||||
{.name = "xml",
|
||||
.type = VSH_OT_STRING,
|
||||
.unwanted_positional = true,
|
||||
@ -4560,6 +4568,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 = 1;
|
||||
int rv = -1;
|
||||
unsigned int flags = 0;
|
||||
const char *xmlfile = NULL;
|
||||
g_autofree char *xml = NULL;
|
||||
@ -4573,15 +4586,30 @@ 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(¶ms, &nparams, &maxparams,
|
||||
VIR_DOMAIN_SAVE_PARAM_FILE, to) < 0)
|
||||
goto out;
|
||||
|
||||
if (flags & VIR_DOMAIN_SAVE_PARALLEL) {
|
||||
if ((rv = vshCommandOptInt(ctl, cmd, "parallel-channels", &nchannels)) < 0)
|
||||
goto out;
|
||||
|
||||
if (virTypedParamsAddInt(¶ms, &nparams, &maxparams,
|
||||
VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) < 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0)
|
||||
goto out;
|
||||
@ -4594,9 +4622,13 @@ doSave(void *opaque)
|
||||
vshReportError(ctl);
|
||||
goto out;
|
||||
}
|
||||
if (xml &&
|
||||
virTypedParamsAddString(¶ms, &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);
|
||||
}
|
||||
@ -4609,6 +4641,8 @@ doSave(void *opaque)
|
||||
data->ret = 0;
|
||||
|
||||
out:
|
||||
virTypedParamsFree(params, nparams);
|
||||
|
||||
#ifndef WIN32
|
||||
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
|
||||
out_sig:
|
||||
|
Loading…
x
Reference in New Issue
Block a user