]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuBuildMemoryBackendStr: Report backend requirement more appropriately
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 12 Feb 2015 16:43:27 +0000 (17:43 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Feb 2015 08:07:09 +0000 (09:07 +0100)
So, when building the '-numa' command line, the
qemuBuildMemoryBackendStr() function does quite a lot of checks to
chose the best backend, or to check if one is in fact needed. However,
it returned that backend is needed even for this little fella:

  <numatune>
    <memory mode="strict" nodeset="0,2"/>
  </numatune>

This can be guaranteed via CGroups entirely, there's no need to use
memory-backend-ram to let qemu know where to get memory from. Well, as
long as there's no <memnode/> element, which explicitly requires the
backend. Long story short, we wouldn't have to care, as qemu works
either way. However, the problem is migration (as always). Previously,
libvirt would have started qemu with:

  -numa node,memory=X

in this case and restricted memory placement in CGroups. Today, libvirt
creates more complicated command line:

  -object memory-backend-ram,id=ram-node0,size=X
  -numa node,memdev=ram-node0

Again, one wouldn't find anything wrong with these two approaches.
Both work just fine. Unless you try to migrated from the older libvirt
into the newer one. These two approaches are, unfortunately, not
compatible. My suggestion is, in order to allow users to migrate, lets
use the older approach for as long as the newer one is not needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-cputune-numatune.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.args [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 084530f9a786617e91039e223c3b7c67d4268ea4..8e864abd5e026f94ce18f35701f43ee5f70a3882 100644 (file)
@@ -4699,7 +4699,9 @@ qemuBuildMemoryBackendStr(unsigned long long size,
     props = NULL;
 
     if (!hugepage) {
-        if ((nodemask || force) &&
+        bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numatune, guestNode);
+
+        if ((userNodeset || nodeSpecified || force) &&
             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("this qemu doesn't support the "
@@ -4709,7 +4711,7 @@ qemuBuildMemoryBackendStr(unsigned long long size,
 
         /* report back that using the new backend is not necessary to achieve
          * the desired configuration */
-        if (!nodemask) {
+        if (!userNodeset && !nodeSpecified) {
             ret = 1;
             goto cleanup;
         }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-numatune.args b/tests/qemuxml2argvdata/qemuxml2argv-cputune-numatune.args
new file mode 100644 (file)
index 0000000..481f72f
--- /dev/null
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 -S -M pc-q35-2.3 -m 128 \
+-smp 2,maxcpus=6,sockets=6,cores=1,threads=1 \
+-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi \
+-boot c -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.args b/tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.args
new file mode 100644 (file)
index 0000000..0b1b0f5
--- /dev/null
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/kvm -S -M pc -m 64 -smp 1 \
+-numa node,nodeid=0,cpus=0,mem=64 \
+-nographic -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -boot c -usb -net none -serial none -parallel none
index 2de92ebfc35ff42fd876a2b2d35312ababde717d..39ed66b2e48edadc74f29f884bf0d94af0ca941f 100644 (file)
@@ -1260,6 +1260,10 @@ mymain(void)
     DO_TEST("cputune-zero-shares", QEMU_CAPS_NAME);
     DO_TEST_PARSE_ERROR("cputune-iothreadsched-toomuch", QEMU_CAPS_NAME);
     DO_TEST_PARSE_ERROR("cputune-vcpusched-overlap", QEMU_CAPS_NAME);
+    DO_TEST("cputune-numatune", QEMU_CAPS_SMP_TOPOLOGY,
+            QEMU_CAPS_KVM,
+            QEMU_CAPS_OBJECT_MEMORY_RAM,
+            QEMU_CAPS_OBJECT_MEMORY_FILE);
 
     DO_TEST("numatune-memory", NONE);
     DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
@@ -1272,6 +1276,8 @@ mymain(void)
     DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);
 
     DO_TEST("numatune-auto-nodeset-invalid", NONE);
+    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
+            QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                     QEMU_CAPS_OBJECT_MEMORY_RAM);
     DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);