@@ -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);
@@ -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);
@@ -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
@@ -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' } }