From: Glauber Costa <[EMAIL PROTECTED]>

This patch wraps up the piece of code in hw/pc.c that
actually allocates and initializates a cpu. After that,
plan is to be able to start it later on.

Signed-off-by: Glauber Costa <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index ef180ec..fad5d4e 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -737,6 +737,28 @@ static int load_option_rom(const char *filename, int 
offset)
     return size;
 }
 
+CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled)
+{
+        CPUState *env = cpu_init(cpu_model);
+        if (!env) {
+            fprintf(stderr, "Unable to find x86 CPU definition\n");
+            exit(1);
+        }
+        if (cpu != 0)
+            env->hflags |= HF_HALTED_MASK;
+        if (smp_cpus > 1) {
+            /* XXX: enable it in all cases */
+            env->cpuid_features |= CPUID_APIC;
+        }
+        register_savevm("cpu", cpu, 4, cpu_save, cpu_load, env);
+        qemu_register_reset(main_cpu_reset, env);
+        if (pci_enabled) {
+            apic_init(env);
+        }
+        vmport_init(env);
+       return env;
+}
+
 /* PC hardware initialisation */
 static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
                      const char *boot_device, DisplayState *ds,
@@ -776,23 +798,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
     }
     
     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 (i != 0)
-            env->hflags |= HF_HALTED_MASK;
-        if (smp_cpus > 1) {
-            /* XXX: enable it in all cases */
-            env->cpuid_features |= CPUID_APIC;
-        }
-        register_savevm("cpu", i, 4, cpu_save, cpu_load, env);
-        qemu_register_reset(main_cpu_reset, env);
-        if (pci_enabled) {
-            apic_init(env);
-        }
-        vmport_init(env);
+       env = pc_new_cpu(i, cpu_model, pci_enabled);
     }
 
     /* allocate RAM */
diff --git a/qemu/hw/pc.h b/qemu/hw/pc.h
index d109569..f879f30 100644
--- a/qemu/hw/pc.h
+++ b/qemu/hw/pc.h
@@ -85,6 +85,7 @@ extern int fd_bootchk;
 
 void ioport_set_a20(int enable);
 int ioport_get_a20(void);
+CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled);
 
 /* acpi.c */
 extern int acpi_enabled;

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to