diff mbox

[qom-next,6/6] target-i386: move reset callback to cpu.c

Message ID 1337791181-27446-7-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov May 23, 2012, 4:39 p.m. UTC
Moving reset callback into cpu object from board level will allow
properly create object during run-time (hotplug).

When reset over QOM hierarchy is implemented, this reset callback
should be removed.

v2:
  - fix build for i386-linux-target

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/pc.c           |    7 -------
 target-i386/cpu.c |   11 +++++++++++
 2 files changed, 11 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/hw/pc.c b/hw/pc.c
index d7845ea..868dbe7 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -885,12 +885,6 @@  void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
     }
 }
 
-static void pc_cpu_reset(void *opaque)
-{
-    X86CPU *cpu = opaque;
-    cpu_reset(CPU(cpu));
-}
-
 void pc_cpus_init(const char *cpu_model)
 {
     X86CPU *cpu;
@@ -901,7 +895,6 @@  void pc_cpus_init(const char *cpu_model)
         if (cpu == NULL) {
             exit(1);
         }
-        qemu_register_reset(pc_cpu_reset, cpu);
     }
 }
 
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 99ef891..ad39f71 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1775,6 +1775,13 @@  static void x86_set_cpu_model(Object *obj, const char *value, Error **errp)
 }
 
 #ifndef CONFIG_USER_ONLY
+/* TODO: remove me, when reset over QOM tree is implemented */
+static void x86_cpu_machine_reset_cb(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    cpu_reset(CPU(cpu));
+}
+
 static CPUDebugExcpHandler *prev_debug_excp_handler;
 
 static void breakpoint_handler(CPUX86State *env)
@@ -1823,6 +1830,10 @@  void x86_cpu_realize(Object *obj, Error **errp)
 
     mce_init(cpu);
     qemu_init_vcpu(env);
+
+#ifndef CONFIG_USER_ONLY
+    qemu_register_reset(x86_cpu_machine_reset_cb, cpu);
+#endif
     cpu_reset(CPU(cpu));
 }