[PATCH RFC 2/2] support configuring the format of dumping memory in qemu.conf

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

 



This patch is used to add dump_memory_format to qemu.conf and make the
specified format as the default dump format of 'virsh dump --memory-only'.
But when "--compress" is specified with dump command, the format configured
by dump_memory_format will be overrided. dump_memory_format can one of elf,
kdump-zlib, kdump-lzo and kdump-snappy. And elf is the default value.

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 src/qemu/libvirtd_qemu.aug         |  1 +
 src/qemu/qemu.conf                 |  6 ++++++
 src/qemu/qemu_conf.c               |  2 ++
 src/qemu/qemu_conf.h               |  1 +
 src/qemu/qemu_driver.c             | 37 ++++++++++++++++++++++++++++++++++---
 src/qemu/test_libvirtd_qemu.aug.in |  1 +
 6 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index a9ff421..25737e8 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -60,6 +60,7 @@ module Libvirtd_qemu =

    let save_entry =  str_entry "save_image_format"
                  | str_entry "dump_image_format"
+                 | str_entry "dump_memory_format"
                  | str_entry "snapshot_image_format"
                  | str_entry "auto_dump_path"
                  | bool_entry "auto_dump_bypass_cache"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 17f1b10..8dc9d29 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -294,6 +294,11 @@
 # the requested compression program can't be found, this falls
 # back to "raw" compression.
 #
+# dump_memory_format is used when you use 'virsh dump --memory-only' to dump
+# guest memory, and if specifing format with 'virsh dump --memory-only',
+# dump_memory_format will not work. dump_memory_format can be elf, kdump-zlib,
+# kdump-lzo and kdump-snappy.
+#
 # snapshot_image_format specifies the compression algorithm of the memory save
 # image when an external snapshot of a domain is taken. This does not apply
 # on disk image format. It is an error if the specified format isn't valid,
@@ -301,6 +306,7 @@
 #
 #save_image_format = "raw"
 #dump_image_format = "raw"
+#dump_memory_format = "elf"
 #snapshot_image_format = "raw"

 # When a domain is configured to be auto-dumped when libvirtd receives a
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4378791..7893e31 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -296,6 +296,7 @@ static void virQEMUDriverConfigDispose(void *obj)

     VIR_FREE(cfg->saveImageFormat);
     VIR_FREE(cfg->dumpImageFormat);
+    VIR_FREE(cfg->dumpMemoryFormat);
     VIR_FREE(cfg->autoDumpPath);

     virStringFreeList(cfg->securityDriverNames);
@@ -546,6 +547,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,

     GET_VALUE_STR("save_image_format", cfg->saveImageFormat);
     GET_VALUE_STR("dump_image_format", cfg->dumpImageFormat);
+    GET_VALUE_STR("dump_memory_format", cfg->dumpMemoryFormat);
     GET_VALUE_STR("snapshot_image_format", cfg->snapshotImageFormat);

     GET_VALUE_STR("auto_dump_path", cfg->autoDumpPath);
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 1f44a76..3bb1935 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -147,6 +147,7 @@ struct _virQEMUDriverConfig {

     char *saveImageFormat;
     char *dumpImageFormat;
+    char *dumpMemoryFormat;
     char *snapshotImageFormat;

     char *autoDumpPath;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c4e1aef..06f39c0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3407,6 +3407,21 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm,
     return ret;
 }

+typedef enum {
+    QEMU_DUMP_MEMORY_FORMAT_ELF = 0,
+    QEMU_DUMP_MEMORY_FORMAT_KDUMP_ZLIB = 1,
+    QEMU_DUMP_MEMORY_FORMAT_KDUMP_LZO = 2,
+    QEMU_DUMP_MEMORY_FORMAT_KDUMP_SNAPPY = 3,
+    QEMU_DUMP_MEMORY_FORMAT_LAST
+} virQEMUDumpMemoryFormat;
+
+VIR_ENUM_DECL(qemuDumpMemoryCompression)
+VIR_ENUM_IMPL(qemuDumpMemoryCompression, QEMU_DUMP_MEMORY_FORMAT_LAST,
+              "elf",
+              "kdump-zlib",
+              "kdump-lzo",
+              "kdump-snappy")
+
 static int
 doCoreDump(virQEMUDriverPtr driver,
            virDomainObjPtr vm,
@@ -3419,7 +3434,9 @@ doCoreDump(virQEMUDriverPtr driver,
     virFileWrapperFdPtr wrapperFd = NULL;
     int directFlag = 0;
     unsigned int flags = VIR_FILE_WRAPPER_NON_BLOCKING;
-    const char *dump_format;
+    const char *dump_format = "elf";
+    virQEMUDriverConfigPtr cfg = NULL;
+    int dump_memory_format;

     /* Create an empty file with appropriate ownership.  */
     if (dump_flags & VIR_DUMP_BYPASS_CACHE) {
@@ -3449,8 +3466,22 @@ doCoreDump(virQEMUDriverPtr driver,
             dump_format = "kdump-lzo";
         else if (dump_flags & VIR_DUMP_COMPRESS_SNAPPY)
             dump_format = "kdump-snappy";
-        else
-            dump_format = "elf";
+        else {
+            /* when --compress option is specified, qemu.conf will not work */
+            cfg = virQEMUDriverGetConfig(driver);
+            if (cfg->dumpMemoryFormat) {
+                dump_memory_format = qemuDumpMemoryCompressionTypeFromString(
+                                                        cfg->dumpMemoryFormat);
+                if (dump_memory_format == QEMU_DUMP_MEMORY_FORMAT_KDUMP_ZLIB)
+                    dump_format = "kdump-zlib";
+                else if (dump_memory_format ==
+                                            QEMU_DUMP_MEMORY_FORMAT_KDUMP_LZO)
+                    dump_format = "kdump-lzo";
+                else if (dump_memory_format ==
+                                        QEMU_DUMP_MEMORY_FORMAT_KDUMP_SNAPPY)
+                    dump_format = "kdump-snappy";
+            }
+        }
         ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP,
                            dump_format);
     } else {
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 81fedd6..9d0bcec 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -51,6 +51,7 @@ module Test_libvirtd_qemu =
 }
 { "save_image_format" = "raw" }
 { "dump_image_format" = "raw" }
+{ "dump_memory_format" = "elf" }
 { "snapshot_image_format" = "raw" }
 { "auto_dump_path" = "/var/lib/libvirt/qemu/dump" }
 { "auto_dump_bypass_cache" = "0" }
--
1.8.3.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]