[libvirt] [PATCH] [4/4] Add a managedsave command to virsh

Daniel Veillard veillard at redhat.com
Thu Apr 1 16:23:14 UTC 2010


This command implements the managed save operation

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

diff --git a/tools/virsh.c b/tools/virsh.c
index 5c56fa6..6d01fa4 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1333,6 +1333,44 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
 }
 
 /*
+ * "managedsave" command
+ */
+static const vshCmdInfo info_managedsave[] = {
+    {"help", N_("managed save of a domain state")},
+    {"desc", N_("Save a running domain the data being managed by libvirt.")},
+    {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
  */
 static const vshCmdInfo info_schedinfo[] = {
@@ -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},
diff --git a/tools/virsh.pod b/tools/virsh.pod
index fc4a70c..603fc16 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -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<namagedsave> 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

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list