diff options
author | Anthony Liguori | 2011-12-08 04:34:16 +0100 |
---|---|---|
committer | Anthony Liguori | 2012-02-03 17:41:06 +0100 |
commit | 39bffca2030950ef6efe57c2fac8327a45ae1015 (patch) | |
tree | 325262f44978e6116c9e43f688c900e08ee83738 /hw/usb-msd.c | |
parent | qdev: kill off DeviceInfo list (diff) | |
download | qemu-39bffca2030950ef6efe57c2fac8327a45ae1015.tar.gz qemu-39bffca2030950ef6efe57c2fac8327a45ae1015.tar.xz qemu-39bffca2030950ef6efe57c2fac8327a45ae1015.zip |
qdev: register all types natively through QEMU Object Model
This was done in a mostly automated fashion. I did it in three steps and then
rebased it into a single step which avoids repeatedly touching every file in
the tree.
The first step was a sed-based addition of the parent type to the subclass
registration functions.
The second step was another sed-based removal of subclass registration functions
while also adding virtual functions from the base class into a class_init
function as appropriate.
Finally, a python script was used to convert the DeviceInfo structures and
qdev_register_subclass functions to TypeInfo structures, class_init functions,
and type_register_static calls.
We are almost fully converted to QOM after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb-msd.c')
-rw-r--r-- | hw/usb-msd.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 19d0d7b8c8..6153376f3f 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -636,8 +636,16 @@ static const VMStateDescription vmstate_usb_msd = { } }; +static Property msd_properties[] = { + DEFINE_BLOCK_PROPERTIES(MSDState, conf), + DEFINE_PROP_STRING("serial", MSDState, serial), + DEFINE_PROP_BIT("removable", MSDState, removable, 0, false), + DEFINE_PROP_END_OF_LIST(), +}; + static void usb_msd_class_initfn(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); uc->init = usb_msd_initfn; @@ -649,25 +657,21 @@ static void usb_msd_class_initfn(ObjectClass *klass, void *data) uc->handle_reset = usb_msd_handle_reset; uc->handle_control = usb_msd_handle_control; uc->handle_data = usb_msd_handle_data; + dc->fw_name = "storage"; + dc->vmsd = &vmstate_usb_msd; + dc->props = msd_properties; } -static struct DeviceInfo msd_info = { - .name = "usb-storage", - .fw_name = "storage", - .size = sizeof(MSDState), - .vmsd = &vmstate_usb_msd, - .class_init= usb_msd_class_initfn, - .props = (Property[]) { - DEFINE_BLOCK_PROPERTIES(MSDState, conf), - DEFINE_PROP_STRING("serial", MSDState, serial), - DEFINE_PROP_BIT("removable", MSDState, removable, 0, false), - DEFINE_PROP_END_OF_LIST(), - }, +static TypeInfo msd_info = { + .name = "usb-storage", + .parent = TYPE_USB_DEVICE, + .instance_size = sizeof(MSDState), + .class_init = usb_msd_class_initfn, }; static void usb_msd_register_devices(void) { - usb_qdev_register(&msd_info); + type_register_static(&msd_info); usb_legacy_register("usb-storage", "disk", usb_msd_init); } device_init(usb_msd_register_devices) |