[libvirt] [PATCH 3/3] Plumb managedsave compression through to virsh.

Chris Lalancette clalance at redhat.com
Fri Aug 13 14:53:49 UTC 2010


Signed-off-by: Chris Lalancette <clalance at redhat.com>
---
 tools/virsh.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 352d44a..5e97293 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1404,6 +1404,7 @@ static const vshCmdInfo info_managedsave[] = {
 };
 
 static const vshCmdOptDef opts_managedsave[] = {
+    {"compression", VSH_OT_STRING, 0, N_("compress save image")},
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {NULL, 0, 0, NULL}
 };
@@ -1414,14 +1415,33 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     char *name;
     int ret = TRUE;
+    char *compress = NULL;
+    unsigned int flags = 0;
 
     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
 
+    compress = vshCommandOptString(cmd, "compression", NULL);
+    if (compress) {
+        if (STREQ(compress, "gzip"))
+            flags |= VIR_DOMAIN_SAVE_COMPRESS_GZIP;
+        else if (STREQ(compress, "bzip2"))
+            flags |= VIR_DOMAIN_SAVE_COMPRESS_BZIP2;
+        else if (STREQ(compress, "xz"))
+            flags |= VIR_DOMAIN_SAVE_COMPRESS_XZ;
+        else if (STREQ(compress, "lzop"))
+            flags |= VIR_DOMAIN_SAVE_COMPRESS_LZOP;
+        else {
+            vshError(ctl, "%s",
+                     _("Invalid compression type; it must be one of 'gzip', 'bzip2', 'xz', or 'lzop'"));
+            return FALSE;
+        }
+    }
+
     if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
         return FALSE;
 
-    if (virDomainManagedSave(dom, 0) == 0) {
+    if (virDomainManagedSave(dom, flags) == 0) {
         vshPrint(ctl, _("Domain %s state saved by libvirt\n"), name);
     } else {
         vshError(ctl, _("Failed to save domain %s state"), name);
-- 
1.7.2.1




More information about the libvir-list mailing list