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