Now, virsh dump doesn't support compresses dump. This patch adds GZIP and LZOP option to virsh dump and support it at qemu coredump. (AFAIK, LZOP is available on RHEL6.) When I did 4G guest dump, (Raw) 3844669750 (Gzip) 1029846577 (LZOP) 1416263880 (faster than gzip in general) This will be a help for a host where crash-dump is used and several guests works on it. help message is modified as this. NAME dump - dump the core of a domain to a file for analysis SYNOPSIS dump [--live] [--crash] [--gzip] [--lzop] <domain> <file> DESCRIPTION Core dump a domain. OPTIONS --live perform a live core dump if supported --crash crash the domain after core dump --gzip gzip dump(only one compression allowed --lzop lzop dump(only one compression allowed [--domain] <string> domain name, id or uuid [--file] <string> where to dump the core Tested on Fedora-13+x86-64. Note: for better compression, we may have to skip pages filled by zero or freed pages. But it seems it's qemu's works. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> --- include/libvirt/libvirt.h.in | 2 ++ src/qemu/qemu_driver.c | 23 +++++++++++++++++++---- tools/virsh.c | 10 +++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) Index: libvirt-0.8.4/src/qemu/qemu_driver.c =================================================================== --- libvirt-0.8.4.orig/src/qemu/qemu_driver.c +++ libvirt-0.8.4/src/qemu/qemu_driver.c @@ -5710,7 +5710,7 @@ cleanup: static int qemudDomainCoreDump(virDomainPtr dom, const char *path, - int flags ATTRIBUTE_UNUSED) { + int flags) { struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; int resume = 0, paused = 0; @@ -5720,6 +5720,14 @@ static int qemudDomainCoreDump(virDomain "cat", NULL, }; + const char *zargs[] = { + "gzip", + NULL, + }; + const char *lzargs[] = { + "lzop", + NULL, + }; qemuDomainObjPrivatePtr priv; qemuDriverLock(driver); @@ -5787,9 +5795,16 @@ static int qemudDomainCoreDump(virDomain } qemuDomainObjEnterMonitorWithDriver(driver, vm); - ret = qemuMonitorMigrateToFile(priv->mon, - QEMU_MONITOR_MIGRATE_BACKGROUND, - args, path, 0); + if (flags & VIR_DUMP_GZIP) + ret = qemuMonitorMigrateToFile(priv->mon, + QEMU_MONITOR_MIGRATE_BACKGROUND, zargs, path, 0); + else if (flags & VIR_DUMP_LZOP) + ret = qemuMonitorMigrateToFile(priv->mon, + QEMU_MONITOR_MIGRATE_BACKGROUND, lzargs, path, 0); + else + ret = qemuMonitorMigrateToFile(priv->mon, + QEMU_MONITOR_MIGRATE_BACKGROUND, args, path, 0); + qemuDomainObjExitMonitorWithDriver(driver, vm); if (ret < 0) goto endjob; Index: libvirt-0.8.4/tools/virsh.c =================================================================== --- libvirt-0.8.4.orig/tools/virsh.c +++ libvirt-0.8.4/tools/virsh.c @@ -1751,6 +1751,8 @@ static const vshCmdInfo info_dump[] = { static const vshCmdOptDef opts_dump[] = { {"live", VSH_OT_BOOL, 0, N_("perform a live core dump if supported")}, {"crash", VSH_OT_BOOL, 0, N_("crash the domain after core dump")}, + {"gzip", VSH_OT_BOOL, 0, N_("gzip dump(only one compression allowed")}, + {"lzop", VSH_OT_BOOL, 0, N_("lzop dump(only one compression allowed")}, {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to dump the core")}, {NULL, 0, 0, NULL} @@ -1778,7 +1780,13 @@ cmdDump(vshControl *ctl, const vshCmd *c flags |= VIR_DUMP_LIVE; if (vshCommandOptBool (cmd, "crash")) flags |= VIR_DUMP_CRASH; - + if (vshCommandOptBool (cmd, "gzip")) + flags |= VIR_DUMP_GZIP; + if (vshCommandOptBool (cmd, "lzop")) + flags |= VIR_DUMP_LZOP; + if ((flags & (VIR_DUMP_GZIP | VIR_DUMP_LZOP)) + == (VIR_DUMP_GZIP | VIR_DUMP_LZOP)) + return FALSE; if (virDomainCoreDump(dom, to, flags) == 0) { vshPrint(ctl, _("Domain %s dumped to %s\n"), name, to); } else { Index: libvirt-0.8.4/include/libvirt/libvirt.h.in =================================================================== --- libvirt-0.8.4.orig/include/libvirt/libvirt.h.in +++ libvirt-0.8.4/include/libvirt/libvirt.h.in @@ -402,6 +402,8 @@ typedef virDomainMemoryStatStruct *virDo typedef enum { VIR_DUMP_CRASH = (1 << 0), /* crash after dump */ VIR_DUMP_LIVE = (1 << 1), /* live dump */ + VIR_DUMP_GZIP = (1 << 2), /* gzip dump file */ + VIR_DUMP_LZOP = (1 << 3), /* lzop dump file */ } virDomainCoreDumpFlags; /* Domain migration flags. */ -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list