diff mbox

[v2,16/17] accel: Save AccelState on MachineState when initializing

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

Commit Message

Eduardo Habkost Aug. 29, 2014, 8:31 p.m. UTC
This will allow machine initialization code to get the accelerator
object if necessary.

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(+)

Comments

Paolo Bonzini Sept. 26, 2014, 3:11 p.m. UTC | #1
Il 29/08/2014 22:31, Eduardo Habkost ha scritto:
> This will allow machine initialization code to get the accelerator
> object if necessary.
> 
> 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 --git a/hw/core/accel.c b/hw/core/accel.c
> index 66ee1fa..2e1ea76 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;
> 

I would just squash this with the previous patch.  Apart from this,

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo
diff mbox

Patch

diff --git a/hw/core/accel.c b/hw/core/accel.c
index 66ee1fa..2e1ea76 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;