@@ -31,18 +31,18 @@ static char *cpu_hierarchy_to_string(MachineState *ms)
MachineClass *mc = MACHINE_GET_CLASS(ms);
GString *s = g_string_new(NULL);
- g_string_append_printf(s, "sockets (%u)", ms->smp.sockets);
+ g_string_append_printf(s, "sockets (%u)", ms->topo.smp.sockets);
if (mc->smp_props.dies_supported) {
- g_string_append_printf(s, " * dies (%u)", ms->smp.dies);
+ g_string_append_printf(s, " * dies (%u)", ms->topo.smp.dies);
}
if (mc->smp_props.clusters_supported) {
- g_string_append_printf(s, " * clusters (%u)", ms->smp.clusters);
+ g_string_append_printf(s, " * clusters (%u)", ms->topo.smp.clusters);
}
- g_string_append_printf(s, " * cores (%u)", ms->smp.cores);
- g_string_append_printf(s, " * threads (%u)", ms->smp.threads);
+ g_string_append_printf(s, " * cores (%u)", ms->topo.smp.cores);
+ g_string_append_printf(s, " * threads (%u)", ms->topo.smp.threads);
return g_string_free(s, false);
}
@@ -159,6 +159,14 @@ void machine_parse_smp_config(MachineState *ms,
ms->smp.threads = threads;
ms->smp.max_cpus = maxcpus;
+ ms->topo.cpus = cpus;
+ ms->topo.max_cpus = maxcpus;
+ ms->topo.smp.sockets = sockets;
+ ms->topo.smp.dies = dies;
+ ms->topo.smp.clusters = clusters;
+ ms->topo.smp.cores = cores;
+ ms->topo.smp.threads = threads;
+
mc->smp_props.has_clusters = config->has_clusters;
/* sanity-check of the computed topology */
@@ -180,18 +188,18 @@ void machine_parse_smp_config(MachineState *ms,
return;
}
- if (ms->smp.cpus < mc->min_cpus) {
+ if (ms->topo.cpus < mc->min_cpus) {
error_setg(errp, "Invalid SMP CPUs %d. The min CPUs "
"supported by machine '%s' is %d",
- ms->smp.cpus,
+ ms->topo.cpus,
mc->name, mc->min_cpus);
return;
}
- if (ms->smp.max_cpus > mc->max_cpus) {
+ if (ms->topo.max_cpus > mc->max_cpus) {
error_setg(errp, "Invalid SMP CPUs %d. The max CPUs "
"supported by machine '%s' is %d",
- ms->smp.max_cpus,
+ ms->topo.max_cpus,
mc->name, mc->max_cpus);
return;
}
@@ -829,13 +829,13 @@ static void machine_get_smp(Object *obj, Visitor *v, const char *name,
{
MachineState *ms = MACHINE(obj);
SMPConfiguration *config = &(SMPConfiguration){
- .has_cpus = true, .cpus = ms->smp.cpus,
- .has_sockets = true, .sockets = ms->smp.sockets,
- .has_dies = true, .dies = ms->smp.dies,
- .has_clusters = true, .clusters = ms->smp.clusters,
- .has_cores = true, .cores = ms->smp.cores,
- .has_threads = true, .threads = ms->smp.threads,
- .has_maxcpus = true, .maxcpus = ms->smp.max_cpus,
+ .has_cpus = true, .cpus = ms->topo.cpus,
+ .has_sockets = true, .sockets = ms->topo.smp.sockets,
+ .has_dies = true, .dies = ms->topo.smp.dies,
+ .has_clusters = true, .clusters = ms->topo.smp.clusters,
+ .has_cores = true, .cores = ms->topo.smp.cores,
+ .has_threads = true, .threads = ms->topo.smp.threads,
+ .has_maxcpus = true, .maxcpus = ms->topo.max_cpus,
};
if (!visit_type_SMPConfiguration(v, name, &config, &error_abort)) {
@@ -1101,6 +1101,15 @@ static void machine_initfn(Object *obj)
ms->smp.cores = 1;
ms->smp.threads = 1;
+ ms->topo.cpus = mc->default_cpus;
+ ms->topo.max_cpus = mc->default_cpus;
+ ms->topo.topo_type = CPU_TOPO_TYPE_SMP;
+ ms->topo.smp.sockets = 1;
+ ms->topo.smp.dies = 1;
+ ms->topo.smp.clusters = 1;
+ ms->topo.smp.cores = 1;
+ ms->topo.smp.threads = 1;
+
machine_copy_boot_config(ms, &(BootConfiguration){ 0 });
}
@@ -10,6 +10,7 @@
#include "qemu/module.h"
#include "qom/object.h"
#include "hw/core/cpu.h"
+#include "hw/cpu/cpu-topology.h"
#define TYPE_MACHINE_SUFFIX "-machine"
@@ -360,6 +361,7 @@ struct MachineState {
AccelState *accelerator;
CPUArchIdList *possible_cpus;
CpuTopology smp;
+ GeneralCpuTopology topo; /* TODO: Completely replace MachineState.smp */
struct NVDIMMState *nvdimms_state;
struct NumaState *numa_state;
};