render / rpms / libvirt

Forked from rpms/libvirt 7 months ago
Clone
b971b8
From d97b868a9517173a7f805fd3232b3d9fdc2bad89 Mon Sep 17 00:00:00 2001
b971b8
Message-Id: <d97b868a9517173a7f805fd3232b3d9fdc2bad89@dist-git>
b971b8
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
b971b8
Date: Tue, 5 May 2020 16:49:12 +0100
b971b8
Subject: [PATCH] qemu: fix detection of vCPU pids when multiple dies are
b971b8
 present
b971b8
MIME-Version: 1.0
b971b8
Content-Type: text/plain; charset=UTF-8
b971b8
Content-Transfer-Encoding: 8bit
b971b8
b971b8
The logic for querying hotpluggable CPUs needs to sort the list
b971b8
of CPUs returned by QEMU. Unfortunately our sorting method failed
b971b8
to use the die_id field, so CPUs were not correctly sorted.
b971b8
b971b8
This is seen when configuring a guest with partially populated
b971b8
CPUs
b971b8
b971b8
  <vcpu placement='static' current='1'>16</vcpu>
b971b8
  <cpu...>
b971b8
    <topology sockets='4' dies='2' cores='1' threads='2'/>
b971b8
  </cpu>
b971b8
b971b8
Then trying to start it would fail:
b971b8
b971b8
  # virsh -c qemu:///system start demo
b971b8
  error: Failed to start domain demo
b971b8
  error: internal error: qemu didn't report thread id for vcpu '0'
b971b8
b971b8
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
b971b8
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
b971b8
(cherry picked from commit 8b789c6574454863acbd2511fc2094d1e63e8154)
b971b8
b971b8
https://bugzilla.redhat.com/show_bug.cgi?id=1813395
b971b8
https://bugzilla.redhat.com/show_bug.cgi?id=1821592
b971b8
b971b8
Message-Id: <20200505154912.950468-2-berrange@redhat.com>
b971b8
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
b971b8
---
b971b8
 src/qemu/qemu_domain.c       | 10 ++++++++--
b971b8
 src/qemu/qemu_monitor.c      |  2 ++
b971b8
 src/qemu/qemu_monitor.h      |  2 ++
b971b8
 src/qemu/qemu_monitor_json.c |  5 +++++
b971b8
 4 files changed, 17 insertions(+), 2 deletions(-)
b971b8
b971b8
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
b971b8
index 1509e41021..cdf7b3e692 100644
b971b8
--- a/src/qemu/qemu_domain.c
b971b8
+++ b/src/qemu/qemu_domain.c
b971b8
@@ -13812,8 +13812,14 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
b971b8
         }
b971b8
 
b971b8
         if (validTIDs)
b971b8
-            VIR_DEBUG("vCPU[%zu] PID %llu is valid",
b971b8
-                      i, (unsigned long long)info[i].tid);
b971b8
+            VIR_DEBUG("vCPU[%zu] PID %llu is valid "
b971b8
+                      "(node=%d socket=%d die=%d core=%d thread=%d)",
b971b8
+                      i, (unsigned long long)info[i].tid,
b971b8
+                      info[i].node_id,
b971b8
+                      info[i].socket_id,
b971b8
+                      info[i].die_id,
b971b8
+                      info[i].core_id,
b971b8
+                      info[i].thread_id);
b971b8
     }
b971b8
 
b971b8
     VIR_DEBUG("Extracting vCPU information validTIDs=%d", validTIDs);
b971b8
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
b971b8
index 5915035589..d8911066ab 100644
b971b8
--- a/src/qemu/qemu_monitor.c
b971b8
+++ b/src/qemu/qemu_monitor.c
b971b8
@@ -1667,6 +1667,7 @@ qemuMonitorCPUInfoClear(qemuMonitorCPUInfoPtr cpus,
b971b8
         cpus[i].id = 0;
b971b8
         cpus[i].qemu_id = -1;
b971b8
         cpus[i].socket_id = -1;
b971b8
+        cpus[i].die_id = -1;
b971b8
         cpus[i].core_id = -1;
b971b8
         cpus[i].thread_id = -1;
b971b8
         cpus[i].node_id = -1;
b971b8
@@ -1822,6 +1823,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
b971b8
         vcpus[mastervcpu].hotpluggable = !!hotplugvcpus[i].alias ||
b971b8
                                          !vcpus[mastervcpu].online;
b971b8
         vcpus[mastervcpu].socket_id = hotplugvcpus[i].socket_id;
b971b8
+        vcpus[mastervcpu].die_id = hotplugvcpus[i].die_id;
b971b8
         vcpus[mastervcpu].core_id = hotplugvcpus[i].core_id;
b971b8
         vcpus[mastervcpu].thread_id = hotplugvcpus[i].thread_id;
b971b8
         vcpus[mastervcpu].node_id = hotplugvcpus[i].node_id;
b971b8
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
b971b8
index ca975d084c..6e83f250ed 100644
b971b8
--- a/src/qemu/qemu_monitor.h
b971b8
+++ b/src/qemu/qemu_monitor.h
b971b8
@@ -567,6 +567,7 @@ struct qemuMonitorQueryHotpluggableCpusEntry {
b971b8
     /* topology information -1 if qemu didn't report given parameter */
b971b8
     int node_id;
b971b8
     int socket_id;
b971b8
+    int die_id;
b971b8
     int core_id;
b971b8
     int thread_id;
b971b8
 
b971b8
@@ -589,6 +590,7 @@ struct _qemuMonitorCPUInfo {
b971b8
     /* topology info for hotplug purposes. Hotplug of given vcpu impossible if
b971b8
      * all entries are -1 */
b971b8
     int socket_id;
b971b8
+    int die_id;
b971b8
     int core_id;
b971b8
     int thread_id;
b971b8
     int node_id;
b971b8
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
b971b8
index 92d7317a82..d445a4904f 100644
b971b8
--- a/src/qemu/qemu_monitor_json.c
b971b8
+++ b/src/qemu/qemu_monitor_json.c
b971b8
@@ -8576,11 +8576,13 @@ qemuMonitorJSONProcessHotpluggableCpusReply(virJSONValuePtr vcpu,
b971b8
 
b971b8
     entry->node_id = -1;
b971b8
     entry->socket_id = -1;
b971b8
+    entry->die_id = -1;
b971b8
     entry->core_id = -1;
b971b8
     entry->thread_id = -1;
b971b8
 
b971b8
     ignore_value(virJSONValueObjectGetNumberInt(props, "node-id", &entry->node_id));
b971b8
     ignore_value(virJSONValueObjectGetNumberInt(props, "socket-id", &entry->socket_id));
b971b8
+    ignore_value(virJSONValueObjectGetNumberInt(props, "die-id", &entry->die_id));
b971b8
     ignore_value(virJSONValueObjectGetNumberInt(props, "core-id", &entry->core_id));
b971b8
     ignore_value(virJSONValueObjectGetNumberInt(props, "thread-id", &entry->thread_id));
b971b8
 
b971b8
@@ -8615,6 +8617,9 @@ qemuMonitorQueryHotpluggableCpusEntrySort(const void *p1,
b971b8
     if (a->socket_id != b->socket_id)
b971b8
         return a->socket_id - b->socket_id;
b971b8
 
b971b8
+    if (a->die_id != b->die_id)
b971b8
+        return a->die_id - b->die_id;
b971b8
+
b971b8
     if (a->core_id != b->core_id)
b971b8
         return a->core_id - b->core_id;
b971b8
 
b971b8
-- 
b971b8
2.26.2
b971b8