mirror of
https://git.proxmox.com/git/qemu
synced 2025-06-29 05:56:51 +00:00
x86: Factor out pc_new_cpu
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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
15dfcd454c
commit
3a31f36a07
32
hw/pc.c
32
hw/pc.c
@ -1062,6 +1062,25 @@ int cpu_is_bsp(CPUState *env)
|
|||||||
return env->cpuid_apic_id == 0;
|
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, env);
|
||||||
|
}
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
/* PC hardware initialisation */
|
/* PC hardware initialisation */
|
||||||
static void pc_init1(ram_addr_t ram_size,
|
static void pc_init1(ram_addr_t ram_size,
|
||||||
const char *boot_device,
|
const char *boot_device,
|
||||||
@ -1105,18 +1124,7 @@ static void pc_init1(ram_addr_t ram_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < smp_cpus; i++) {
|
for (i = 0; i < smp_cpus; i++) {
|
||||||
env = cpu_init(cpu_model);
|
env = pc_new_cpu(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, env);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vmport_init();
|
vmport_init();
|
||||||
|
Loading…
Reference in New Issue
Block a user