]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add a managedsave command to virsh
authorDaniel Veillard <veillard@redhat.com>
Thu, 1 Apr 2010 16:05:38 +0000 (18:05 +0200)
committerDaniel Veillard <veillard@redhat.com>
Sun, 4 Apr 2010 09:36:59 +0000 (11:36 +0200)
This command implements the managed save operation

* tools/virsh.c: new command
* tools/virsh.pod: documentation

tools/virsh.c
tools/virsh.pod

index 5c56fa60084f4fa42514d71dac38c29f6e21b81c..ca1a003702f2b1aff4017a2bf3c9f9b122866bdd 100644 (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},
index fc4a70c4c29d2ad1399cf94a54603ed028928ba7..62395d7f12166e2e49f256d9f9dc6f1b96893011 100644 (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