[kvm-devel] [PATCH 8/15] isolate cpu initialization function in hw/pc.c

2008-02-26 Thread Glauber Costa
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]
---
 qemu/hw/pc.c |   40 +++-
 qemu/hw/pc.h |1 +
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 77a7d53..982377d 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -740,6 +740,28 @@ static int load_option_rom(const char *f
 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,
@@ -779,23 +801,7 @@ #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 (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 f640395..f70ab55 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;
-- 
1.4.2


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


[kvm-devel] [PATCH 8/15] isolate cpu initialization function in hw/pc.c

2008-02-22 Thread Glauber Costa
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]
---
 qemu/hw/pc.c |   40 +++-
 qemu/hw/pc.h |1 +
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 77a7d53..982377d 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -740,6 +740,28 @@ static int load_option_rom(const char *f
 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,
@@ -779,23 +801,7 @@ #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 (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 f640395..f70ab55 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;
-- 
1.4.2


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