You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.5 KiB

From de03c66f06549081fef4d5600eb9a2136664a0fa Mon Sep 17 00:00:00 2001
From: Xu Wang <gesaint@linux.vnet.ibm.com>
Date: Mon, 19 Aug 2013 17:11:10 +0800
Subject: [PATCH 05/48] Add dumpCore tag support to memory
dumpCore tag in the <memory> is not supported by libvirt-cim and
it will be dropped during updating any element in the xml definition
of a domain. This patch keep the tag all the time.
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
libxkutil/device_parsing.c | 28 +++++++++++++++++++++++++++-
libxkutil/device_parsing.h | 3 +++
libxkutil/xmlgen.c | 9 +++++++++
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index ffdf682..542e4e9 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -606,8 +606,17 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs)
if (XSTREQ(node->name, "currentMemory"))
sscanf(content, "%" PRIu64, &mdev->size);
- else if (XSTREQ(node->name, "memory"))
+ else if (XSTREQ(node->name, "memory")) {
sscanf(content, "%" PRIu64, &mdev->maxsize);
+ content = get_attr_value(node, "dumpCore");
+ if (content && XSTREQ(content, "on")) {
+ mdev->dumpCore = MEM_DUMP_CORE_ON;
+ } else if (content && XSTREQ(content, "off")) {
+ mdev->dumpCore = MEM_DUMP_CORE_OFF;
+ } else {
+ mdev->dumpCore = MEM_DUMP_CORE_NOT_SET;
+ }
+ }
free(content);
@@ -969,6 +978,7 @@ static int _get_mem_device(const char *xml, struct virt_device **list)
struct virt_device *mdevs = NULL;
struct virt_device *mdev = NULL;
int ret;
+ bool mem_dump_core_set = false;
ret = parse_devices(xml, &mdevs, CIM_RES_TYPE_MEM);
if (ret <= 0)
@@ -988,10 +998,26 @@ static int _get_mem_device(const char *xml, struct virt_device **list)
mdevs[1].dev.mem.size);
mdev->dev.mem.maxsize = MAX(mdevs[0].dev.mem.maxsize,
mdevs[1].dev.mem.maxsize);
+ /* libvirt dumpCore tag always belong to memory xml node, but
+ * here we may have two mdev for memory node and currentMemory
+ * node. So pick up one value.
+ */
+ if (mdevs[0].dev.mem.dumpCore != MEM_DUMP_CORE_NOT_SET) {
+ mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore;
+ mem_dump_core_set = true;
+ } else if (mdevs[1].dev.mem.dumpCore !=
+ MEM_DUMP_CORE_NOT_SET) {
+ if (mem_dump_core_set) {
+ CU_DEBUG("WARN: libvirt set memory core dump in"
+ "two nodes!");
+ }
+ mdev->dev.mem.dumpCore = mdevs[1].dev.mem.dumpCore;
+ }
} else {
mdev->dev.mem.size = MAX(mdevs[0].dev.mem.size,
mdevs[0].dev.mem.maxsize);
mdev->dev.mem.maxsize = mdev->dev.mem.size;
+ mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore;
}
mdev->type = CIM_RES_TYPE_MEM;
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h
index 2b6d3d1..979b792 100644
--- a/libxkutil/device_parsing.h
+++ b/libxkutil/device_parsing.h
@@ -75,6 +75,9 @@ struct net_device {
struct mem_device {
uint64_t size;
uint64_t maxsize;
+ enum { MEM_DUMP_CORE_NOT_SET,
+ MEM_DUMP_CORE_ON,
+ MEM_DUMP_CORE_OFF } dumpCore;
};
struct vcpu_device {
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 4287d42..30e9a5e 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -498,6 +498,15 @@ static const char *mem_xml(xmlNodePtr root, struct domain *dominfo)
BAD_CAST string);
free(string);
+
+ if (tmp == NULL)
+ return XML_ERROR;
+ if (mem->dumpCore == MEM_DUMP_CORE_ON) {
+ xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "on");
+ } else if (mem->dumpCore == MEM_DUMP_CORE_OFF) {
+ xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "off");
+ }
+
out:
if (tmp == NULL)
return XML_ERROR;
--
1.8.5.3