|
|
edecca |
From d1a499f071b2a223641d2e4f0783eda1ad67d1ae Mon Sep 17 00:00:00 2001
|
|
|
edecca |
Message-Id: <d1a499f071b2a223641d2e4f0783eda1ad67d1ae@dist-git>
|
|
|
edecca |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
edecca |
Date: Mon, 13 Aug 2018 19:21:52 +0200
|
|
|
edecca |
Subject: [PATCH] conf: Move hugepage XML validation check out of qemu_command
|
|
|
edecca |
MIME-Version: 1.0
|
|
|
edecca |
Content-Type: text/plain; charset=UTF-8
|
|
|
edecca |
Content-Transfer-Encoding: 8bit
|
|
|
edecca |
|
|
|
edecca |
We can safely validate the hugepage nodeset attribute at a define time.
|
|
|
edecca |
This validation is not done for already existing domains when the daemon
|
|
|
edecca |
is restarted.
|
|
|
edecca |
|
|
|
edecca |
All the changes to the tests are necessary because we move the error
|
|
|
edecca |
from domain start into XML parse.
|
|
|
edecca |
|
|
|
edecca |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
edecca |
(cherry picked from commit 5c93dfb46d9dff623707994f115b6bd7ca4f0682)
|
|
|
edecca |
|
|
|
edecca |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1615461
|
|
|
edecca |
|
|
|
edecca |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
edecca |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
edecca |
---
|
|
|
edecca |
src/conf/domain_conf.c | 32 +++++++++++++++++
|
|
|
edecca |
src/qemu/qemu_command.c | 34 -------------------
|
|
|
edecca |
.../seclabel-dynamic-none-relabel.xml | 2 +-
|
|
|
edecca |
tests/qemuxml2argvtest.c | 18 +++++-----
|
|
|
edecca |
.../hugepages-default-1G-nodeset-2M.xml | 1 -
|
|
|
edecca |
.../qemuxml2xmloutdata/hugepages-nodeset.xml | 1 -
|
|
|
edecca |
.../hugepages-numa-nodeset-nonexist.xml | 1 -
|
|
|
edecca |
.../seclabel-dynamic-none-relabel.xml | 2 +-
|
|
|
edecca |
tests/qemuxml2xmltest.c | 3 --
|
|
|
edecca |
9 files changed, 43 insertions(+), 51 deletions(-)
|
|
|
edecca |
delete mode 120000 tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
|
|
|
edecca |
delete mode 120000 tests/qemuxml2xmloutdata/hugepages-nodeset.xml
|
|
|
edecca |
delete mode 120000 tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
|
|
|
edecca |
|
|
|
edecca |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
edecca |
index a05aad056d..280bbdf35c 100644
|
|
|
edecca |
--- a/src/conf/domain_conf.c
|
|
|
edecca |
+++ b/src/conf/domain_conf.c
|
|
|
edecca |
@@ -6142,6 +6142,35 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def)
|
|
|
edecca |
}
|
|
|
edecca |
|
|
|
edecca |
|
|
|
edecca |
+static int
|
|
|
edecca |
+virDomainDefMemtuneValidate(const virDomainDef *def)
|
|
|
edecca |
+{
|
|
|
edecca |
+ const virDomainMemtune *mem = &(def->mem);
|
|
|
edecca |
+ size_t i;
|
|
|
edecca |
+ ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1;
|
|
|
edecca |
+
|
|
|
edecca |
+ for (i = 0; i < mem->nhugepages; i++) {
|
|
|
edecca |
+ ssize_t nextBit;
|
|
|
edecca |
+
|
|
|
edecca |
+ if (!mem->hugepages[i].nodemask) {
|
|
|
edecca |
+ /* This is the master hugepage to use. Skip it as it has no
|
|
|
edecca |
+ * nodemask anyway. */
|
|
|
edecca |
+ continue;
|
|
|
edecca |
+ }
|
|
|
edecca |
+
|
|
|
edecca |
+ nextBit = virBitmapNextSetBit(mem->hugepages[i].nodemask, pos);
|
|
|
edecca |
+ if (nextBit >= 0) {
|
|
|
edecca |
+ virReportError(VIR_ERR_XML_DETAIL,
|
|
|
edecca |
+ _("hugepages: node %zd not found"),
|
|
|
edecca |
+ nextBit);
|
|
|
edecca |
+ return -1;
|
|
|
edecca |
+ }
|
|
|
edecca |
+ }
|
|
|
edecca |
+
|
|
|
edecca |
+ return 0;
|
|
|
edecca |
+}
|
|
|
edecca |
+
|
|
|
edecca |
+
|
|
|
edecca |
static int
|
|
|
edecca |
virDomainDefValidateInternal(const virDomainDef *def)
|
|
|
edecca |
{
|
|
|
edecca |
@@ -6177,6 +6206,9 @@ virDomainDefValidateInternal(const virDomainDef *def)
|
|
|
edecca |
if (virDomainDefLifecycleActionValidate(def) < 0)
|
|
|
edecca |
return -1;
|
|
|
edecca |
|
|
|
edecca |
+ if (virDomainDefMemtuneValidate(def) < 0)
|
|
|
edecca |
+ return -1;
|
|
|
edecca |
+
|
|
|
edecca |
return 0;
|
|
|
edecca |
}
|
|
|
edecca |
|
|
|
edecca |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
edecca |
index 954265feb0..f2b64ed720 100644
|
|
|
edecca |
--- a/src/qemu/qemu_command.c
|
|
|
edecca |
+++ b/src/qemu/qemu_command.c
|
|
|
edecca |
@@ -7482,16 +7482,6 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
|
|
|
edecca |
if (!def->mem.nhugepages)
|
|
|
edecca |
return 0;
|
|
|
edecca |
|
|
|
edecca |
- if (def->mem.hugepages[0].nodemask) {
|
|
|
edecca |
- ssize_t next_bit = virBitmapNextSetBit(def->mem.hugepages[0].nodemask, -1);
|
|
|
edecca |
- if (next_bit >= 0) {
|
|
|
edecca |
- virReportError(VIR_ERR_XML_DETAIL,
|
|
|
edecca |
- _("hugepages: node %zd not found"),
|
|
|
edecca |
- next_bit);
|
|
|
edecca |
- return -1;
|
|
|
edecca |
- }
|
|
|
edecca |
- }
|
|
|
edecca |
-
|
|
|
edecca |
/* There is one special case: if user specified "huge"
|
|
|
edecca |
* pages of regular system pages size.
|
|
|
edecca |
* And there is nothing to do in this case.
|
|
|
edecca |
@@ -7624,30 +7614,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
|
|
edecca |
if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset))
|
|
|
edecca |
goto cleanup;
|
|
|
edecca |
|
|
|
edecca |
- for (i = 0; i < def->mem.nhugepages; i++) {
|
|
|
edecca |
- ssize_t next_bit, pos = 0;
|
|
|
edecca |
-
|
|
|
edecca |
- if (!def->mem.hugepages[i].nodemask) {
|
|
|
edecca |
- /* This is the master hugepage to use. Skip it as it has no
|
|
|
edecca |
- * nodemask anyway. */
|
|
|
edecca |
- continue;
|
|
|
edecca |
- }
|
|
|
edecca |
-
|
|
|
edecca |
- if (ncells) {
|
|
|
edecca |
- /* Fortunately, we allow only guest NUMA nodes to be continuous
|
|
|
edecca |
- * starting from zero. */
|
|
|
edecca |
- pos = ncells - 1;
|
|
|
edecca |
- }
|
|
|
edecca |
-
|
|
|
edecca |
- next_bit = virBitmapNextSetBit(def->mem.hugepages[i].nodemask, pos);
|
|
|
edecca |
- if (next_bit >= 0) {
|
|
|
edecca |
- virReportError(VIR_ERR_XML_DETAIL,
|
|
|
edecca |
- _("hugepages: node %zd not found"),
|
|
|
edecca |
- next_bit);
|
|
|
edecca |
- goto cleanup;
|
|
|
edecca |
- }
|
|
|
edecca |
- }
|
|
|
edecca |
-
|
|
|
edecca |
if (VIR_ALLOC_N(nodeBackends, ncells) < 0)
|
|
|
edecca |
goto cleanup;
|
|
|
edecca |
|
|
|
edecca |
diff --git a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
|
|
|
edecca |
index 47f253b5f7..e954250009 100644
|
|
|
edecca |
--- a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
|
|
|
edecca |
+++ b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
|
|
|
edecca |
@@ -5,7 +5,7 @@
|
|
|
edecca |
<currentMemory unit='KiB'>262144</currentMemory>
|
|
|
edecca |
<memoryBacking>
|
|
|
edecca |
<hugepages>
|
|
|
edecca |
- <page size='2048' unit='KiB' nodeset='0'/>
|
|
|
edecca |
+ <page size='2048' unit='KiB'/>
|
|
|
edecca |
</hugepages>
|
|
|
edecca |
</memoryBacking>
|
|
|
edecca |
<vcpu placement='static'>4</vcpu>
|
|
|
edecca |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
|
|
edecca |
index bd5fdf9412..f82bca2637 100644
|
|
|
edecca |
--- a/tests/qemuxml2argvtest.c
|
|
|
edecca |
+++ b/tests/qemuxml2argvtest.c
|
|
|
edecca |
@@ -959,12 +959,12 @@ mymain(void)
|
|
|
edecca |
DO_TEST("hugepages-default", NONE);
|
|
|
edecca |
DO_TEST("hugepages-default-2M", NONE);
|
|
|
edecca |
DO_TEST("hugepages-default-system-size", NONE);
|
|
|
edecca |
- DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
|
|
|
edecca |
- DO_TEST_FAILURE("hugepages-nodeset", NONE);
|
|
|
edecca |
- DO_TEST_FAILURE("hugepages-nodeset-nonexist",
|
|
|
edecca |
- QEMU_CAPS_DEVICE_PC_DIMM,
|
|
|
edecca |
- QEMU_CAPS_OBJECT_MEMORY_FILE,
|
|
|
edecca |
- QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
|
|
|
edecca |
+ DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE);
|
|
|
edecca |
+ DO_TEST_PARSE_ERROR("hugepages-nodeset", NONE);
|
|
|
edecca |
+ DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist",
|
|
|
edecca |
+ QEMU_CAPS_DEVICE_PC_DIMM,
|
|
|
edecca |
+ QEMU_CAPS_OBJECT_MEMORY_FILE,
|
|
|
edecca |
+ QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
|
|
|
edecca |
DO_TEST("hugepages-numa-default",
|
|
|
edecca |
QEMU_CAPS_OBJECT_MEMORY_FILE);
|
|
|
edecca |
DO_TEST("hugepages-numa-default-2M",
|
|
|
edecca |
@@ -979,9 +979,9 @@ mymain(void)
|
|
|
edecca |
DO_TEST("hugepages-numa-nodeset-part",
|
|
|
edecca |
QEMU_CAPS_OBJECT_MEMORY_RAM,
|
|
|
edecca |
QEMU_CAPS_OBJECT_MEMORY_FILE);
|
|
|
edecca |
- DO_TEST_FAILURE("hugepages-numa-nodeset-nonexist",
|
|
|
edecca |
- QEMU_CAPS_OBJECT_MEMORY_RAM,
|
|
|
edecca |
- QEMU_CAPS_OBJECT_MEMORY_FILE);
|
|
|
edecca |
+ DO_TEST_PARSE_ERROR("hugepages-numa-nodeset-nonexist",
|
|
|
edecca |
+ QEMU_CAPS_OBJECT_MEMORY_RAM,
|
|
|
edecca |
+ QEMU_CAPS_OBJECT_MEMORY_FILE);
|
|
|
edecca |
DO_TEST("hugepages-shared",
|
|
|
edecca |
QEMU_CAPS_OBJECT_MEMORY_RAM,
|
|
|
edecca |
QEMU_CAPS_OBJECT_MEMORY_FILE);
|
|
|
edecca |
diff --git a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml b/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
|
|
|
edecca |
deleted file mode 120000
|
|
|
edecca |
index 3d8eb7616e..0000000000
|
|
|
edecca |
--- a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
|
|
|
edecca |
+++ /dev/null
|
|
|
edecca |
@@ -1 +0,0 @@
|
|
|
edecca |
-../qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml
|
|
|
edecca |
\ No newline at end of file
|
|
|
edecca |
diff --git a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
|
|
|
edecca |
deleted file mode 120000
|
|
|
edecca |
index b55838b780..0000000000
|
|
|
edecca |
--- a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
|
|
|
edecca |
+++ /dev/null
|
|
|
edecca |
@@ -1 +0,0 @@
|
|
|
edecca |
-../qemuxml2argvdata/hugepages-nodeset.xml
|
|
|
edecca |
\ No newline at end of file
|
|
|
edecca |
diff --git a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
|
|
|
edecca |
deleted file mode 120000
|
|
|
edecca |
index d490edca69..0000000000
|
|
|
edecca |
--- a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
|
|
|
edecca |
+++ /dev/null
|
|
|
edecca |
@@ -1 +0,0 @@
|
|
|
edecca |
-../qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml
|
|
|
edecca |
\ No newline at end of file
|
|
|
edecca |
diff --git a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml b/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml
|
|
|
edecca |
index 050967b4ee..bfa66b8deb 100644
|
|
|
edecca |
--- a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml
|
|
|
edecca |
+++ b/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml
|
|
|
edecca |
@@ -5,7 +5,7 @@
|
|
|
edecca |
<currentMemory unit='KiB'>262144</currentMemory>
|
|
|
edecca |
<memoryBacking>
|
|
|
edecca |
<hugepages>
|
|
|
edecca |
- <page size='2048' unit='KiB' nodeset='0'/>
|
|
|
edecca |
+ <page size='2048' unit='KiB'/>
|
|
|
edecca |
</hugepages>
|
|
|
edecca |
</memoryBacking>
|
|
|
edecca |
<vcpu placement='static'>4</vcpu>
|
|
|
edecca |
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
|
|
|
edecca |
index acbe2f7133..aa543e9e51 100644
|
|
|
edecca |
--- a/tests/qemuxml2xmltest.c
|
|
|
edecca |
+++ b/tests/qemuxml2xmltest.c
|
|
|
edecca |
@@ -336,13 +336,10 @@ mymain(void)
|
|
|
edecca |
DO_TEST("hugepages-default", NONE);
|
|
|
edecca |
DO_TEST("hugepages-default-2M", NONE);
|
|
|
edecca |
DO_TEST("hugepages-default-system-size", NONE);
|
|
|
edecca |
- DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
|
|
|
edecca |
- DO_TEST("hugepages-nodeset", NONE);
|
|
|
edecca |
DO_TEST("hugepages-numa-default-2M", NONE);
|
|
|
edecca |
DO_TEST("hugepages-numa-default-dimm", NONE);
|
|
|
edecca |
DO_TEST("hugepages-numa-nodeset", NONE);
|
|
|
edecca |
DO_TEST("hugepages-numa-nodeset-part", NONE);
|
|
|
edecca |
- DO_TEST("hugepages-numa-nodeset-nonexist", NONE);
|
|
|
edecca |
DO_TEST("hugepages-shared", NONE);
|
|
|
edecca |
DO_TEST("hugepages-memaccess", NONE);
|
|
|
edecca |
DO_TEST("hugepages-memaccess2", NONE);
|
|
|
edecca |
--
|
|
|
edecca |
2.18.0
|
|
|
edecca |
|