From 5aa8358dbedddfd0e4fef74e84430d146780f76f Mon Sep 17 00:00:00 2001
Message-Id: <5aa8358dbedddfd0e4fef74e84430d146780f76f.1382534061.git.jdenemar@redhat.com>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 14 Oct 2013 16:38:47 +0200
Subject: [PATCH] qemu: managedsave: Add support for compressing managed save
images
https://bugzilla.redhat.com/show_bug.cgi?id=1017227
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.
(cherry picked from commit 550cae847bd018ed1a4f68b987d093fd3abb07df)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu.conf | 6 +++---
src/qemu/qemu_driver.c | 23 +++++++++++++++++++++--
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index cdf1ec4..a2735cb 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -260,9 +260,9 @@
# saving a domain in order to save disk space; the list above is in descending
# order by performance and ascending order by compression ratio.
#
-# save_image_format is used when you use 'virsh save' at scheduled
-# saving, and it is an error if the specified save_image_format is
-# not valid, or the requested compression program can't be found.
+# save_image_format is used when you use 'virsh save' or 'virsh managedsave'
+# at scheduled saving, and it is an error if the specified save_image_format
+# is not valid, or the requested compression program can't be found.
#
# dump_image_format is used when you use 'virsh dump' at emergency
# crashdump, and if the specified dump_image_format is not valid, or
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3820303..14b0d57 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3237,6 +3237,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;
@@ -3262,13 +3264,29 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
goto cleanup;
}
+ cfg = virQEMUDriverGetConfig(driver);
+ if (cfg->saveImageFormat) {
+ compressed = qemuSaveCompressionTypeFromString(cfg->saveImageFormat);
+ if (compressed < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Invalid save 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;
@@ -3278,6 +3296,7 @@ cleanup:
if (vm)
virObjectUnlock(vm);
VIR_FREE(name);
+ virObjectUnref(cfg);
return ret;
}
--
1.8.4