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