diff mbox

[RFC,09/20] cpu: introduce cpu_realize()

Message ID 1355861053-11460-10-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Dec. 18, 2012, 8:04 p.m. UTC
This is just for testing/demonstration purposes. Probably this will be
replaced by the more generic DeviceState realize() method, later.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qemu/cpu.h | 13 +++++++++++++
 qom/cpu.c          | 10 ++++++++++
 2 files changed, 23 insertions(+)

Comments

Andreas Färber Dec. 18, 2012, 11:13 p.m. UTC | #1
Am 18.12.2012 21:04, schrieb Eduardo Habkost:
> This is just for testing/demonstration purposes. Probably this will be
> replaced by the more generic DeviceState realize() method, later.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Such a function was nack'ed for Object, the reason being that the goal
was to set realized = true in one central place rather than sprinkling
_realize() calls everywhere as done for qdev init.

Since CPU is close to becoming a device, I would rather not do this
differently for the CPU, but I can truely understand the utility of it
in this series... :)

Andreas
diff mbox

Patch

diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
index b27b353..90bb27d 100644
--- a/include/qemu/cpu.h
+++ b/include/qemu/cpu.h
@@ -20,6 +20,7 @@ 
 #ifndef QEMU_CPU_H
 #define QEMU_CPU_H
 
+#include "error.h"
 #include "qemu/object.h"
 #include "qemu-thread.h"
 
@@ -41,6 +42,7 @@  typedef struct CPUState CPUState;
 /**
  * CPUClass:
  * @reset: Callback to reset the #CPUState to its initial state.
+ * @realize: Realize function to finish CPU initialization.
  *
  * Represents a CPU family or model.
  */
@@ -50,6 +52,7 @@  typedef struct CPUClass {
     /*< public >*/
 
     void (*reset)(CPUState *cpu);
+    void (*realize)(CPUState *cpu, Error **errp);
 } CPUClass;
 
 /**
@@ -88,6 +91,16 @@  struct CPUState {
  */
 void cpu_reset(CPUState *cpu);
 
+
+/**
+ * cpu_realize:
+ * @cpu: The CPU that is going to be "realized".
+ *
+ * Finishes initialization of the CPU object, after properties have been
+ * set.
+ */
+void cpu_realize(CPUState *cpu, Error **errp);
+
 /**
  * qemu_cpu_has_work:
  * @cpu: The vCPU to check.
diff --git a/qom/cpu.c b/qom/cpu.c
index 5b36046..a96f6ee 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -30,6 +30,16 @@  void cpu_reset(CPUState *cpu)
     }
 }
 
+void cpu_realize(CPUState *cpu, Error **errp)
+{
+    CPUClass *klass = CPU_GET_CLASS(cpu);
+
+    if (klass->realize) {
+        (*klass->realize)(cpu, errp);
+    }
+}
+
+
 static void cpu_common_reset(CPUState *cpu)
 {
 }