|
|
43fe83 |
From 5aa8358dbedddfd0e4fef74e84430d146780f76f Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <5aa8358dbedddfd0e4fef74e84430d146780f76f.1382534061.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
43fe83 |
Date: Mon, 14 Oct 2013 16:38:47 +0200
|
|
|
43fe83 |
Subject: [PATCH] qemu: managedsave: Add support for compressing managed save
|
|
|
43fe83 |
images
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1017227
|
|
|
43fe83 |
|
|
|
43fe83 |
The regular save image code has the support to compress images using a
|
|
|
43fe83 |
specified algorithm. This was not implemented for managed save although
|
|
|
43fe83 |
it shares most of the backend code.
|
|
|
43fe83 |
|
|
|
43fe83 |
(cherry picked from commit 550cae847bd018ed1a4f68b987d093fd3abb07df)
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/qemu/qemu.conf | 6 +++---
|
|
|
43fe83 |
src/qemu/qemu_driver.c | 23 +++++++++++++++++++++--
|
|
|
43fe83 |
2 files changed, 24 insertions(+), 5 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
|
|
|
43fe83 |
index cdf1ec4..a2735cb 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu.conf
|
|
|
43fe83 |
+++ b/src/qemu/qemu.conf
|
|
|
43fe83 |
@@ -260,9 +260,9 @@
|
|
|
43fe83 |
# saving a domain in order to save disk space; the list above is in descending
|
|
|
43fe83 |
# order by performance and ascending order by compression ratio.
|
|
|
43fe83 |
#
|
|
|
43fe83 |
-# save_image_format is used when you use 'virsh save' at scheduled
|
|
|
43fe83 |
-# saving, and it is an error if the specified save_image_format is
|
|
|
43fe83 |
-# not valid, or the requested compression program can't be found.
|
|
|
43fe83 |
+# save_image_format is used when you use 'virsh save' or 'virsh managedsave'
|
|
|
43fe83 |
+# at scheduled saving, and it is an error if the specified save_image_format
|
|
|
43fe83 |
+# is not valid, or the requested compression program can't be found.
|
|
|
43fe83 |
#
|
|
|
43fe83 |
# dump_image_format is used when you use 'virsh dump' at emergency
|
|
|
43fe83 |
# crashdump, and if the specified dump_image_format is not valid, or
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
43fe83 |
index 3820303..14b0d57 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_driver.c
|
|
|
43fe83 |
+++ b/src/qemu/qemu_driver.c
|
|
|
43fe83 |
@@ -3237,6 +3237,8 @@ static int
|
|
|
43fe83 |
qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virQEMUDriverPtr driver = dom->conn->privateData;
|
|
|
43fe83 |
+ virQEMUDriverConfigPtr cfg = NULL;
|
|
|
43fe83 |
+ int compressed = QEMU_SAVE_FORMAT_RAW;
|
|
|
43fe83 |
virDomainObjPtr vm;
|
|
|
43fe83 |
char *name = NULL;
|
|
|
43fe83 |
int ret = -1;
|
|
|
43fe83 |
@@ -3262,13 +3264,29 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
+ cfg = virQEMUDriverGetConfig(driver);
|
|
|
43fe83 |
+ if (cfg->saveImageFormat) {
|
|
|
43fe83 |
+ compressed = qemuSaveCompressionTypeFromString(cfg->saveImageFormat);
|
|
|
43fe83 |
+ if (compressed < 0) {
|
|
|
43fe83 |
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
43fe83 |
+ _("Invalid save image format specified "
|
|
|
43fe83 |
+ "in configuration file"));
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ if (!qemuCompressProgramAvailable(compressed)) {
|
|
|
43fe83 |
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
43fe83 |
+ _("Compression program for image format "
|
|
|
43fe83 |
+ "in configuration file isn't available"));
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
if (!(name = qemuDomainManagedSavePath(driver, vm)))
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
|
|
|
43fe83 |
VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, name);
|
|
|
43fe83 |
|
|
|
43fe83 |
- if ((ret = qemuDomainSaveInternal(driver, dom, vm, name,
|
|
|
43fe83 |
- QEMU_SAVE_FORMAT_RAW,
|
|
|
43fe83 |
+ if ((ret = qemuDomainSaveInternal(driver, dom, vm, name, compressed,
|
|
|
43fe83 |
NULL, flags)) == 0)
|
|
|
43fe83 |
vm->hasManagedSave = true;
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -3278,6 +3296,7 @@ cleanup:
|
|
|
43fe83 |
if (vm)
|
|
|
43fe83 |
virObjectUnlock(vm);
|
|
|
43fe83 |
VIR_FREE(name);
|
|
|
43fe83 |
+ virObjectUnref(cfg);
|
|
|
43fe83 |
|
|
|
43fe83 |
return ret;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.4
|
|
|
43fe83 |
|