* [Qemu-devel] [PATCH] x86: Factor out pc_new_cpu
@ 2009-06-25 6:23 Jan Kiszka
0 siblings, 0 replies; only message in thread
From: Jan Kiszka @ 2009-06-25 6:23 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Avi Kivity
[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]
At this point, this refactoring looks like overkill. But we will need it
for CPU hotplugging, and qemu-kvm already carries it. Merging it early
would help qemu-kvm when rebasing against upstream.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/pc.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 86e5cfe..09073f5 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -829,6 +829,25 @@ int cpu_is_bsp(CPUState *env)
return env->cpuid_apic_id == 0;
}
+static CPUState *pc_new_cpu(const char *cpu_model)
+{
+ CPUState *env;
+
+ env = cpu_init(cpu_model);
+ if (!env) {
+ fprintf(stderr, "Unable to find x86 CPU definition\n");
+ exit(1);
+ }
+ if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
+ env->cpuid_apic_id = env->cpu_index;
+ /* APIC reset callback resets cpu */
+ apic_init(env);
+ } else {
+ qemu_register_reset((QEMUResetHandler*)cpu_reset, 0, env);
+ }
+ return env;
+}
+
/* PC hardware initialisation */
static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
@@ -869,20 +888,8 @@ static void pc_init1(ram_addr_t ram_size,
cpu_model = "qemu32";
#endif
}
-
- for(i = 0; i < smp_cpus; i++) {
- env = cpu_init(cpu_model);
- if (!env) {
- fprintf(stderr, "Unable to find x86 CPU definition\n");
- exit(1);
- }
- if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
- env->cpuid_apic_id = env->cpu_index;
- /* APIC reset callback resets cpu */
- apic_init(env);
- } else {
- qemu_register_reset((QEMUResetHandler*)cpu_reset, 0, env);
- }
+ for (i = 0; i < smp_cpus; i++) {
+ env = pc_new_cpu(cpu_model);
}
vmport_init();
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-25 6:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-25 6:23 [Qemu-devel] [PATCH] x86: Factor out pc_new_cpu Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).