[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/28] kvm: Make KVMState be the TYPE_KVM_ACCEL insta
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 23/28] kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct |
Date: |
Thu, 9 Oct 2014 12:17:30 +0200 |
From: Eduardo Habkost <address@hidden>
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 <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
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
- [Qemu-devel] [PULL 05/28] qemu-char: Add reconnecting to client sockets, (continued)
- [Qemu-devel] [PULL 05/28] qemu-char: Add reconnecting to client sockets, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 06/28] qemu-char: Print the remote and local addresses for a socket, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 17/28] accel: Move qtest accel registration to qtest.c, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 18/28] accel: Remove tcg_available() function, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 19/28] accel: Move accel init/allowed code to separate function, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 20/28] accel: Rename 'init' method to 'init_machine', Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 22/28] accel: Create accel object when initializing machine, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 21/28] accel: Pass MachineState object to accel init functions, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 26/28] qemu-error: Add error_vreport(), Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 27/28] qemu-sockets: Add error to non-blocking connect handler, Paolo Bonzini, 2014/10/09
- [Qemu-devel] [PULL 23/28] kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct,
Paolo Bonzini <=
- Re: [Qemu-devel] [PULL 23/28] kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct, Gonglei, 2014/10/10
[Qemu-devel] [PULL 28/28] qemu-char: Fix reconnect socket error reporting, Paolo Bonzini, 2014/10/09
[Qemu-devel] [PULL 25/28] virtio-scsi: fix use-after-free of VirtIOSCSIReq, Paolo Bonzini, 2014/10/09
[Qemu-devel] [PULL 24/28] linuxboot: compute initrd loading address, Paolo Bonzini, 2014/10/09
[Qemu-devel] [PULL 07/28] vl.c: Small coding style fix, Paolo Bonzini, 2014/10/09
[Qemu-devel] [PULL 16/28] accel: Move Xen registration code to xen-common.c, Paolo Bonzini, 2014/10/09