[libvirt] [PATCH v1 0/2] support dumping guest memory in compressed format

dumping guest's memroy is introduced without compression supported, and this is a freature regression of 'virsh dump --memory-only'. This patchset is used to add support in libvirt side to make qemu dump guest's memory in kdump-compressed format and please refer the following address to see implementation of the qemu side, the lastest version of qemu side is v9(ready for being queued). http://lists.nongnu.org/archive/html/qemu-devel/2014-02/msg03016.html qiaonuohan (2): make qemu dump memory in kdump-compressed format add dump_memory_format in qemu.conf include/libvirt/libvirt.h.in | 19 ++++++++++---- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 13 +++++++++- src/qemu/qemu_conf.c | 3 +++ src/qemu/qemu_conf.h | 2 ++ src/qemu/qemu_driver.c | 51 +++++++++++++++++++++++++++++++++++--- src/qemu/qemu_monitor.c | 6 ++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 4 ++- src/qemu/qemu_monitor_json.h | 3 ++- src/qemu/test_libvirtd_qemu.aug.in | 1 + tests/qemumonitorjsontest.c | 2 +- tools/virsh-domain.c | 42 +++++++++++++++++++++++++++++++ 13 files changed, 133 insertions(+), 17 deletions(-)

--memory-only option is introduced without compression supported. Therefore, this is a freature regression of virsh dump. Now qemu has support dumping memory in kdump-compressed format. This patch is used to add "--compress" and "[--compression-format] <string>" to "virsh dump --memory-only" and send dump-guest-memory command to qemu with dump format specified to one of elf, kdump-zlib, kdump-lzo and kdump-snappy. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> --- include/libvirt/libvirt.h.in | 19 ++++++++++++++----- src/qemu/qemu_driver.c | 20 ++++++++++++++++---- src/qemu/qemu_monitor.c | 6 +++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 4 +++- src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 2 +- tools/virsh-domain.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 83 insertions(+), 16 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 295d551..df62918 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1173,11 +1173,20 @@ typedef virDomainMemoryStatStruct *virDomainMemoryStatPtr; /* Domain core dump flags. */ typedef enum { - VIR_DUMP_CRASH = (1 << 0), /* crash after dump */ - VIR_DUMP_LIVE = (1 << 1), /* live dump */ - VIR_DUMP_BYPASS_CACHE = (1 << 2), /* avoid file system cache pollution */ - VIR_DUMP_RESET = (1 << 3), /* reset domain after dump finishes */ - VIR_DUMP_MEMORY_ONLY = (1 << 4), /* use dump-guest-memory */ + VIR_DUMP_CRASH = (1 << 0), /* crash after dump */ + VIR_DUMP_LIVE = (1 << 1), /* live dump */ + VIR_DUMP_BYPASS_CACHE = (1 << 2), /* avoid file system cache pollution */ + VIR_DUMP_RESET = (1 << 3), /* reset domain after dump finishes */ + VIR_DUMP_MEMORY_ONLY = (1 << 4), /* use dump-guest-memory */ + VIR_DUMP_COMPRESS_ZLIB = (1 << 5), /* dump guest memory in + kdump-compressed format, with + zlib-compressed */ + VIR_DUMP_COMPRESS_LZO = (1 << 6), /* dump guest memory in + kdump-compressed format, with + lzo-compressed */ + VIR_DUMP_COMPRESS_SNAPPY = (1 << 7), /* dump guest memory in + kdump-compressed format, with + snappy-compressed */ } virDomainCoreDumpFlags; /* Domain migration flags. */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 59e018d..19b4dd2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3383,7 +3383,8 @@ cleanup: } static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm, - int fd, enum qemuDomainAsyncJob asyncJob) + int fd, enum qemuDomainAsyncJob asyncJob, + const char* dump_format) { qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; @@ -3403,7 +3404,7 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; - ret = qemuMonitorDumpToFd(priv->mon, fd); + ret = qemuMonitorDumpToFd(priv->mon, fd, dump_format); qemuDomainObjExitMonitor(driver, vm); return ret; @@ -3421,6 +3422,7 @@ doCoreDump(virQEMUDriverPtr driver, virFileWrapperFdPtr wrapperFd = NULL; int directFlag = 0; unsigned int flags = VIR_FILE_WRAPPER_NON_BLOCKING; + const char *dump_format; /* Create an empty file with appropriate ownership. */ if (dump_flags & VIR_DUMP_BYPASS_CACHE) { @@ -3444,7 +3446,16 @@ doCoreDump(virQEMUDriverPtr driver, goto cleanup; if (dump_flags & VIR_DUMP_MEMORY_ONLY) { - ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP); + if (dump_flags & VIR_DUMP_COMPRESS_ZLIB) + dump_format = "kdump-zlib"; + else if (dump_flags & VIR_DUMP_COMPRESS_LZO) + dump_format = "kdump-lzo"; + else if (dump_flags & VIR_DUMP_COMPRESS_SNAPPY) + dump_format = "kdump-snappy"; + else + dump_format = "elf"; + ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP, + dump_format); } else { ret = qemuMigrationToFile(driver, vm, fd, 0, path, qemuCompressProgramName(compress), false, @@ -3520,7 +3531,8 @@ static int qemuDomainCoreDump(virDomainPtr dom, virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH | VIR_DUMP_BYPASS_CACHE | VIR_DUMP_RESET | - VIR_DUMP_MEMORY_ONLY, -1); + VIR_DUMP_MEMORY_ONLY | VIR_DUMP_COMPRESS_ZLIB | + VIR_DUMP_COMPRESS_LZO | VIR_DUMP_COMPRESS_SNAPPY, -1); if (!(vm = qemuDomObjFromDomain(dom))) return -1; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a2769db..2722781 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2345,10 +2345,10 @@ int qemuMonitorMigrateCancel(qemuMonitorPtr mon) } int -qemuMonitorDumpToFd(qemuMonitorPtr mon, int fd) +qemuMonitorDumpToFd(qemuMonitorPtr mon, int fd, const char *dump_format) { int ret; - VIR_DEBUG("mon=%p fd=%d", mon, fd); + VIR_DEBUG("mon=%p fd=%d dump_format=%s", mon, fd, dump_format); if (!mon) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -2368,7 +2368,7 @@ qemuMonitorDumpToFd(qemuMonitorPtr mon, int fd) if (qemuMonitorSendFileHandle(mon, "dump", fd) < 0) return -1; - ret = qemuMonitorJSONDump(mon, "fd:dump"); + ret = qemuMonitorJSONDump(mon, "fd:dump", dump_format); if (ret < 0) { if (qemuMonitorCloseFileHandle(mon, "dump") < 0) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index eabf000..f2e5763 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -495,7 +495,8 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon, int qemuMonitorMigrateCancel(qemuMonitorPtr mon); int qemuMonitorDumpToFd(qemuMonitorPtr mon, - int fd); + int fd, + const char *dump_format); int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon, int type, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5e825ac..7c9625f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2636,7 +2636,8 @@ int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon) int qemuMonitorJSONDump(qemuMonitorPtr mon, - const char *protocol) + const char *protocol, + const char *dump_format) { int ret; virJSONValuePtr cmd = NULL; @@ -2645,6 +2646,7 @@ qemuMonitorJSONDump(qemuMonitorPtr mon, cmd = qemuMonitorJSONMakeCommand("dump-guest-memory", "b:paging", false, "s:protocol", protocol, + "s:format", dump_format, NULL); if (!cmd) return -1; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index a93c51e..7691356 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -148,7 +148,8 @@ int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr mon, int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon); int qemuMonitorJSONDump(qemuMonitorPtr mon, - const char *protocol); + const char *protocol, + const char *dump_format); int qemuMonitorJSONGraphicsRelocate(qemuMonitorPtr mon, int type, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index d7da5a8..c02016f 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1154,7 +1154,7 @@ GEN_TEST_FUNC(qemuMonitorJSONSetMigrationDowntime, 1) GEN_TEST_FUNC(qemuMonitorJSONMigrate, QEMU_MONITOR_MIGRATE_BACKGROUND | QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | QEMU_MONITOR_MIGRATE_NON_SHARED_INC, "tcp:localhost:12345") -GEN_TEST_FUNC(qemuMonitorJSONDump, "dummy_protocol") +GEN_TEST_FUNC(qemuMonitorJSONDump, "dummy_protocol", "dummy_dump_format") GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SPICE, "localhost", 12345, 12346, NULL) GEN_TEST_FUNC(qemuMonitorJSONAddNetdev, "some_dummy_netdevstr") diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index c3db94c..68e9d02 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4519,6 +4519,14 @@ static const vshCmdOptDef opts_dump[] = { .type = VSH_OT_BOOL, .help = N_("dump domain's memory only") }, + {.name = "compress", + .type = VSH_OT_BOOL, + .help = N_("make qemu dump domain's memory in kdump-compressed format") + }, + {.name = "compression-format", + .type = VSH_OT_DATA, + .help = N_("specify the compression format of kdump-compressed format") + }, {.name = NULL} }; @@ -4533,6 +4541,8 @@ doDump(void *opaque) sigset_t sigmask, oldsigmask; const char *name = NULL; const char *to = NULL; + bool optCompress; + const char *compression_format = NULL; unsigned int flags = 0; sigemptyset(&sigmask); @@ -4557,6 +4567,38 @@ doDump(void *opaque) if (vshCommandOptBool(cmd, "memory-only")) flags |= VIR_DUMP_MEMORY_ONLY; + optCompress = vshCommandOptBool(cmd, "compress"); + if (optCompress && !(flags & VIR_DUMP_MEMORY_ONLY)) { + vshError(ctl, "%s", + _("compress flag cannot be set without memory-only flag")); + goto out; + } + + if (vshCommandOptString(cmd, "compression-format", &compression_format)) { + if (!optCompress) { + vshError(ctl, "%s", + _("compression-format cannot be set without compress " + "flag")); + goto out; + } + + if (STREQ(compression_format, "zlib")) + flags |= VIR_DUMP_COMPRESS_ZLIB; + else if (STREQ(compression_format, "lzo")) + flags |= VIR_DUMP_COMPRESS_LZO; + else if (STREQ(compression_format, "snappy")) + flags |= VIR_DUMP_COMPRESS_SNAPPY; + else { + vshError(ctl, _("compression format '%s' is not supported, " + "expecting 'zlib', 'lzo' or 'snappy'."), + compression_format); + goto out; + } + } else { + if (optCompress) + flags |= VIR_DUMP_COMPRESS_ZLIB; + } + if (virDomainCoreDump(dom, to, flags) < 0) { vshError(ctl, _("Failed to core dump domain %s to %s"), name, to); goto out;

On Thu, Feb 20, 2014 at 10:30:31AM +0800, Qiao Nuohan wrote:
--memory-only option is introduced without compression supported. Therefore, this is a freature regression of virsh dump. Now qemu has support dumping memory in kdump-compressed format. This patch is used to add "--compress" and "[--compression-format] <string>" to "virsh dump --memory-only" and send dump-guest-memory command to qemu with dump format specified to one of elf, kdump-zlib, kdump-lzo and kdump-snappy.
Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> --- include/libvirt/libvirt.h.in | 19 ++++++++++++++----- src/qemu/qemu_driver.c | 20 ++++++++++++++++---- src/qemu/qemu_monitor.c | 6 +++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 4 +++- src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 2 +- tools/virsh-domain.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 83 insertions(+), 16 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 295d551..df62918 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1173,11 +1173,20 @@ typedef virDomainMemoryStatStruct *virDomainMemoryStatPtr;
/* Domain core dump flags. */ typedef enum { - VIR_DUMP_CRASH = (1 << 0), /* crash after dump */ - VIR_DUMP_LIVE = (1 << 1), /* live dump */ - VIR_DUMP_BYPASS_CACHE = (1 << 2), /* avoid file system cache pollution */ - VIR_DUMP_RESET = (1 << 3), /* reset domain after dump finishes */ - VIR_DUMP_MEMORY_ONLY = (1 << 4), /* use dump-guest-memory */ + VIR_DUMP_CRASH = (1 << 0), /* crash after dump */ + VIR_DUMP_LIVE = (1 << 1), /* live dump */ + VIR_DUMP_BYPASS_CACHE = (1 << 2), /* avoid file system cache pollution */ + VIR_DUMP_RESET = (1 << 3), /* reset domain after dump finishes */ + VIR_DUMP_MEMORY_ONLY = (1 << 4), /* use dump-guest-memory */ + VIR_DUMP_COMPRESS_ZLIB = (1 << 5), /* dump guest memory in + kdump-compressed format, with + zlib-compressed */ + VIR_DUMP_COMPRESS_LZO = (1 << 6), /* dump guest memory in + kdump-compressed format, with + lzo-compressed */ + VIR_DUMP_COMPRESS_SNAPPY = (1 << 7), /* dump guest memory in + kdump-compressed format, with + snappy-compressed */ } virDomainCoreDumpFlags;
I'm not really a fan of using flags for this, since all these new flags are mutually exclusive. This is a strong indication that they should not be flags, and instead be a separate parametere. So IMHO if we wnat to be able to specify a dump format we should have an explicit 'int dumpformat' parameter for it. Yes, I know this would involve a new API. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 02/24/2014 06:30 PM, Daniel P. Berrange wrote:
On Thu, Feb 20, 2014 at 10:30:31AM +0800, Qiao Nuohan wrote:
--memory-only option is introduced without compression supported. Therefore, this is a freature regression of virsh dump. Now qemu has support dumping memory in kdump-compressed format. This patch is used to add "--compress" and "[--compression-format]<string>" to "virsh dump --memory-only" and send dump-guest-memory command to qemu with dump format specified to one of elf, kdump-zlib, kdump-lzo and kdump-snappy.
Signed-off-by: Qiao Nuohan<qiaonuohan@cn.fujitsu.com> --- include/libvirt/libvirt.h.in | 19 ++++++++++++++----- src/qemu/qemu_driver.c | 20 ++++++++++++++++---- src/qemu/qemu_monitor.c | 6 +++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 4 +++- src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 2 +- tools/virsh-domain.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 83 insertions(+), 16 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 295d551..df62918 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1173,11 +1173,20 @@ typedef virDomainMemoryStatStruct *virDomainMemoryStatPtr;
/* Domain core dump flags. */ typedef enum { - VIR_DUMP_CRASH = (1<< 0), /* crash after dump */ - VIR_DUMP_LIVE = (1<< 1), /* live dump */ - VIR_DUMP_BYPASS_CACHE = (1<< 2), /* avoid file system cache pollution */ - VIR_DUMP_RESET = (1<< 3), /* reset domain after dump finishes */ - VIR_DUMP_MEMORY_ONLY = (1<< 4), /* use dump-guest-memory */ + VIR_DUMP_CRASH = (1<< 0), /* crash after dump */ + VIR_DUMP_LIVE = (1<< 1), /* live dump */ + VIR_DUMP_BYPASS_CACHE = (1<< 2), /* avoid file system cache pollution */ + VIR_DUMP_RESET = (1<< 3), /* reset domain after dump finishes */ + VIR_DUMP_MEMORY_ONLY = (1<< 4), /* use dump-guest-memory */ + VIR_DUMP_COMPRESS_ZLIB = (1<< 5), /* dump guest memory in + kdump-compressed format, with + zlib-compressed */ + VIR_DUMP_COMPRESS_LZO = (1<< 6), /* dump guest memory in + kdump-compressed format, with + lzo-compressed */ + VIR_DUMP_COMPRESS_SNAPPY = (1<< 7), /* dump guest memory in + kdump-compressed format, with + snappy-compressed */ } virDomainCoreDumpFlags;
I'm not really a fan of using flags for this, since all these new flags are mutually exclusive. This is a strong indication that they should not be flags, and instead be a separate parametere. So IMHO if we wnat to be able to specify a dump format we should have an explicit 'int dumpformat' parameter for it. Yes, I know this would involve a new API.
I thought flag would be better, but now I know adding new parameter is preferred. Thanks for point it out.
Regards, Daniel
-- Regards Qiao Nuohan

This patch is used to add dump_memory_format to qemu.conf and libvirt will use it to specify the default format in which qemu dumps guest's memory. But when "--compress" is specified with "virsh dump --memory-only", 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@cn.fujitsu.com> --- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 13 ++++++++++++- src/qemu/qemu_conf.c | 3 +++ src/qemu/qemu_conf.h | 2 ++ src/qemu/qemu_driver.c | 37 ++++++++++++++++++++++++++++++++++--- src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index a9ff421..d3704fc 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -61,6 +61,7 @@ module Libvirtd_qemu = let save_entry = str_entry "save_image_format" | str_entry "dump_image_format" | str_entry "snapshot_image_format" + | str_entry "dump_memory_format" | str_entry "auto_dump_path" | bool_entry "auto_dump_bypass_cache" | bool_entry "auto_start_bypass_cache" diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index e436084..148a6bc 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -292,7 +292,8 @@ # dump_image_format is used when you use 'virsh dump' at emergency # crashdump, and if the specified dump_image_format is not valid, or # the requested compression program can't be found, this falls -# back to "raw" compression. +# back to "raw" compression. Note, dump_image_format doesn't work when you use +# "virsh dump --memory-only". # # 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 @@ -303,6 +304,16 @@ #dump_image_format = "raw" #snapshot_image_format = "raw" +# Qemu can dump guest's memory in elf format or in kdump-compressed format, and +# the compression of kdump_compressed format can be zlib/lzo/snappy. +# +# dump_memory_format is used to specify the format in which qemu dumps guest's +# memory. However, if "--compress" is specified with 'virsh dump --memory-only', +# dump_memory_format will not work. +# dump_memory_format can be elf, kdump-zlib, kdump-lzo and kdump-snappy. +# +#dump_memory_format = "elf" + # 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 # specified by auto_dump_path. Default value is /var/lib/libvirt/qemu/dump diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ecaaf81..7d225da 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); @@ -548,6 +549,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, GET_VALUE_STR("dump_image_format", cfg->dumpImageFormat); GET_VALUE_STR("snapshot_image_format", cfg->snapshotImageFormat); + GET_VALUE_STR("dump_memory_format", cfg->dumpMemoryFormat); + 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 1f44a76..97b0f67 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -149,6 +149,8 @@ struct _virQEMUDriverConfig { char *dumpImageFormat; char *snapshotImageFormat; + char *dumpMemoryFormat; + char *autoDumpPath; bool autoDumpBypassCache; bool autoStartBypassCache; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 19b4dd2..c6f8ae9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3410,6 +3410,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(qemuDumpMemoryFormat) +VIR_ENUM_IMPL(qemuDumpMemoryFormat, QEMU_DUMP_MEMORY_FORMAT_LAST, + "elf", + "kdump-zlib", + "kdump-lzo", + "kdump-snappy") + static int doCoreDump(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3422,7 +3437,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) { @@ -3452,8 +3469,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 = qemuDumpMemoryFormatTypeFromString( + 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" }

ping... On 02/20/2014 10:28 AM, Qiao Nuohan wrote:
dumping guest's memroy is introduced without compression supported, and this is a freature regression of 'virsh dump --memory-only'. This patchset is used to add support in libvirt side to make qemu dump guest's memory in kdump-compressed format and please refer the following address to see implementation of the qemu side, the lastest version of qemu side is v9(ready for being queued).
http://lists.nongnu.org/archive/html/qemu-devel/2014-02/msg03016.html
qiaonuohan (2): make qemu dump memory in kdump-compressed format add dump_memory_format in qemu.conf
include/libvirt/libvirt.h.in | 19 ++++++++++---- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 13 +++++++++- src/qemu/qemu_conf.c | 3 +++ src/qemu/qemu_conf.h | 2 ++ src/qemu/qemu_driver.c | 51 +++++++++++++++++++++++++++++++++++--- src/qemu/qemu_monitor.c | 6 ++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 4 ++- src/qemu/qemu_monitor_json.h | 3 ++- src/qemu/test_libvirtd_qemu.aug.in | 1 + tests/qemumonitorjsontest.c | 2 +- tools/virsh-domain.c | 42 +++++++++++++++++++++++++++++++ 13 files changed, 133 insertions(+), 17 deletions(-)
-- Regards Qiao Nuohan
participants (2)
-
Daniel P. Berrange
-
Qiao Nuohan