[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 17/17] kvm: Make KVMState be the TYPE_KVM_ACCEL i
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH v3 17/17] kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct |
Date: |
Fri, 26 Sep 2014 17:45:32 -0300 |
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>
---
kvm-all.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index 8de1a83..3ab1b4e 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -75,8 +75,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;
@@ -109,10 +111,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;
@@ -1405,7 +1410,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
@@ -1594,7 +1599,6 @@ err:
close(s->fd);
}
g_free(s->slots);
- g_free(s);
return ret;
}
@@ -2244,6 +2248,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.9.3
- [Qemu-devel] [PATCH v3 07/17] accel: Make AccelClass.available() optional, (continued)
- [Qemu-devel] [PATCH v3 07/17] accel: Make AccelClass.available() optional, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 08/17] accel: Report unknown accelerator as "not found" instead of "does not exist", Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 09/17] accel: Move KVM accel registration to kvm-all.c, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 10/17] accel: Move Xen registration code to xen-common.c, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 11/17] accel: Move qtest accel registration to qtest.c, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 12/17] accel: Remove tcg_available() function, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 13/17] accel: Move accel init/allowed code to separate function, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 14/17] accel: Rename 'init' method to 'init_machine', Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 15/17] accel: Pass MachineState object to accel init functions, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 16/17] accel: Create accel object when initializing machine, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 17/17] kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct,
Eduardo Habkost <=
- Re: [Qemu-devel] [PATCH v3 00/17] QOMify accelerator code, Paolo Bonzini, 2014/09/29