c313de
From 607f70a5d24d2df9c63861434c4ba1991226ee34 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <607f70a5d24d2df9c63861434c4ba1991226ee34@dist-git>
c313de
From: Andrea Bolognani <abologna@redhat.com>
c313de
Date: Tue, 11 Jun 2019 10:55:03 +0200
c313de
Subject: [PATCH] qemu: Fix qemuProcessInitCpuAffinity()
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
Ever since the feature was introduced with commit 0f8e7ae33ace,
c313de
it has contained a logic error in that it attempted to use a NUMA
c313de
node map where a CPU map was expected.
c313de
c313de
Because of that, guests using <numatune> might fail to start:
c313de
c313de
  # virsh start guest
c313de
  error: Failed to start domain guest
c313de
  error: cannot set CPU affinity on process 40055: Invalid argument
c313de
c313de
This was particularly easy to trigger on POWER 8 machines, where
c313de
secondary threads always show up as offline in the host: having
c313de
c313de
  <numatune>
c313de
    <memory mode='strict' placement='static' nodeset='1'/>
c313de
  </numatune>
c313de
c313de
in the guest configuration, for example, would result in libvirt
c313de
trying to set the process affinity so that it would prefer
c313de
running on CPU 1, but since that's a secondary thread and thus
c313de
shows up as offline, the operation would fail, and so would
c313de
starting the guest.
c313de
c313de
Use the newly introduced virNumaNodesetToCPUset() to convert the
c313de
NUMA node map to a CPU map, which in the example above would be
c313de
48,56,64,72,80,88 - a valid input for virProcessSetAffinity().
c313de
c313de
https://bugzilla.redhat.com/show_bug.cgi?id=1703661
c313de
c313de
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
(cherry picked from commit 5f2212c062c720716b7701fa0a5511311dc6e906)
c313de
c313de
https://bugzilla.redhat.com/show_bug.cgi?id=1716908
c313de
c313de
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
c313de
Message-Id: <20190611085506.12564-4-abologna@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/qemu/qemu_process.c | 7 ++++++-
c313de
 1 file changed, 6 insertions(+), 1 deletion(-)
c313de
c313de
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
c313de
index 8b05cef80c..a3b71354e1 100644
c313de
--- a/src/qemu/qemu_process.c
c313de
+++ b/src/qemu/qemu_process.c
c313de
@@ -2382,11 +2382,16 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
c313de
     if (virDomainNumaGetNodeCount(vm->def->numa) <= 1 &&
c313de
         virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 &&
c313de
         mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
c313de
+        virBitmapPtr nodeset = NULL;
c313de
+
c313de
         if (virDomainNumatuneMaybeGetNodeset(vm->def->numa,
c313de
                                              priv->autoNodeset,
c313de
-                                             &cpumapToSet,
c313de
+                                             &nodeset,
c313de
                                              -1) < 0)
c313de
             goto cleanup;
c313de
+
c313de
+        if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0)
c313de
+            goto cleanup;
c313de
     } else if (vm->def->cputune.emulatorpin) {
c313de
         cpumapToSet = vm->def->cputune.emulatorpin;
c313de
     } else {
c313de
-- 
c313de
2.22.0
c313de