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