From: Michal Privoznik Date: Mon, 15 Sep 2014 09:59:09 +0000 (+0200) Subject: conf: Disallow nonexistent NUMA nodes for hugepages X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ec982f6d929f3c2343d4ea9b06e49c23e6c526ba;p=libvirt.git conf: Disallow nonexistent NUMA nodes for hugepages As of 136ad4974 it is possible to specify different huge pages per guest NUMA node. However, there's no check if nodeset specified in ./hugepages/page contains only those guest NUMA nodes that exist. In other words with current code it is possible to define meaningless combination: 4 Notice the node 4 in ? Signed-off-by: Michal Privoznik --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a892d99b30..1c2feebdcf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6550,6 +6550,30 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, 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 (def->cpu && def->cpu->ncells) { + /* Fortunately, we allow only guest NUMA nodes to be continuous + * starting from zero. */ + pos = def->cpu->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; + } + } + for (i = 0; i < def->cpu->ncells; i++) { int cellmem = VIR_DIV_UP(def->cpu->cells[i].mem, 1024); def->cpu->cells[i].mem = cellmem * 1024; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml new file mode 100644 index 0000000000..a3ed29bca4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml @@ -0,0 +1,45 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 4194304 + 4194304 + + + + + + + 4 + + + + + + hvm + + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 246f6487bd..c8a6c2e507 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -686,6 +686,8 @@ mymain(void) QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-shared", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST_FAILURE("hugepages-pages4", QEMU_CAPS_MEM_PATH, + QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE); DO_TEST("disk-cdrom", NONE); DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,