Received: from eggs.gnu.org ([2001:4830:134:3::10]:45757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcDxs-00020z-C6 for qemu-devel@nongnu.org; Thu, 09 Oct 2014 09:41:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcDxi-0007CF-R2 for qemu-devel@nongnu.org; Thu, 09 Oct 2014 09:41:08 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:63516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcDxi-0007C6-JW for qemu-devel@nongnu.org; Thu, 09 Oct 2014 09:40:58 -0400 Received: by mail-wi0-f177.google.com with SMTP id fb4so1824571wid.4 for ; Thu, 09 Oct 2014 06:40:57 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 9 Oct 2014 15:40:36 +0200 Message-Id: <1412862036-14546-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1412862036-14546-1-git-send-email-pbonzini@redhat.com> References: <1412862036-14546-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL v3 22/28] accel: Create accel object when initializing machine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost From: Eduardo Habkost Create an actual TYPE_ACCEL object when initializing a machine. This will allow accelerator classes to implement some initialization on instance_init, and to save state on the TYPE_ACCEL object. Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- accel.c | 7 +++++++ include/hw/boards.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/accel.c b/accel.c index 6087ab3..74e41da 100644 --- a/accel.c +++ b/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; @@ -60,11 +61,17 @@ static AccelClass *accel_find(const char *opt_name) static int accel_init_machine(AccelClass *acc, MachineState *ms) { + ObjectClass *oc = OBJECT_CLASS(acc); + 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)); } return ret; } diff --git a/include/hw/boards.h b/include/hw/boards.h index 0058c49..6a60c3c 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -5,6 +5,7 @@ #include "qemu/typedefs.h" #include "sysemu/blockdev.h" +#include "sysemu/accel.h" #include "hw/qdev.h" #include "qom/object.h" @@ -131,6 +132,7 @@ struct MachineState { char *kernel_cmdline; char *initrd_filename; const char *cpu_model; + AccelState *accelerator; }; #endif -- 1.8.3.1