diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8fd774b531..be9c08626a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6184,6 +6184,35 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def) } +static int +virDomainDefMemtuneValidate(const virDomainDef *def) +{ + const virDomainMemtune *mem = &(def->mem); + size_t i; + ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1; + + for (i = 0; i < mem->nhugepages; i++) { + ssize_t nextBit; + + if (!mem->hugepages[i].nodemask) { + /* This is the master hugepage to use. Skip it as it has no + * nodemask anyway. */ + continue; + } + + nextBit = virBitmapNextSetBit(mem->hugepages[i].nodemask, pos); + if (nextBit >= 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("hugepages: node %zd not found"), + nextBit); + return -1; + } + } + + return 0; +} + + static int virDomainDefValidateInternal(const virDomainDef *def) { @@ -6219,6 +6248,9 @@ virDomainDefValidateInternal(const virDomainDef *def) if (virDomainDefLifecycleActionValidate(def) < 0) return -1; + if (virDomainDefMemtuneValidate(def) < 0) + return -1; + return 0; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 12ff09d46d..a3fadc505d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7433,16 +7433,6 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, if (!def->mem.nhugepages) return 0; - if (def->mem.hugepages[0].nodemask) { - ssize_t next_bit = virBitmapNextSetBit(def->mem.hugepages[0].nodemask, -1); - if (next_bit >= 0) { - virReportError(VIR_ERR_XML_DETAIL, - _("hugepages: node %zd not found"), - next_bit); - return -1; - } - } - /* There is one special case: if user specified "huge" * pages of regular system pages size. * And there is nothing to do in this case. @@ -7575,30 +7565,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset)) goto cleanup; - for (i = 0; i < def->mem.nhugepages; i++) { - ssize_t next_bit, pos = 0; - - if (!def->mem.hugepages[i].nodemask) { - /* This is the master hugepage to use. Skip it as it has no - * nodemask anyway. */ - continue; - } - - if (ncells) { - /* Fortunately, we allow only guest NUMA nodes to be continuous - * starting from zero. */ - pos = ncells - 1; - } - - next_bit = virBitmapNextSetBit(def->mem.hugepages[i].nodemask, pos); - if (next_bit >= 0) { - virReportError(VIR_ERR_XML_DETAIL, - _("hugepages: node %zd not found"), - next_bit); - goto cleanup; - } - } - if (VIR_ALLOC_N(nodeBackends, ncells) < 0) goto cleanup; diff --git a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml index 47f253b5f7..e954250009 100644 --- a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml +++ b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml @@ -5,7 +5,7 @@ 262144 - + 4 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7721827f40..8d883efafd 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -958,12 +958,12 @@ mymain(void) DO_TEST("hugepages-default", NONE); DO_TEST("hugepages-default-2M", NONE); DO_TEST("hugepages-default-system-size", NONE); - DO_TEST("hugepages-default-1G-nodeset-2M", NONE); - DO_TEST_FAILURE("hugepages-nodeset", NONE); - DO_TEST_FAILURE("hugepages-nodeset-nonexist", - QEMU_CAPS_DEVICE_PC_DIMM, - QEMU_CAPS_OBJECT_MEMORY_FILE, - QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); + DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE); + DO_TEST_PARSE_ERROR("hugepages-nodeset", NONE); + DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist", + QEMU_CAPS_DEVICE_PC_DIMM, + QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); DO_TEST("hugepages-numa-default", QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-numa-default-2M", @@ -978,9 +978,9 @@ mymain(void) DO_TEST("hugepages-numa-nodeset-part", QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); - DO_TEST_FAILURE("hugepages-numa-nodeset-nonexist", - QEMU_CAPS_OBJECT_MEMORY_RAM, - QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST_PARSE_ERROR("hugepages-numa-nodeset-nonexist", + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-shared", QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); diff --git a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml b/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml deleted file mode 120000 index 3d8eb7616e..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml +++ /dev/null @@ -1 +0,0 @@ -../qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml deleted file mode 120000 index b55838b780..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml +++ /dev/null @@ -1 +0,0 @@ -../qemuxml2argvdata/hugepages-nodeset.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml deleted file mode 120000 index d490edca69..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml +++ /dev/null @@ -1 +0,0 @@ -../qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml b/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml index 050967b4ee..bfa66b8deb 100644 --- a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml +++ b/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml @@ -5,7 +5,7 @@ 262144 - + 4 diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 7c4a649a6e..d5f6db5504 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -331,13 +331,10 @@ mymain(void) DO_TEST("hugepages-default", NONE); DO_TEST("hugepages-default-2M", NONE); DO_TEST("hugepages-default-system-size", NONE); - DO_TEST("hugepages-default-1G-nodeset-2M", NONE); - DO_TEST("hugepages-nodeset", NONE); DO_TEST("hugepages-numa-default-2M", NONE); DO_TEST("hugepages-numa-default-dimm", NONE); DO_TEST("hugepages-numa-nodeset", NONE); DO_TEST("hugepages-numa-nodeset-part", NONE); - DO_TEST("hugepages-numa-nodeset-nonexist", NONE); DO_TEST("hugepages-shared", NONE); DO_TEST("hugepages-memaccess", NONE); DO_TEST("hugepages-memaccess2", NONE);