From fa6bdf6afa878b8d7c5ed71664ee72be8967cdc5 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 18 May 2018 12:54:46 +0200 Subject: [PATCH] qemu: Deny hugepages for non-existent NUMA nodes https://bugzilla.redhat.com/show_bug.cgi?id=1534418 Just like ec982f6d929f3c23 denies hugepages for non-existent guest NUMA nodes in case there are some nodes configured. Unfortunately, when there are none, qemuBuildNumaArgStr() is not called and thus we have to have check in qemuBuildMemPathStr() too. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 10 +++++ tests/qemuxml2argvdata/hugepages-pages8.xml | 41 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ 3 files changed, 54 insertions(+) create mode 100644 tests/qemuxml2argvdata/hugepages-pages8.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9da2d609e8..56cf16dcd1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7270,6 +7270,16 @@ 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. diff --git a/tests/qemuxml2argvdata/hugepages-pages8.xml b/tests/qemuxml2argvdata/hugepages-pages8.xml new file mode 100644 index 0000000000..4cf4c1a8ad --- /dev/null +++ b/tests/qemuxml2argvdata/hugepages-pages8.xml @@ -0,0 +1,41 @@ + + SomeDummyHugepagesGuest + ef1bdff4-27f3-4e85-a807-5fb4d58463cc + 1048576 + 1048576 + + + + + + 2 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + +
+ + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 78454acb1a..19801953e5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -937,6 +937,9 @@ mymain(void) DO_TEST("hugepages-pages7", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); + DO_TEST_FAILURE("hugepages-pages8", + QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);