[PATCH 2/3] Managed save compression flags.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add in the ability to specify compression flags from the
managed save API.  We map these to the supported QEMU
compression flags internally.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |    7 +++++++
 src/qemu/qemu_driver.c       |   25 +++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 2ff484d..e4e7c84 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -648,6 +648,13 @@ int                     virDomainRestore        (virConnectPtr conn,
 /*
  * Managed domain save
  */
+typedef enum {
+    VIR_DOMAIN_SAVE_COMPRESS_RAW = 0,
+    VIR_DOMAIN_SAVE_COMPRESS_GZIP = 1 << 0,
+    VIR_DOMAIN_SAVE_COMPRESS_BZIP2 = 1 << 1,
+    VIR_DOMAIN_SAVE_COMPRESS_XZ = 1 << 2,
+    VIR_DOMAIN_SAVE_COMPRESS_LZOP = 1 << 3,
+} virDomainSaveCompression;
 int                    virDomainManagedSave     (virDomainPtr dom,
                                                  unsigned int flags);
 int                    virDomainHasManagedSaveImage(virDomainPtr dom,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b72aace..637cf28 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -79,6 +79,7 @@
 #include "domain_nwfilter.h"
 #include "hooks.h"
 #include "storage_file.h"
+#include "count-one-bits.h"
 
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
@@ -5588,7 +5589,28 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
     int ret = -1;
     int compressed;
 
-    virCheckFlags(0, -1);
+    if (count_one_bits(flags) > 1) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
+                        _("Too many compression flags specified 0x%x"), flags);
+        return -1;
+    }
+
+    /* this is in lieu of virCheckFlags */
+    if (flags == 0)
+        compressed = QEMUD_SAVE_FORMAT_RAW;
+    else if (flags & VIR_DOMAIN_SAVE_COMPRESS_GZIP)
+        compressed = QEMUD_SAVE_FORMAT_GZIP;
+    else if (flags & VIR_DOMAIN_SAVE_COMPRESS_BZIP2)
+        compressed = QEMUD_SAVE_FORMAT_BZIP2;
+    else if (flags & VIR_DOMAIN_SAVE_COMPRESS_XZ)
+        compressed = QEMUD_SAVE_FORMAT_XZ;
+    else if (flags & VIR_DOMAIN_SAVE_COMPRESS_LZOP)
+        compressed = QEMUD_SAVE_FORMAT_LZOP;
+    else {
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
+                        _("Invalid compression flags 0x%x"), flags);
+        return -1;
+    }
 
     qemuDriverLock(driver);
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -5606,7 +5628,6 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
 
     VIR_DEBUG("Saving state to %s", name);
 
-    compressed = QEMUD_SAVE_FORMAT_RAW;
     ret = qemudDomainSaveFlag(driver, dom, vm, name, compressed);
 
 cleanup:
-- 
1.7.2.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]