Skip to content

Commit

Permalink
kvm/clock: QOM'ify some more
Browse files Browse the repository at this point in the history
Introduce type constant and avoid FROM_SYSBUS().

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
[AF: Renamed parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
Hu Tao authored and afaerber committed Jul 22, 2013
1 parent 02f9a6f commit 98bdc0d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hw/i386/kvm/clock.c
Expand Up @@ -22,8 +22,14 @@
#include <linux/kvm.h>
#include <linux/kvm_para.h>

#define TYPE_KVM_CLOCK "kvmclock"
#define KVM_CLOCK(obj) OBJECT_CHECK(KVMClockState, (obj), TYPE_KVM_CLOCK)

typedef struct KVMClockState {
/*< private >*/
SysBusDevice busdev;
/*< public >*/

uint64_t clock;
bool clock_valid;
} KVMClockState;
Expand Down Expand Up @@ -87,7 +93,7 @@ static void kvmclock_vm_state_change(void *opaque, int running,

static int kvmclock_init(SysBusDevice *dev)
{
KVMClockState *s = FROM_SYSBUS(KVMClockState, dev);
KVMClockState *s = KVM_CLOCK(dev);

qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s);
return 0;
Expand Down Expand Up @@ -115,7 +121,7 @@ static void kvmclock_class_init(ObjectClass *klass, void *data)
}

static const TypeInfo kvmclock_info = {
.name = "kvmclock",
.name = TYPE_KVM_CLOCK,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(KVMClockState),
.class_init = kvmclock_class_init,
Expand All @@ -129,7 +135,7 @@ void kvmclock_create(void)
if (kvm_enabled() &&
cpu->env.features[FEAT_KVM] & ((1ULL << KVM_FEATURE_CLOCKSOURCE) |
(1ULL << KVM_FEATURE_CLOCKSOURCE2))) {
sysbus_create_simple("kvmclock", -1, NULL);
sysbus_create_simple(TYPE_KVM_CLOCK, -1, NULL);
}
}

Expand Down

0 comments on commit 98bdc0d

Please sign in to comment.