From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcAnn-0006P8-Ju for qemu-devel@nongnu.org; Thu, 09 Oct 2014 06:18:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcAne-0000ZC-Bm for qemu-devel@nongnu.org; Thu, 09 Oct 2014 06:18:31 -0400 Received: from mail-wg0-x232.google.com ([2a00:1450:400c:c00::232]:34762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcAne-0000Z6-5m for qemu-devel@nongnu.org; Thu, 09 Oct 2014 06:18:22 -0400 Received: by mail-wg0-f50.google.com with SMTP id a1so910365wgh.9 for ; Thu, 09 Oct 2014 03:18:21 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 9 Oct 2014 12:17:30 +0200 Message-Id: <1412849855-12661-16-git-send-email-pbonzini@redhat.com> In-Reply-To: <1412849438-12274-1-git-send-email-pbonzini@redhat.com> References: <1412849438-12274-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 23/28] kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost From: Eduardo Habkost Now that we create an accel object before calling machine_init, we can simply use the accel object to save all KVMState data, instead of allocationg KVMState manually. Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- kvm-all.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 0a9de92..e98a7c7 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -71,8 +71,10 @@ typedef struct KVMSlot typedef struct kvm_dirty_log KVMDirtyLog; -struct KVMState +typedef struct KVMState { + AccelState parent_obj; + KVMSlot *slots; int nr_slots; int fd; @@ -105,10 +107,13 @@ struct KVMState QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; bool direct_msi; #endif -}; +} KVMState; #define TYPE_KVM_ACCEL ACCEL_CLASS_NAME("kvm") +#define KVM_STATE(obj) \ + OBJECT_CHECK(KVMState, (obj), TYPE_KVM_ACCEL) + KVMState *kvm_state; bool kvm_kernel_irqchip; bool kvm_async_interrupts_allowed; @@ -1401,7 +1406,7 @@ static int kvm_init(MachineState *ms) int i, type = 0; const char *kvm_type; - s = g_malloc0(sizeof(KVMState)); + s = KVM_STATE(ms->accelerator); /* * On systems where the kernel can support different base page @@ -1590,7 +1595,6 @@ err: close(s->fd); } g_free(s->slots); - g_free(s); return ret; } @@ -2242,6 +2246,7 @@ static const TypeInfo kvm_accel_type = { .name = TYPE_KVM_ACCEL, .parent = TYPE_ACCEL, .class_init = kvm_accel_class_init, + .instance_size = sizeof(KVMState), }; static void kvm_type_init(void) -- 1.8.3.1