[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 36/41] hw/i386: Allow x86_cpu_new() to specify parent for new CPU
From: |
Zhao Liu |
Subject: |
[RFC 36/41] hw/i386: Allow x86_cpu_new() to specify parent for new CPU |
Date: |
Thu, 30 Nov 2023 22:41:58 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
For QOM topology, CPU should be inserted under its parent core.
Extend x86_cpu_new() to allow caller to specify topology parent.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/i386/x86.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index d9293846db64..3c99f4c3ab51 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -94,15 +94,22 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,
return x86_apicid_from_cpu_idx(&topo_info, cpu_index);
}
-
static void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id,
- Error **errp)
+ Object *parent, int index, Error **errp)
{
- Object *cpu = object_new(MACHINE(x86ms)->cpu_type);
+ const char *cpu_type = MACHINE(x86ms)->cpu_type;
+ Object *cpu = object_new(cpu_type);
if (!object_property_set_uint(cpu, "apic-id", apic_id, errp)) {
goto out;
}
+
+ if (parent) {
+ char *name = g_strdup_printf("%s[%d]", cpu_type, index);
+ object_property_add_child(parent, name, cpu);
+ g_free(name);
+ }
+
qdev_realize(DEVICE(cpu), NULL, errp);
out:
@@ -146,7 +153,8 @@ void x86_cpus_init(X86MachineState *x86ms, int
default_cpu_version)
possible_cpus = mc->possible_cpu_arch_ids(ms);
for (i = 0; i < ms->smp.cpus; i++) {
- x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, &error_fatal);
+ x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id,
+ NULL, i, &error_fatal);
}
}
--
2.34.1
- [RFC 04/41] qom/object: Introduce helper to resolve path from non-direct parent, (continued)
- [RFC 04/41] qom/object: Introduce helper to resolve path from non-direct parent, Zhao Liu, 2023/11/30
- [RFC 06/41] qdev: Introduce user-child interface to collect devices from -device, Zhao Liu, 2023/11/30
- [RFC 09/41] hw/core/topo: Support topology index for topology device, Zhao Liu, 2023/11/30
- [RFC 10/41] hw/core/topo: Add virtual method to update topology info for parent, Zhao Liu, 2023/11/30
- [RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal, Zhao Liu, 2023/11/30
- [RFC 24/41] hw/cpu/socket: Abstract cpu-socket level as topology device, Zhao Liu, 2023/11/30
- [RFC 26/41] hw/cpu/drawer: Abstract cpu-drawer level as topology device, Zhao Liu, 2023/11/30
- [RFC 15/41] hw/cpu/core: Allow to configure plugged threads for cpu-core, Zhao Liu, 2023/11/30
- [RFC 28/41] hw/core/slot: Maintain the core queue in CPU slot, Zhao Liu, 2023/11/30
- [RFC 33/41] hw/machine: Validate smp topology tree without -smp, Zhao Liu, 2023/11/30
- [RFC 36/41] hw/i386: Allow x86_cpu_new() to specify parent for new CPU,
Zhao Liu <=
- [RFC 39/41] hw/i386: Add the interface to search parent for QOM topology, Zhao Liu, 2023/11/30
- [RFC 40/41] hw/i386: Support QOM topology, Zhao Liu, 2023/11/30
- [RFC 41/41] hw/i386: Cleanup non-QOM topology support, Zhao Liu, 2023/11/30