diff mbox

[RFC,16/25] accel: Save AccelState on MachineState when initializing

Message ID 1404943462-711-17-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost July 9, 2014, 10:04 p.m. UTC
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/accel.c         | 3 +++
 include/hw/boards.h     | 1 +
 include/qemu/typedefs.h | 2 ++
 3 files changed, 6 insertions(+)
diff mbox

Patch

diff --git a/hw/core/accel.c b/hw/core/accel.c
index b86773d..268ecee 100644
--- a/hw/core/accel.c
+++ b/hw/core/accel.c
@@ -32,6 +32,7 @@ 
 #include "sysemu/qtest.h"
 #include "hw/xen/xen.h"
 #include "qom/object.h"
+#include "hw/boards.h"
 
 int tcg_tb_size;
 static bool tcg_allowed = true;
@@ -64,9 +65,11 @@  static int accel_init_machine(AccelClass *acc, MachineState *ms)
     const char *cname = object_class_get_name(oc);
     AccelState *accel = ACCEL(object_new(cname));
     int ret;
+    ms->accelerator = accel;
     *(acc->allowed) = true;
     ret = acc->init_machine(ms);
     if (ret < 0) {
+        ms->accelerator = NULL;
         *(acc->allowed) = false;
         object_unref(OBJECT(accel));
     }
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 605a970..1cff2b4 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -132,6 +132,7 @@  struct MachineState {
     char *kernel_cmdline;
     char *initrd_filename;
     const char *cpu_model;
+    AccelState *accelerator;
 };
 
 #endif
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 04df51b..446af93 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -30,6 +30,8 @@  typedef struct MemoryListener MemoryListener;
 
 typedef struct MemoryMappingList MemoryMappingList;
 
+typedef struct AccelState AccelState;
+
 typedef struct QEMUMachine QEMUMachine;
 typedef struct MachineClass MachineClass;
 typedef struct MachineState MachineState;