[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 51/52] qapi: Expose CPU topology info in query_cpus_fast
From: |
Zhao Liu |
Subject: |
[RFC 51/52] qapi: Expose CPU topology info in query_cpus_fast |
Date: |
Mon, 13 Feb 2023 17:50:34 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
The topology type and core type are useful to users, so expose them
in query_cpus_fast.
Since the hybrid core is pre-set and does not support hotplug for
the entire core, the topology type and core type are not exposed in
query-hotpluggable-cpus.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/core/machine-qmp-cmds.c | 11 +++++++++++
hw/core/machine-topo.c | 5 +++++
include/hw/boards.h | 5 +++++
qapi/machine.json | 19 +++++++++++++++++--
4 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 44b5da888024..6be7148a8374 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -67,6 +67,17 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
value->props = props;
}
+ if (mc->cpu_index_to_core_type) {
+ CpuTopoInfo *topo;
+ const char *core_type;
+
+ topo = g_malloc0(sizeof(CpuTopoInfo));
+ topo->topo_type = machine_topo_get_type(ms);
+ core_type = mc->cpu_index_to_core_type(ms, cpu->cpu_index);
+ topo->core_type = g_strdup(core_type);
+ value->topo = topo;
+ }
+
value->target = target;
if (target == SYS_EMU_TARGET_S390X) {
cpustate_to_cpuinfo_s390(&value->u.s390x, cpu);
diff --git a/hw/core/machine-topo.c b/hw/core/machine-topo.c
index f38b8c683026..f0ff550a2519 100644
--- a/hw/core/machine-topo.c
+++ b/hw/core/machine-topo.c
@@ -177,6 +177,11 @@ unsigned int machine_topo_get_threads_per_socket(const
MachineState *ms)
return ms->topo.max_cpus / sockets;
}
+CpuTopoType machine_topo_get_type(const MachineState *ms)
+{
+ return ms->topo.topo_type;
+}
+
void machine_init_topology_default(MachineState *ms, bool smp)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
diff --git a/include/hw/boards.h b/include/hw/boards.h
index c93bb1206244..d925e8af9ed6 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -239,6 +239,8 @@ typedef struct {
* purposes only.
* Applies only to default memory backend, i.e., explicit memory backend
* wasn't used.
+ * @cpu_index_to_core_type:
+ * Return the core_type of specified CPU with @cpu_index.
*/
struct MachineClass {
/*< private >*/
@@ -305,6 +307,8 @@ struct MachineClass {
const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx);
ram_addr_t (*fixup_ram_size)(ram_addr_t size);
+ const char *(*cpu_index_to_core_type)(MachineState *machine,
+ unsigned cpu_index);
};
/**
@@ -496,5 +500,6 @@ unsigned int machine_topo_get_cores_by_idx(const
MachineState *ms,
unsigned int cpu_index);
unsigned int machine_topo_get_cores_per_socket(const MachineState *ms);
unsigned int machine_topo_get_threads_per_socket(const MachineState *ms);
+CpuTopoType machine_topo_get_type(const MachineState *ms);
#endif
diff --git a/qapi/machine.json b/qapi/machine.json
index 931c6dea9819..e86778b7a777 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -40,7 +40,6 @@
# @CpuTopoType:
#
# An enumeration of cpu topology type
-# TODO: Expose topology type in query-cpus-fast
#
# Since: 8.0
##
@@ -48,6 +47,21 @@
'prefix': 'CPU_TOPO_TYPE',
'data': [ 'smp', 'hybrid' ] }
+##
+# @CpuTopoInfo:
+#
+# Additional information about basic CPU topology
+#
+# @topo-type: the type of CPU topology
+#
+# @core-type: the type of CPU core
+#
+# Since: 8.0
+##
+{ 'struct' : 'CpuTopoInfo',
+ 'data' : { 'topo-type': 'CpuTopoType',
+ 'core-type': 'str'} }
+
##
# @CpuS390State:
#
@@ -95,7 +109,8 @@
'qom-path' : 'str',
'thread-id' : 'int',
'*props' : 'CpuInstanceProperties',
- 'target' : 'SysEmuTarget' },
+ 'target' : 'SysEmuTarget',
+ '*topo' : 'CpuTopoInfo' },
'discriminator' : 'target',
'data' : { 's390x' : 'CpuInfoS390' } }
--
2.34.1
- [RFC 40/52] qapi: Introduce hybrid options, (continued)
- [RFC 40/52] qapi: Introduce hybrid options, Zhao Liu, 2023/02/13
- [RFC 39/52] i386/cpu: Add Intel hybrid related CPUID support, Zhao Liu, 2023/02/13
- [RFC 43/52] hw/machine: Rename MachineClass.smp_props to MachineClass.topo_props, Zhao Liu, 2023/02/13
- [RFC 44/52] machine: Add "-hybrid" parsing rule, Zhao Liu, 2023/02/13
- [RFC 45/52] hw/machine: Add hybrid cpu topology validation, Zhao Liu, 2023/02/13
- [RFC 47/52] hw/machine: Use opts_visitor to parse hybrid topo, Zhao Liu, 2023/02/13
- [RFC 46/52] hw/machine: build core level hybrid topology form HybridCorePack, Zhao Liu, 2023/02/13
- [RFC 48/52] machine: Support "-hybrid" command, Zhao Liu, 2023/02/13
- [RFC 49/52] i386/pc: Support hybrid cpu topology, Zhao Liu, 2023/02/13
- [RFC 50/52] qemu-options: Add the document of hybrid command, Zhao Liu, 2023/02/13
- [RFC 51/52] qapi: Expose CPU topology info in query_cpus_fast,
Zhao Liu <=
- [RFC 52/52] i386: Support cpu_index_to_core_type() for x86, Zhao Liu, 2023/02/13
- Re: [RFC 00/52] Introduce hybrid CPU topology, Alex Bennée, 2023/02/13
- Re: [RFC 00/52] Introduce hybrid CPU topology, Daniel P . Berrangé, 2023/02/13