]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Always check nodeset provided to numatune
authorAndrea Bolognani <abologna@redhat.com>
Tue, 3 Jan 2023 17:46:05 +0000 (18:46 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 9 Jan 2023 10:09:31 +0000 (11:09 +0100)
Up until commit 629282d88454, using mode=restrictive caused
virNumaSetupMemoryPolicy() to be called from qemuProcessHook(),
and that in turn resulted in virNumaNodesetIsAvailable() being
called and the nodeset being validated.

After that change, the only validation for the nodeset is the one
happening in qemuBuildMemoryBackendProps(), which is skipped when
using mode=restrictive.

Make sure virNumaNodesetIsAvailable() is called whenever a
nodeset has been provided by the user, regardless of the mode.

https://bugzilla.redhat.com/show_bug.cgi?id=2156289

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/numatune-memnode-unavailable-restrictive.x86_64-latest.args [deleted file]
tests/qemuxml2argvdata/numatune-memnode-unavailable-restrictive.x86_64-latest.err [new file with mode: 0644]
tests/qemuxml2argvtest.c

index cd3222feacec7342d654934bb757ef8ef7628081..1f886580856e38af98d7fc09543247f24ed07741 100644 (file)
@@ -3428,12 +3428,14 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
             return -1;
     }
 
+    /* Make sure the requested nodeset is sensible */
+    if (nodemask && !virNumaNodesetIsAvailable(nodemask))
+        return -1;
+
     /* If mode is "restrictive", we should only use cgroups setting allowed memory
      * nodes, and skip passing the host-nodes and policy parameters to QEMU command
      * line which means we will use system default memory policy. */
     if (nodemask && mode != VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) {
-        if (!virNumaNodesetIsAvailable(nodemask))
-            return -1;
         if (virJSONValueObjectAdd(&props,
                                   "m:host-nodes", nodemask,
                                   "S:policy", qemuNumaPolicyTypeToString(mode),
diff --git a/tests/qemuxml2argvdata/numatune-memnode-unavailable-restrictive.x86_64-latest.args b/tests/qemuxml2argvdata/numatune-memnode-unavailable-restrictive.x86_64-latest.args
deleted file mode 100644 (file)
index b257ef1..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-LC_ALL=C \
-PATH=/bin \
-HOME=/tmp/lib/domain--1-QEMUGuest \
-USER=test \
-LOGNAME=test \
-XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest/.local/share \
-XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest/.cache \
-XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest/.config \
-/usr/bin/qemu-system-x86_64 \
--name guest=QEMUGuest,debug-threads=on \
--S \
--object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest/master-key.aes"}' \
--machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \
--accel tcg \
--cpu qemu64 \
--m 24104 \
--object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":25274875904}' \
--overcommit mem-lock=off \
--smp 32,sockets=32,cores=1,threads=1 \
--uuid 9f4b6512-e73a-4a25-93e8-5307802821ce \
--display none \
--no-user-config \
--nodefaults \
--chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
--mon chardev=charmonitor,id=monitor,mode=control \
--rtc base=utc \
--no-shutdown \
--no-acpi \
--boot strict=on \
--audiodev '{"id":"audio1","driver":"none"}' \
--sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
--msg timestamp=on
diff --git a/tests/qemuxml2argvdata/numatune-memnode-unavailable-restrictive.x86_64-latest.err b/tests/qemuxml2argvdata/numatune-memnode-unavailable-restrictive.x86_64-latest.err
new file mode 100644 (file)
index 0000000..a826c3c
--- /dev/null
@@ -0,0 +1 @@
+internal error: Mock: no numa node set is available at bit 999
index 8130e1231466b55dbd8c56016cb82d903c7daabc..44ad0f70494a18926fd73d50bd0204d894907e0e 100644 (file)
@@ -1982,7 +1982,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR_NOCAPS("numatune-memnode-nocpu");
     DO_TEST_PARSE_ERROR_NOCAPS("numatune-memnodes-problematic");
     DO_TEST_CAPS_LATEST_FAILURE("numatune-memnode-unavailable-strict");
-    DO_TEST_CAPS_LATEST("numatune-memnode-unavailable-restrictive");
+    DO_TEST_CAPS_LATEST_FAILURE("numatune-memnode-unavailable-restrictive");
     DO_TEST_NOCAPS("numad");
     DO_TEST_NOCAPS("numad-auto-vcpu-static-numatune");
     DO_TEST_PARSE_ERROR_NOCAPS("numad-auto-vcpu-static-numatune-no-nodeset");