]> xenbits.xensource.com Git - people/aperard/libvirt.git/commitdiff
qemu: Make monitor aware of CPU clusters
authorAndrea Bolognani <abologna@redhat.com>
Fri, 5 Jan 2024 17:51:29 +0000 (18:51 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 15 Jan 2024 13:56:36 +0000 (14:56 +0100)
This makes it so libvirt can obtain accurate information about
guest CPUs from QEMU, and should make it possible to correctly
perform operations such as CPU hotplug.

Of course this is mostly moot at the moment: only aarch64 can use
CPU clusters, and CPU hotplug is not yet implemented on that
architecture.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c

index 3a00fb689e169f6236f61b5a95bcbb6d2bffde55..e2a1bf2c1304226a27aeaef05be678bf6ce42c28 100644 (file)
@@ -9900,11 +9900,12 @@ qemuDomainRefreshVcpuInfo(virDomainObj *vm,
 
         if (validTIDs)
             VIR_DEBUG("vCPU[%zu] PID %llu is valid "
-                      "(node=%d socket=%d die=%d core=%d thread=%d)",
+                      "(node=%d socket=%d die=%d cluster=%d core=%d thread=%d)",
                       i, (unsigned long long)info[i].tid,
                       info[i].node_id,
                       info[i].socket_id,
                       info[i].die_id,
+                      info[i].cluster_id,
                       info[i].core_id,
                       info[i].thread_id);
     }
index dfad4ee1ea32dcd8eedd64fae86fe950771e6879..a1773d86d410a4681f5f55ae7d37d61de65f6f71 100644 (file)
@@ -1501,6 +1501,7 @@ qemuMonitorCPUInfoClear(qemuMonitorCPUInfo *cpus,
         cpus[i].qemu_id = -1;
         cpus[i].socket_id = -1;
         cpus[i].die_id = -1;
+        cpus[i].cluster_id = -1;
         cpus[i].core_id = -1;
         cpus[i].thread_id = -1;
         cpus[i].node_id = -1;
@@ -1658,6 +1659,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
                                          !vcpus[mainvcpu].online;
         vcpus[mainvcpu].socket_id = hotplugvcpus[i].socket_id;
         vcpus[mainvcpu].die_id = hotplugvcpus[i].die_id;
+        vcpus[mainvcpu].cluster_id = hotplugvcpus[i].cluster_id;
         vcpus[mainvcpu].core_id = hotplugvcpus[i].core_id;
         vcpus[mainvcpu].thread_id = hotplugvcpus[i].thread_id;
         vcpus[mainvcpu].node_id = hotplugvcpus[i].node_id;
index c4af9b407d2d57aaa3ea0d9674d0c32193b07612..981c609e9f404070dd4eb5758fc0930981740b77 100644 (file)
@@ -590,6 +590,7 @@ struct qemuMonitorQueryHotpluggableCpusEntry {
     int node_id;
     int socket_id;
     int die_id;
+    int cluster_id;
     int core_id;
     int thread_id;
 
@@ -613,6 +614,7 @@ struct _qemuMonitorCPUInfo {
      * all entries are -1 */
     int socket_id;
     int die_id;
+    int cluster_id;
     int core_id;
     int thread_id;
     int node_id;
index 9cb0f3d1d82070eade7a4d87885d15c6e9da00d5..e114b6bfb1d5cc653e602bdc03d63fb05e9de0f0 100644 (file)
@@ -7579,12 +7579,14 @@ qemuMonitorJSONProcessHotpluggableCpusReply(virJSONValue *vcpu,
     entry->node_id = -1;
     entry->socket_id = -1;
     entry->die_id = -1;
+    entry->cluster_id = -1;
     entry->core_id = -1;
     entry->thread_id = -1;
 
     ignore_value(virJSONValueObjectGetNumberInt(props, "node-id", &entry->node_id));
     ignore_value(virJSONValueObjectGetNumberInt(props, "socket-id", &entry->socket_id));
     ignore_value(virJSONValueObjectGetNumberInt(props, "die-id", &entry->die_id));
+    ignore_value(virJSONValueObjectGetNumberInt(props, "cluster-id", &entry->cluster_id));
     ignore_value(virJSONValueObjectGetNumberInt(props, "core-id", &entry->core_id));
     ignore_value(virJSONValueObjectGetNumberInt(props, "thread-id", &entry->thread_id));
 
@@ -7622,6 +7624,9 @@ qemuMonitorQueryHotpluggableCpusEntrySort(const void *p1,
     if (a->die_id != b->die_id)
         return a->die_id - b->die_id;
 
+    if (a->cluster_id != b->cluster_id)
+        return a->cluster_id - b->cluster_id;
+
     if (a->core_id != b->core_id)
         return a->core_id - b->core_id;