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