[libvirt] [PATCH] also allow use of XZ for Qemu image compression

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

 



While this patch stays minimal by simply adding XZ/xz to the list,
I think it would be better to remove lzma, since it uses
an inferior format (which lacks an integrity check), and
has been effectively subsumed by xz.

Let me know if you'd like that, and I'll prepare the slightly
more invasive patch.

>From afb7275f14e8062e6d5eebf704e1fd0f582cb407 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Tue, 8 Sep 2009 20:52:37 +0200
Subject: [PATCH] also allow use of XZ for Qemu image compression

* src/qemu_driver.c (enum qemud_save_formats) [QEMUD_SAVE_FORMAT_XZ]:
New member.
[QEMUD_SAVE_FORMAT_LZMA]: Mark as deprecated.
(qemudDomainSave, qemudDomainRestore): Handle the new member.
* src/qemu.conf: Mention xz, too.
---
 src/qemu.conf     |    2 +-
 src/qemu_driver.c |   10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu.conf b/src/qemu.conf
index 06babc4..342bb8a 100644
--- a/src/qemu.conf
+++ b/src/qemu.conf
@@ -134,7 +134,7 @@
 # memory from the domain is dumped out directly to a file.  If you have
 # guests with a large amount of memory, however, this can take up quite
 # a bit of space.  If you would like to compress the images while they
-# are being saved to disk, you can also set "gzip", "bzip2", "lzma"
+# are being saved to disk, you can also set "gzip", "bzip2", "lzma", "xz",
 # or "lzop" for save_image_format.  Note that this means you slow down
 # the process of saving a domain in order to save disk space.
 #
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index f64d70b..7b64712 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -3622,7 +3622,8 @@ enum qemud_save_formats {
     QEMUD_SAVE_FORMAT_RAW,
     QEMUD_SAVE_FORMAT_GZIP,
     QEMUD_SAVE_FORMAT_BZIP2,
-    QEMUD_SAVE_FORMAT_LZMA,
+    QEMUD_SAVE_FORMAT_LZMA,  /* deprecated, in favor of xz */
+    QEMUD_SAVE_FORMAT_XZ,
     QEMUD_SAVE_FORMAT_LZOP,
 };

@@ -3664,6 +3665,8 @@ static int qemudDomainSave(virDomainPtr dom,
         header.compressed = QEMUD_SAVE_FORMAT_BZIP2;
     else if (STREQ(driver->saveImageFormat, "lzma"))
         header.compressed = QEMUD_SAVE_FORMAT_LZMA;
+    else if (STREQ(driver->saveImageFormat, "xz"))
+        header.compressed = QEMUD_SAVE_FORMAT_XZ;
     else if (STREQ(driver->saveImageFormat, "lzop"))
         header.compressed = QEMUD_SAVE_FORMAT_LZOP;
     else {
@@ -3758,6 +3761,9 @@ static int qemudDomainSave(virDomainPtr dom,
     else if (header.compressed == QEMUD_SAVE_FORMAT_LZMA)
         internalret = virAsprintf(&command, "migrate \"exec:"
                                   "lzma -c >> '%s' 2>/dev/null\"", safe_path);
+    else if (header.compressed == QEMUD_SAVE_FORMAT_XZ)
+        internalret = virAsprintf(&command, "migrate \"exec:"
+                                  "xz -c >> '%s' 2>/dev/null\"", safe_path);
     else if (header.compressed == QEMUD_SAVE_FORMAT_LZOP)
         internalret = virAsprintf(&command, "migrate \"exec:"
                                   "lzop -c >> '%s' 2>/dev/null\"", safe_path);
@@ -4383,6 +4389,8 @@ static int qemudDomainRestore(virConnectPtr conn,
             intermediate_argv[0] = "bzip2";
         else if (header.compressed == QEMUD_SAVE_FORMAT_LZMA)
             intermediate_argv[0] = "lzma";
+        else if (header.compressed == QEMUD_SAVE_FORMAT_XZ)
+            intermediate_argv[0] = "xz";
         else if (header.compressed == QEMUD_SAVE_FORMAT_LZOP)
             intermediate_argv[0] = "lzop";
         else if (header.compressed != QEMUD_SAVE_FORMAT_RAW) {
--
1.6.5.rc0.164.g5f6b0

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