|
|
9119d9 |
From 37b4578539091288a7e7851799ebf4289272706e Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <37b4578539091288a7e7851799ebf4289272706e@dist-git>
|
|
|
9119d9 |
From: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
Date: Wed, 17 Sep 2014 16:17:56 +0200
|
|
|
9119d9 |
Subject: [PATCH] docs, conf, schema: add support for shared memory mapping
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1133144
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit def6b35989362cc7ce8474256e19d877ff07a711)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
docs/formatdomain.html.in | 7 +++-
|
|
|
9119d9 |
docs/schemas/domaincommon.rng | 8 ++++
|
|
|
9119d9 |
src/conf/cpu_conf.c | 30 ++++++++++++++-
|
|
|
9119d9 |
src/conf/cpu_conf.h | 17 ++++++--
|
|
|
9119d9 |
.../qemuxml2argv-cpu-numa-memshared.xml | 28 ++++++++++++++
|
|
|
9119d9 |
.../qemuxml2argv-hugepages-shared.xml | 45 ++++++++++++++++++++++
|
|
|
9119d9 |
tests/qemuxml2xmltest.c | 2 +
|
|
|
9119d9 |
7 files changed, 131 insertions(+), 6 deletions(-)
|
|
|
9119d9 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml
|
|
|
9119d9 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
|
|
9119d9 |
index a2ea758..ade40f3 100644
|
|
|
9119d9 |
--- a/docs/formatdomain.html.in
|
|
|
9119d9 |
+++ b/docs/formatdomain.html.in
|
|
|
9119d9 |
@@ -1123,7 +1123,7 @@
|
|
|
9119d9 |
...
|
|
|
9119d9 |
<numa>
|
|
|
9119d9 |
<cell id='0' cpus='0-3' memory='512000'/>
|
|
|
9119d9 |
- <cell id='1' cpus='4-7' memory='512000'/>
|
|
|
9119d9 |
+ <cell id='1' cpus='4-7' memory='512000' memAccess='shared'/>
|
|
|
9119d9 |
</numa>
|
|
|
9119d9 |
...
|
|
|
9119d9 |
</cpu>
|
|
|
9119d9 |
@@ -1140,6 +1140,11 @@
|
|
|
9119d9 |
assigned id s in the increasing order starting from
|
|
|
9119d9 |
0. Mixing cells with and without the id attribute
|
|
|
9119d9 |
is not recommended as it may result in unwanted behaviour.
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ Since 1.2.9 the optional attribute
|
|
|
9119d9 |
+ memAccess can control whether the memory is to be
|
|
|
9119d9 |
+ mapped as "shared" or "private". This is valid only for
|
|
|
9119d9 |
+ hugepages-backed memory.
|
|
|
9119d9 |
|
|
|
9119d9 |
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
|
|
|
9119d9 |
index 6ae940a..75006f5 100644
|
|
|
9119d9 |
--- a/docs/schemas/domaincommon.rng
|
|
|
9119d9 |
+++ b/docs/schemas/domaincommon.rng
|
|
|
9119d9 |
@@ -4092,6 +4092,14 @@
|
|
|
9119d9 |
<attribute name="memory">
|
|
|
9119d9 |
<ref name="memoryKB"/>
|
|
|
9119d9 |
</attribute>
|
|
|
9119d9 |
+ <optional>
|
|
|
9119d9 |
+ <attribute name="memAccess">
|
|
|
9119d9 |
+ <choice>
|
|
|
9119d9 |
+ <value>shared</value>
|
|
|
9119d9 |
+ <value>private</value>
|
|
|
9119d9 |
+ </choice>
|
|
|
9119d9 |
+ </attribute>
|
|
|
9119d9 |
+ </optional>
|
|
|
9119d9 |
</element>
|
|
|
9119d9 |
</define>
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
|
|
9119d9 |
index 5003cf1..e190641 100644
|
|
|
9119d9 |
--- a/src/conf/cpu_conf.c
|
|
|
9119d9 |
+++ b/src/conf/cpu_conf.c
|
|
|
9119d9 |
@@ -56,6 +56,11 @@ VIR_ENUM_IMPL(virCPUFeaturePolicy, VIR_CPU_FEATURE_LAST,
|
|
|
9119d9 |
"disable",
|
|
|
9119d9 |
"forbid")
|
|
|
9119d9 |
|
|
|
9119d9 |
+VIR_ENUM_IMPL(virMemAccess, VIR_MEM_ACCESS_LAST,
|
|
|
9119d9 |
+ "default",
|
|
|
9119d9 |
+ "shared",
|
|
|
9119d9 |
+ "private")
|
|
|
9119d9 |
+
|
|
|
9119d9 |
|
|
|
9119d9 |
void ATTRIBUTE_NONNULL(1)
|
|
|
9119d9 |
virCPUDefFreeModel(virCPUDefPtr def)
|
|
|
9119d9 |
@@ -435,7 +440,7 @@ virCPUDefParseXML(xmlNodePtr node,
|
|
|
9119d9 |
def->ncells = n;
|
|
|
9119d9 |
|
|
|
9119d9 |
for (i = 0; i < n; i++) {
|
|
|
9119d9 |
- char *cpus, *memory;
|
|
|
9119d9 |
+ char *cpus, *memory, *memAccessStr;
|
|
|
9119d9 |
int ret, ncpus = 0;
|
|
|
9119d9 |
unsigned int cur_cell;
|
|
|
9119d9 |
char *tmp = NULL;
|
|
|
9119d9 |
@@ -491,7 +496,7 @@ virCPUDefParseXML(xmlNodePtr node,
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- ret = virStrToLong_ui(memory, NULL, 10, &def->cells[cur_cell].mem);
|
|
|
9119d9 |
+ ret = virStrToLong_ui(memory, NULL, 10, &def->cells[cur_cell].mem);
|
|
|
9119d9 |
if (ret == -1) {
|
|
|
9119d9 |
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
9119d9 |
_("Invalid 'memory' attribute in NUMA cell"));
|
|
|
9119d9 |
@@ -499,6 +504,22 @@ virCPUDefParseXML(xmlNodePtr node,
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
VIR_FREE(memory);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ memAccessStr = virXMLPropString(nodes[i], "memAccess");
|
|
|
9119d9 |
+ if (memAccessStr) {
|
|
|
9119d9 |
+ def->cells[cur_cell].memAccess =
|
|
|
9119d9 |
+ virMemAccessTypeFromString(memAccessStr);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (def->cells[cur_cell].memAccess <= 0) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
9119d9 |
+ _("Invalid 'memAccess' attribute "
|
|
|
9119d9 |
+ "value '%s'"),
|
|
|
9119d9 |
+ memAccessStr);
|
|
|
9119d9 |
+ VIR_FREE(memAccessStr);
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+ VIR_FREE(memAccessStr);
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -674,10 +695,15 @@ virCPUDefFormatBuf(virBufferPtr buf,
|
|
|
9119d9 |
virBufferAddLit(buf, "<numa>\n");
|
|
|
9119d9 |
virBufferAdjustIndent(buf, 2);
|
|
|
9119d9 |
for (i = 0; i < def->ncells; i++) {
|
|
|
9119d9 |
+ virMemAccess memAccess = def->cells[i].memAccess;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
virBufferAddLit(buf, "
|
|
|
9119d9 |
virBufferAsprintf(buf, " id='%zu'", i);
|
|
|
9119d9 |
virBufferAsprintf(buf, " cpus='%s'", def->cells[i].cpustr);
|
|
|
9119d9 |
virBufferAsprintf(buf, " memory='%d'", def->cells[i].mem);
|
|
|
9119d9 |
+ if (memAccess)
|
|
|
9119d9 |
+ virBufferAsprintf(buf, " memAccess='%s'",
|
|
|
9119d9 |
+ virMemAccessTypeToString(memAccess));
|
|
|
9119d9 |
virBufferAddLit(buf, "/>\n");
|
|
|
9119d9 |
}
|
|
|
9119d9 |
virBufferAdjustIndent(buf, -2);
|
|
|
9119d9 |
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
|
|
|
9119d9 |
index 2d538db..d45210b 100644
|
|
|
9119d9 |
--- a/src/conf/cpu_conf.h
|
|
|
9119d9 |
+++ b/src/conf/cpu_conf.h
|
|
|
9119d9 |
@@ -83,6 +83,16 @@ typedef enum {
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_ENUM_DECL(virCPUFeaturePolicy)
|
|
|
9119d9 |
|
|
|
9119d9 |
+typedef enum {
|
|
|
9119d9 |
+ VIR_MEM_ACCESS_DEFAULT,
|
|
|
9119d9 |
+ VIR_MEM_ACCESS_SHARED,
|
|
|
9119d9 |
+ VIR_MEM_ACCESS_PRIVATE,
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ VIR_MEM_ACCESS_LAST,
|
|
|
9119d9 |
+} virMemAccess;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+VIR_ENUM_DECL(virMemAccess)
|
|
|
9119d9 |
+
|
|
|
9119d9 |
typedef struct _virCPUFeatureDef virCPUFeatureDef;
|
|
|
9119d9 |
typedef virCPUFeatureDef *virCPUFeatureDefPtr;
|
|
|
9119d9 |
struct _virCPUFeatureDef {
|
|
|
9119d9 |
@@ -93,9 +103,10 @@ struct _virCPUFeatureDef {
|
|
|
9119d9 |
typedef struct _virCellDef virCellDef;
|
|
|
9119d9 |
typedef virCellDef *virCellDefPtr;
|
|
|
9119d9 |
struct _virCellDef {
|
|
|
9119d9 |
- virBitmapPtr cpumask; /* CPUs that are part of this node */
|
|
|
9119d9 |
- char *cpustr; /* CPUs stored in string form for dumpxml */
|
|
|
9119d9 |
- unsigned int mem; /* Node memory in kB */
|
|
|
9119d9 |
+ virBitmapPtr cpumask; /* CPUs that are part of this node */
|
|
|
9119d9 |
+ char *cpustr; /* CPUs stored in string form for dumpxml */
|
|
|
9119d9 |
+ unsigned int mem; /* Node memory in kB */
|
|
|
9119d9 |
+ virMemAccess memAccess;
|
|
|
9119d9 |
};
|
|
|
9119d9 |
|
|
|
9119d9 |
typedef struct _virCPUDef virCPUDef;
|
|
|
9119d9 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml
|
|
|
9119d9 |
new file mode 100644
|
|
|
9119d9 |
index 0000000..cf7c040
|
|
|
9119d9 |
--- /dev/null
|
|
|
9119d9 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml
|
|
|
9119d9 |
@@ -0,0 +1,28 @@
|
|
|
9119d9 |
+<domain type='qemu'>
|
|
|
9119d9 |
+ <name>QEMUGuest1</name>
|
|
|
9119d9 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
9119d9 |
+ <memory unit='KiB'>219100</memory>
|
|
|
9119d9 |
+ <currentMemory unit='KiB'>219100</currentMemory>
|
|
|
9119d9 |
+ <vcpu placement='static'>16</vcpu>
|
|
|
9119d9 |
+ <os>
|
|
|
9119d9 |
+ <type arch='x86_64' machine='pc'>hvm</type>
|
|
|
9119d9 |
+ <boot dev='network'/>
|
|
|
9119d9 |
+ </os>
|
|
|
9119d9 |
+ <cpu>
|
|
|
9119d9 |
+ <topology sockets='2' cores='4' threads='2'/>
|
|
|
9119d9 |
+ <numa>
|
|
|
9119d9 |
+ <cell id='0' cpus='0-7' memory='109550' memAccess='shared'/>
|
|
|
9119d9 |
+ <cell id='1' cpus='8-15' memory='109550' memAccess='private'/>
|
|
|
9119d9 |
+ </numa>
|
|
|
9119d9 |
+ </cpu>
|
|
|
9119d9 |
+ <clock offset='utc'/>
|
|
|
9119d9 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
9119d9 |
+ <on_reboot>restart</on_reboot>
|
|
|
9119d9 |
+ <on_crash>destroy</on_crash>
|
|
|
9119d9 |
+ <devices>
|
|
|
9119d9 |
+ <emulator>/usr/bin/qemu</emulator>
|
|
|
9119d9 |
+ <controller type='usb' index='0'/>
|
|
|
9119d9 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
9119d9 |
+ <memballoon model='virtio'/>
|
|
|
9119d9 |
+ </devices>
|
|
|
9119d9 |
+</domain>
|
|
|
9119d9 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml
|
|
|
9119d9 |
new file mode 100644
|
|
|
9119d9 |
index 0000000..e7db69c
|
|
|
9119d9 |
--- /dev/null
|
|
|
9119d9 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml
|
|
|
9119d9 |
@@ -0,0 +1,45 @@
|
|
|
9119d9 |
+<domain type='qemu'>
|
|
|
9119d9 |
+ <name>QEMUGuest1</name>
|
|
|
9119d9 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
9119d9 |
+ <memory unit='KiB'>4194304</memory>
|
|
|
9119d9 |
+ <currentMemory unit='KiB'>4194304</currentMemory>
|
|
|
9119d9 |
+ <memoryBacking>
|
|
|
9119d9 |
+ <hugepages>
|
|
|
9119d9 |
+ <page size='2048' unit='KiB' nodeset='1'/>
|
|
|
9119d9 |
+ <page size='1048576' unit='KiB' nodeset='0,2-3'/>
|
|
|
9119d9 |
+ </hugepages>
|
|
|
9119d9 |
+ </memoryBacking>
|
|
|
9119d9 |
+ <vcpu placement='static'>4</vcpu>
|
|
|
9119d9 |
+ <numatune>
|
|
|
9119d9 |
+ <memory mode='strict' nodeset='0-3'/>
|
|
|
9119d9 |
+ <memnode cellid='3' mode='strict' nodeset='3'/>
|
|
|
9119d9 |
+ </numatune>
|
|
|
9119d9 |
+ <os>
|
|
|
9119d9 |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
9119d9 |
+ <boot dev='hd'/>
|
|
|
9119d9 |
+ </os>
|
|
|
9119d9 |
+ <cpu>
|
|
|
9119d9 |
+ <numa>
|
|
|
9119d9 |
+ <cell id='0' cpus='0' memory='1048576'/>
|
|
|
9119d9 |
+ <cell id='1' cpus='1' memory='1048576' memAccess='shared'/>
|
|
|
9119d9 |
+ <cell id='2' cpus='2' memory='1048576' memAccess='private'/>
|
|
|
9119d9 |
+ <cell id='3' cpus='3' memory='1048576'/>
|
|
|
9119d9 |
+ </numa>
|
|
|
9119d9 |
+ </cpu>
|
|
|
9119d9 |
+ <clock offset='utc'/>
|
|
|
9119d9 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
9119d9 |
+ <on_reboot>restart</on_reboot>
|
|
|
9119d9 |
+ <on_crash>destroy</on_crash>
|
|
|
9119d9 |
+ <devices>
|
|
|
9119d9 |
+ <emulator>/usr/bin/qemu</emulator>
|
|
|
9119d9 |
+ <disk type='block' device='disk'>
|
|
|
9119d9 |
+ <source dev='/dev/HostVG/QEMUGuest1'/>
|
|
|
9119d9 |
+ <target dev='hda' bus='ide'/>
|
|
|
9119d9 |
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
|
9119d9 |
+ </disk>
|
|
|
9119d9 |
+ <controller type='usb' index='0'/>
|
|
|
9119d9 |
+ <controller type='ide' index='0'/>
|
|
|
9119d9 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
9119d9 |
+ <memballoon model='virtio'/>
|
|
|
9119d9 |
+ </devices>
|
|
|
9119d9 |
+</domain>
|
|
|
9119d9 |
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
|
|
|
9119d9 |
index 1835fe6..180665b 100644
|
|
|
9119d9 |
--- a/tests/qemuxml2xmltest.c
|
|
|
9119d9 |
+++ b/tests/qemuxml2xmltest.c
|
|
|
9119d9 |
@@ -205,6 +205,7 @@ mymain(void)
|
|
|
9119d9 |
DO_TEST("hugepages-pages");
|
|
|
9119d9 |
DO_TEST("hugepages-pages2");
|
|
|
9119d9 |
DO_TEST("hugepages-pages3");
|
|
|
9119d9 |
+ DO_TEST("hugepages-shared");
|
|
|
9119d9 |
DO_TEST("nosharepages");
|
|
|
9119d9 |
DO_TEST("disk-aio");
|
|
|
9119d9 |
DO_TEST("disk-cdrom");
|
|
|
9119d9 |
@@ -390,6 +391,7 @@ mymain(void)
|
|
|
9119d9 |
DO_TEST_DIFFERENT("cpu-numa1");
|
|
|
9119d9 |
DO_TEST_DIFFERENT("cpu-numa2");
|
|
|
9119d9 |
DO_TEST("cpu-numa-disjoint");
|
|
|
9119d9 |
+ DO_TEST("cpu-numa-memshared");
|
|
|
9119d9 |
|
|
|
9119d9 |
DO_TEST_DIFFERENT("numatune-auto-prefer");
|
|
|
9119d9 |
DO_TEST_DIFFERENT("numatune-memnode");
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.0
|
|
|
9119d9 |
|