render / rpms / libvirt

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