[libvirt] [PATCH 0/4] Support for limiting guest coredumps

This series applies on the disable_s3/s4 series [1] and works with qemu patch [2] (not applied yet), so it shouldn't be pushed before the qemu part is. Basically qemu supports marking guest memory as (not)dumpable using madvise(2) system call and in case the guest memory is not desired the option can reduce the coredump by a reasonable size. Martin [1] https://www.redhat.com/archives/libvir-list/2012-August/msg00572.html [2] http://lists.nongnu.org/archive/html/qemu-devel/2012-08/msg00554.html Martin Kletzander (4): Add support for limiting guest coredump qemu: add support for dump-guest-core option tests: Add tests for dump-core option docs: Document dump-core memory feature docs/formatdomain.html.in | 13 ++- docs/schemas/domaincommon.rng | 8 ++ src/conf/domain_conf.c | 19 ++++- src/conf/domain_conf.h | 10 ++ src/libvirt_private.syms | 2 + src/qemu/qemu_capabilities.c | 4 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 89 ++++++++++++++++++-- tests/qemuargv2xmltest.c | 2 + .../qemuxml2argv-machine-core-off.args | 5 + .../qemuxml2argv-machine-core-off.xml | 26 ++++++ .../qemuxml2argv-machine-core-on.args | 5 + .../qemuxml2argv-machine-core-on.xml | 26 ++++++ tests/qemuxml2argvtest.c | 3 + tests/qemuxml2xmltest.c | 2 + 15 files changed, 202 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.xml -- 1.7.8.6

Sometimes when guest machine crashes, coredump can get huge due to the guest memory. This can be limited using madvise(2) system call and is being used in QEMU hypervisor. This patch adds an option for configuring that in the domain XML. --- docs/schemas/domaincommon.rng | 8 ++++++++ src/conf/domain_conf.c | 19 ++++++++++++++++++- src/conf/domain_conf.h | 10 ++++++++++ src/libvirt_private.syms | 2 ++ 4 files changed, 38 insertions(+), 1 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d0c6d47..548b306 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -455,6 +455,14 @@ <interleave> <element name="memory"> <ref name='scaledInteger'/> + <optional> + <attribute name="dump-core"> + <choice> + <value>on</value> + <value>off</value> + </choice> + </attribute> + </optional> </element> <optional> <element name="currentMemory"> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f8fe8b5..4944d0f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -376,6 +376,11 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST, "ac97", "ich6") +VIR_ENUM_IMPL(virDomainMemDump, VIR_DOMAIN_MEM_DUMP_LAST, + "default", + "on", + "off") + VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST, "virtio", "xen", @@ -8081,6 +8086,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, &def->mem.cur_balloon, false) < 0) goto error; + /* and info about it */ + tmp = virXPathString("string(./memory[1]/@dump-core)", ctxt); + if (tmp) { + def->mem.dump_core = virDomainMemDumpTypeFromString(tmp); + VIR_FREE(tmp); + } + if (def->mem.cur_balloon > def->mem.max_balloon) { /* Older libvirt could get into this situation due to * rounding; if the discrepancy is less than 1MiB, we silently @@ -12780,8 +12792,13 @@ virDomainDefFormatInternal(virDomainDefPtr def, xmlIndentTreeOutput = oldIndentTreeOutput; } - virBufferAsprintf(buf, " <memory unit='KiB'>%llu</memory>\n", + virBufferAddLit(buf, " <memory"); + if (def->mem.dump_core) + virBufferAsprintf(buf, " dump-core='%s'", + virDomainMemDumpTypeToString(def->mem.dump_core)); + virBufferAsprintf(buf, " unit='KiB'>%llu</memory>\n", def->mem.max_balloon); + virBufferAsprintf(buf, " <currentMemory unit='KiB'>%llu</currentMemory>\n", def->mem.cur_balloon); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 469455e..b27aa68 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1297,6 +1297,14 @@ struct _virDomainRedirdevDef { virDomainDeviceInfo info; /* Guest address */ }; +enum virDomainMemDump { + VIR_DOMAIN_MEM_DUMP_DEFAULT = 0, + VIR_DOMAIN_MEM_DUMP_ON, + VIR_DOMAIN_MEM_DUMP_OFF, + + VIR_DOMAIN_MEM_DUMP_LAST, +}; + enum { VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO, VIR_DOMAIN_MEMBALLOON_MODEL_XEN, @@ -1597,6 +1605,7 @@ struct _virDomainDef { unsigned long long max_balloon; /* in kibibytes */ unsigned long long cur_balloon; /* in kibibytes */ bool hugepage_backed; + int dump_core; /* enum virDomainMemDump */ unsigned long long hard_limit; /* in kibibytes */ unsigned long long soft_limit; /* in kibibytes */ unsigned long long min_guarantee; /* in kibibytes */ @@ -2213,6 +2222,7 @@ VIR_ENUM_DECL(virDomainChrTcpProtocol) VIR_ENUM_DECL(virDomainChrSpicevmc) VIR_ENUM_DECL(virDomainSoundCodec) VIR_ENUM_DECL(virDomainSoundModel) +VIR_ENUM_DECL(virDomainMemDump) VIR_ENUM_DECL(virDomainMemballoonModel) VIR_ENUM_DECL(virDomainSmbiosMode) VIR_ENUM_DECL(virDomainWatchdogModel) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4129653..f11e21f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -397,6 +397,8 @@ virDomainLiveConfigHelperMethod; virDomainLoadAllConfigs; virDomainMemballoonModelTypeFromString; virDomainMemballoonModelTypeToString; +virDomainMemDumpTypeFromString; +virDomainMemDumpTypeToString; virDomainNetDefFree; virDomainNetFind; virDomainNetGetActualBandwidth; -- 1.7.8.6

On 15.08.2012 11:25, Martin Kletzander wrote:
Sometimes when guest machine crashes, coredump can get huge due to the guest memory. This can be limited using madvise(2) system call and is being used in QEMU hypervisor. This patch adds an option for configuring that in the domain XML. --- docs/schemas/domaincommon.rng | 8 ++++++++ src/conf/domain_conf.c | 19 ++++++++++++++++++- src/conf/domain_conf.h | 10 ++++++++++ src/libvirt_private.syms | 2 ++ 4 files changed, 38 insertions(+), 1 deletions(-)
Even though I'd like to see XML extension and it's documentation in one patch, I am okay with that being a separate one.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f8fe8b5..4944d0f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -376,6 +376,11 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST, "ac97", "ich6")
+VIR_ENUM_IMPL(virDomainMemDump, VIR_DOMAIN_MEM_DUMP_LAST, + "default", + "on", + "off") + VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST, "virtio", "xen", @@ -8081,6 +8086,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, &def->mem.cur_balloon, false) < 0) goto error;
+ /* and info about it */ + tmp = virXPathString("string(./memory[1]/@dump-core)", ctxt); + if (tmp) { + def->mem.dump_core = virDomainMemDumpTypeFromString(tmp);
should we silently ignore unknown values?
+ VIR_FREE(tmp); + } + if (def->mem.cur_balloon > def->mem.max_balloon) { /* Older libvirt could get into this situation due to * rounding; if the discrepancy is less than 1MiB, we silently
ACK modulo silent ignoring. Michal

The "dump-guest-core' option is new option for the machine type (-machine pc,dump-guest-core) that controls whether the guest memory will be marked as dumpable. While testing this, I've found out that the value for the '-M' options is not parsed correctly when additional parameters are used. However, when '-machine' is used for the same options, it gets parsed as expected. That's why this patch also modifies the parsing and creating of the command line, so both '-M' and '-machine' are recognized. In QEMU's help there is only mention of the 'machine parameter now with no sign of the older '-M'. --- src/qemu/qemu_capabilities.c | 4 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 89 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b8160b6..37d96b3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -175,6 +175,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, "disable-s3", "disable-s4", + "dump-guest-core", /* 101 */ ); struct qemu_feature_flags { @@ -1175,6 +1176,9 @@ qemuCapsComputeCmdFlags(const char *help, if (strstr(help, "-no-shutdown") && (version < 14000 || version > 15000)) qemuCapsSet(flags, QEMU_CAPS_NO_SHUTDOWN); + if (strstr(help, "dump-guest-core=on|off")) + qemuCapsSet(flags, QEMU_CAPS_DUMP_GUEST_CORE); + /* * Handling of -incoming arg with varying features * -incoming tcp (kvm >= 79, qemu >= 0.10.0) diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e49424a..f35b1b5 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -140,6 +140,7 @@ enum qemuCapsFlags { QEMU_CAPS_VIRTIO_SCSI_PCI = 102, /* -device virtio-scsi-pci */ QEMU_CAPS_DISABLE_S3 = 103, /* S3 BIOS Advertisement on/off */ QEMU_CAPS_DISABLE_S4 = 104, /* S4 BIOS Advertisement on/off */ + QEMU_CAPS_DUMP_GUEST_CORE = 105, /* dump-guest-core parameter */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 34ee00e..0af5233 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4190,6 +4190,53 @@ no_memory: goto cleanup; } +static int +qemuBuildMachineArgStr(virCommandPtr cmd, + const virDomainDefPtr def, + virBitmapPtr qemuCaps) +{ + /* This should *never* be NULL, since we always provide + * a machine in the capabilities data for QEMU. So this + * check is just here as a safety in case the unexpected + * happens */ + if (def->os.machine) { + if (!def->mem.dump_core) { + /* if no parameter to the machine type is needed, we still use + * '-M' to keep the most of the compatibility with older versions. + */ + virCommandAddArgList(cmd, "-M", def->os.machine, NULL); + } else { + char *machine = NULL; + + if (!qemuCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("dump-guest-core is not available " + " with this QEMU binary")); + return -1; + } + + virAsprintf(&machine, + "%s,%s=%s", + def->os.machine, + "dump-guest-core", + virDomainMemDumpTypeToString(def->mem.dump_core)); + + if (machine == NULL) { + virReportOOMError(); + return -1; + } + + /* However, in case there is a parameter to be added, we need to + * use the "-machine" parameter because qemu is not parsing the + * "-M" correctly */ + virCommandAddArgList(cmd, "-machine", machine, NULL); + VIR_FREE(machine); + } + } + + return 0; +} + static char * qemuBuildSmpArgStr(const virDomainDefPtr def, virBitmapPtr qemuCaps) @@ -4403,12 +4450,8 @@ qemuBuildCommandLine(virConnectPtr conn, } virCommandAddArg(cmd, "-S"); /* freeze CPU */ - /* This should *never* be NULL, since we always provide - * a machine in the capabilities data for QEMU. So this - * check is just here as a safety in case the unexpected - * happens */ - if (def->os.machine) - virCommandAddArgList(cmd, "-M", def->os.machine, NULL); + if (qemuBuildMachineArgStr(cmd, def, qemuCaps) < 0) + goto error; if (qemuBuildCpuArgStr(driver, def, emulator, qemuCaps, &ut, &cpu, &hasHwVirt, !!migrateFrom) < 0) @@ -8091,10 +8134,38 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, } if (STREQ(def->name, "")) VIR_FREE(def->name); - } else if (STREQ(arg, "-M")) { + } else if (STREQ(arg, "-M") || + STREQ(arg, "-machine")) { + char *params; WANT_VALUE(); - if (!(def->os.machine = strdup(val))) - goto no_memory; + params = strchr(val, ','); + if (params == NULL) { + if (!(def->os.machine = strdup(val))) + goto no_memory; + } else { + if (!(def->os.machine = strndup(val, params - val))) + goto no_memory; + + while(params++) { + /* prepared for more "-machine" parameters */ + const char *tmp = params; + params = strchr(params, ','); + + if (STRPREFIX(tmp, "dump-guest-core=")) { + tmp += strlen("dump-guest-core="); + if (params) { + tmp = strndup(tmp, params - tmp); + if (tmp == NULL) + goto no_memory; + } + def->mem.dump_core = virDomainMemDumpTypeFromString(tmp); + if (def->mem.dump_core == -1) + def->mem.dump_core = VIR_DOMAIN_MEM_DUMP_DEFAULT; + if (params) + VIR_FREE(tmp); + } + } + } } else if (STREQ(arg, "-serial")) { WANT_VALUE(); if (STRNEQ(val, "none")) { -- 1.7.8.6

On 15.08.2012 11:25, Martin Kletzander wrote:
The "dump-guest-core' option is new option for the machine type (-machine pc,dump-guest-core) that controls whether the guest memory will be marked as dumpable.
While testing this, I've found out that the value for the '-M' options is not parsed correctly when additional parameters are used. However, when '-machine' is used for the same options, it gets parsed as expected. That's why this patch also modifies the parsing and creating of the command line, so both '-M' and '-machine' are recognized. In QEMU's help there is only mention of the 'machine parameter now with no sign of the older '-M'. --- src/qemu/qemu_capabilities.c | 4 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 89 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 85 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b8160b6..37d96b3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -175,6 +175,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, "disable-s3", "disable-s4",
+ "dump-guest-core", /* 101 */ );
struct qemu_feature_flags { @@ -1175,6 +1176,9 @@ qemuCapsComputeCmdFlags(const char *help, if (strstr(help, "-no-shutdown") && (version < 14000 || version > 15000)) qemuCapsSet(flags, QEMU_CAPS_NO_SHUTDOWN);
+ if (strstr(help, "dump-guest-core=on|off")) + qemuCapsSet(flags, QEMU_CAPS_DUMP_GUEST_CORE); + /* * Handling of -incoming arg with varying features * -incoming tcp (kvm >= 79, qemu >= 0.10.0) diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e49424a..f35b1b5 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -140,6 +140,7 @@ enum qemuCapsFlags { QEMU_CAPS_VIRTIO_SCSI_PCI = 102, /* -device virtio-scsi-pci */ QEMU_CAPS_DISABLE_S3 = 103, /* S3 BIOS Advertisement on/off */ QEMU_CAPS_DISABLE_S4 = 104, /* S4 BIOS Advertisement on/off */ + QEMU_CAPS_DUMP_GUEST_CORE = 105, /* dump-guest-core parameter */
QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 34ee00e..0af5233 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4190,6 +4190,53 @@ no_memory: goto cleanup; }
+static int +qemuBuildMachineArgStr(virCommandPtr cmd, + const virDomainDefPtr def, + virBitmapPtr qemuCaps) +{ + /* This should *never* be NULL, since we always provide + * a machine in the capabilities data for QEMU. So this + * check is just here as a safety in case the unexpected + * happens */ + if (def->os.machine) {
If you'd rewrite this: if (!def->os.machine) return 0; then you can move this code one level of nesting higher.
+ if (!def->mem.dump_core) { + /* if no parameter to the machine type is needed, we still use + * '-M' to keep the most of the compatibility with older versions. + */ + virCommandAddArgList(cmd, "-M", def->os.machine, NULL); + } else { + char *machine = NULL; + + if (!qemuCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("dump-guest-core is not available " + " with this QEMU binary")); + return -1; + } + + virAsprintf(&machine, + "%s,%s=%s", + def->os.machine, + "dump-guest-core", + virDomainMemDumpTypeToString(def->mem.dump_core)); + + if (machine == NULL) { + virReportOOMError(); + return -1; + } + + /* However, in case there is a parameter to be added, we need to + * use the "-machine" parameter because qemu is not parsing the + * "-M" correctly */ + virCommandAddArgList(cmd, "-machine", machine, NULL); + VIR_FREE(machine); + } + } + + return 0; +} + static char * qemuBuildSmpArgStr(const virDomainDefPtr def, virBitmapPtr qemuCaps) @@ -4403,12 +4450,8 @@ qemuBuildCommandLine(virConnectPtr conn, } virCommandAddArg(cmd, "-S"); /* freeze CPU */
- /* This should *never* be NULL, since we always provide - * a machine in the capabilities data for QEMU. So this - * check is just here as a safety in case the unexpected - * happens */ - if (def->os.machine) - virCommandAddArgList(cmd, "-M", def->os.machine, NULL); + if (qemuBuildMachineArgStr(cmd, def, qemuCaps) < 0) + goto error;
if (qemuBuildCpuArgStr(driver, def, emulator, qemuCaps, &ut, &cpu, &hasHwVirt, !!migrateFrom) < 0) @@ -8091,10 +8134,38 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, } if (STREQ(def->name, "")) VIR_FREE(def->name); - } else if (STREQ(arg, "-M")) { + } else if (STREQ(arg, "-M") || + STREQ(arg, "-machine")) { + char *params; WANT_VALUE(); - if (!(def->os.machine = strdup(val))) - goto no_memory; + params = strchr(val, ','); + if (params == NULL) { + if (!(def->os.machine = strdup(val))) + goto no_memory; + } else { + if (!(def->os.machine = strndup(val, params - val))) + goto no_memory; + + while(params++) { + /* prepared for more "-machine" parameters */ + const char *tmp = params;
This looks rather odd ... [1]
+ params = strchr(params, ','); + + if (STRPREFIX(tmp, "dump-guest-core=")) { + tmp += strlen("dump-guest-core="); + if (params) { + tmp = strndup(tmp, params - tmp);
[1] ... so does this ...
+ if (tmp == NULL) + goto no_memory; + } + def->mem.dump_core = virDomainMemDumpTypeFromString(tmp); + if (def->mem.dump_core == -1)
s/== -1/< 0/
+ def->mem.dump_core = VIR_DOMAIN_MEM_DUMP_DEFAULT; + if (params) + VIR_FREE(tmp);
[1] ... and this. Drop the const keyword.
+ } + } + } } else if (STREQ(arg, "-serial")) { WANT_VALUE(); if (STRNEQ(val, "none")) {
ACK with those nits fixed. Michal

--- tests/qemuargv2xmltest.c | 2 + .../qemuxml2argv-machine-core-off.args | 5 ++++ .../qemuxml2argv-machine-core-off.xml | 26 ++++++++++++++++++++ .../qemuxml2argv-machine-core-on.args | 5 ++++ .../qemuxml2argv-machine-core-on.xml | 26 ++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ tests/qemuxml2xmltest.c | 2 + 7 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.xml diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index ad5f45b..8d6969d 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -142,6 +142,8 @@ mymain(void) /* Can't roundtrip vcpu cpuset attribute */ /*DO_TEST("minimal", QEMU_CAPS_NAME);*/ + DO_TEST("machine-core-on"); + DO_TEST("machine-core-off"); DO_TEST("boot-cdrom"); DO_TEST("boot-network"); DO_TEST("boot-floppy"); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.args new file mode 100644 index 0000000..67b134f --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.args @@ -0,0 +1,5 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \ +-S -machine pc,dump-guest-core=off -m 214 -smp 1 -nographic \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-hda /dev/HostVG/QEMUGuest1 -net none -serial \ +none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.xml b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.xml new file mode 100644 index 0000000..3e5b300 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.xml @@ -0,0 +1,26 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory dump-core='off' unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.args new file mode 100644 index 0000000..189f2fb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.args @@ -0,0 +1,5 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \ +-S -machine pc,dump-guest-core=on -m 214 -smp 1 -nographic \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-hda /dev/HostVG/QEMUGuest1 -net none -serial \ +none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.xml b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.xml new file mode 100644 index 0000000..bc22a5d --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.xml @@ -0,0 +1,26 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory dump-core='on' unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 022792f..88f0281 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -347,6 +347,9 @@ mymain(void) DO_TEST("minimal-s390", QEMU_CAPS_NAME); DO_TEST("machine-aliases1", NONE); DO_TEST_ERROR("machine-aliases2", NONE); + DO_TEST("machine-core-on", QEMU_CAPS_DUMP_GUEST_CORE); + DO_TEST("machine-core-off", QEMU_CAPS_DUMP_GUEST_CORE); + DO_TEST_FAILURE("machine-core-on", NONE); DO_TEST("boot-cdrom", NONE); DO_TEST("boot-network", NONE); DO_TEST("boot-floppy", NONE); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b60736f..75369c1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -126,6 +126,8 @@ mymain(void) setenv("PATH", "/bin", 1); DO_TEST("minimal"); + DO_TEST("machine-core-on"); + DO_TEST("machine-core-off"); DO_TEST("boot-cdrom"); DO_TEST("boot-network"); DO_TEST("boot-floppy"); -- 1.7.8.6

On 15.08.2012 11:25, Martin Kletzander wrote:
--- tests/qemuargv2xmltest.c | 2 + .../qemuxml2argv-machine-core-off.args | 5 ++++ .../qemuxml2argv-machine-core-off.xml | 26 ++++++++++++++++++++ .../qemuxml2argv-machine-core-on.args | 5 ++++ .../qemuxml2argv-machine-core-on.xml | 26 ++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ tests/qemuxml2xmltest.c | 2 + 7 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.xml
ACK Michal

--- docs/formatdomain.html.in | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index bb225b1..af44742 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -474,9 +474,16 @@ However, the value will be rounded up to the nearest kibibyte by libvirt, and may be further rounded to the granularity supported by the hypervisor. Some hypervisors also enforce a - minimum, such as - 4000KiB. <span class='since'><code>unit</code> since - 0.9.11</span></dd> + minimum, such as 4000KiB. + + In the case of crash, optional attribute <code>dump-core</code> + can be used to control whether the guest memory should be + included in the generated coredump. + + <span class='since'><code>unit</code> since 0.9.11</span>, + <span class='since'><code>dump-core</code> since 0.10.0 + (QEMU only)</span></dd> + <dt><code>currentMemory</code></dt> <dd>The actual allocation of memory for the guest. This value can be less than the maximum allocation, to allow for ballooning -- 1.7.8.6

On 15.08.2012 11:25, Martin Kletzander wrote:
--- docs/formatdomain.html.in | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index bb225b1..af44742 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -474,9 +474,16 @@ However, the value will be rounded up to the nearest kibibyte by libvirt, and may be further rounded to the granularity supported by the hypervisor. Some hypervisors also enforce a - minimum, such as - 4000KiB. <span class='since'><code>unit</code> since - 0.9.11</span></dd> + minimum, such as 4000KiB. + + In the case of crash, optional attribute <code>dump-core</code> + can be used to control whether the guest memory should be + included in the generated coredump. + + <span class='since'><code>unit</code> since 0.9.11</span>, + <span class='since'><code>dump-core</code> since 0.10.0 + (QEMU only)</span></dd> + <dt><code>currentMemory</code></dt> <dd>The actual allocation of memory for the guest. This value can be less than the maximum allocation, to allow for ballooning
ACK if you mention accepted values for dump-core attribute. Michal
participants (2)
-
Martin Kletzander
-
Michal Privoznik