[PATCH 3/4] qemu: managedsave: Add support for compressing managed save images

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

 



The regular save image code has the support to compress images using a
specified algorithm. This was not implemented for managed save although
it shares most of the backend code.
---
 src/qemu/qemu.conf     |  6 ++++++
 src/qemu/qemu_conf.c   |  2 ++
 src/qemu/qemu_conf.h   |  1 +
 src/qemu/qemu_driver.c | 23 +++++++++++++++++++++--
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 5fd6263..7cf67df 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -278,8 +278,14 @@
 # the requested compression program can't be found, this falls
 # back to "raw" compression.
 #
+# managedsave_image_format is used when a domain is saved to a location managed
+# by libvirt for example by using 'virsh managedsave'.  It is an error if the
+# specified format isn't valid, or the requested compression program can't be
+# found.
+#
 #save_image_format = "raw"
 #dump_image_format = "raw"
+#managedsave_image_format = "raw"

 # When a domain is configured to be auto-dumped when libvirtd receives a
 # watchdog event from qemu guest, libvirtd will save dump files in directory
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1a41caf..3e3cc28 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -521,6 +521,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,

     GET_VALUE_STR("save_image_format", cfg->saveImageFormat);
     GET_VALUE_STR("dump_image_format", cfg->dumpImageFormat);
+    GET_VALUE_STR("managedsave_image_format", cfg->managedsaveImageFormat);
+
     GET_VALUE_STR("auto_dump_path", cfg->autoDumpPath);
     GET_VALUE_BOOL("auto_dump_bypass_cache", cfg->autoDumpBypassCache);
     GET_VALUE_BOOL("auto_start_bypass_cache", cfg->autoStartBypassCache);
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index da29a2a..3a68c4a 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -144,6 +144,7 @@ struct _virQEMUDriverConfig {

     char *saveImageFormat;
     char *dumpImageFormat;
+    char *managedsaveImageFormat;

     char *autoDumpPath;
     bool autoDumpBypassCache;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cfdbb9a..bd69e5f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3232,6 +3232,8 @@ static int
 qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
 {
     virQEMUDriverPtr driver = dom->conn->privateData;
+    virQEMUDriverConfigPtr cfg = NULL;
+    int compressed = QEMU_SAVE_FORMAT_RAW;
     virDomainObjPtr vm;
     char *name = NULL;
     int ret = -1;
@@ -3257,13 +3259,29 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
         goto cleanup;
     }

+    cfg = virQEMUDriverGetConfig(driver);
+    if (cfg->managedsaveImageFormat) {
+        compressed = qemuSaveCompressionTypeFromString(cfg->managedsaveImageFormat);
+        if (compressed < 0) {
+            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                           _("Invalid managedsave image format specified "
+                             "in configuration file"));
+            goto cleanup;
+        }
+        if (!qemuCompressProgramAvailable(compressed)) {
+            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                           _("Compression program for image format "
+                             "in configuration file isn't available"));
+            goto cleanup;
+        }
+    }
+
     if (!(name = qemuDomainManagedSavePath(driver, vm)))
         goto cleanup;

     VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, name);

-    if ((ret = qemuDomainSaveInternal(driver, dom, vm, name,
-                                      QEMU_SAVE_FORMAT_RAW,
+    if ((ret = qemuDomainSaveInternal(driver, dom, vm, name, compressed,
                                       NULL, flags)) == 0)
         vm->hasManagedSave = true;

@@ -3273,6 +3291,7 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     VIR_FREE(name);
+    virObjectUnref(cfg);

     return ret;
 }
-- 
1.8.3.2

--
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]