Add a managedsave command to virsh

This command implements the managed save operation

* tools/virsh.c: new command
* tools/virsh.pod: documentation
This commit is contained in:
Daniel Veillard 2010-04-01 18:05:38 +02:00
parent 6e41f30efc
commit d068f9609c
2 changed files with 46 additions and 0 deletions

View File

@ -1332,6 +1332,44 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
return ret;
}
/*
* "managedsave" command
*/
static const vshCmdInfo info_managedsave[] = {
{"help", N_("managed save of a domain state")},
{"desc", N_("Save and stop a running domain, so libvirt can restart it from the same state")},
{NULL, NULL}
};
static const vshCmdOptDef opts_managedsave[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{NULL, 0, 0, NULL}
};
static int
cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
char *name;
int ret = TRUE;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return FALSE;
if (virDomainManagedSave(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s state saved by libvirt\n"), name);
} else {
vshError(ctl, _("Failed to save domain %s state"), name);
ret = FALSE;
}
virDomainFree(dom);
return ret;
}
/*
* "schedinfo" command
*/
@ -8208,6 +8246,8 @@ static const vshCmdDef commands[] = {
{"iface-start", cmdInterfaceStart, opts_interface_start, info_interface_start},
{"iface-destroy", cmdInterfaceDestroy, opts_interface_destroy, info_interface_destroy},
{"managedsave", cmdManagedSave, opts_managedsave, info_managedsave},
{"nodeinfo", cmdNodeinfo, NULL, info_nodeinfo},
{"nodedev-list", cmdNodeListDevices, opts_node_list_devices, info_node_list_devices},

View File

@ -335,6 +335,12 @@ except that it does some error checking.
The editor used can be supplied by the C<$VISUAL> or C<$EDITOR> environment
variables, and defaults to C<vi>.
=item B<managedsave> I<domain-id>
Ask libvirt to save a running domain state in a place managed by libvirt.
If libvirt is asked to restart the domain later on it will resume it from
the saved domain state (and the state is discarded).
=item B<migrate> optional I<--live> I<--suspend> I<domain-id> I<desturi> I<migrateuri>
Migrate domain to another host. Add --live for live migration; --suspend