usb-hid: simplify class initialization a bit
Subsystems (2)
PATCH 1/23 usb-hid: simplify class initialization a bit
We can probably model USBHidDevice as a base class to get even better code sharing but for now, just use a common function to initialize the common class members.
--- hw/usb-hid.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-)
hw/usb-hid.c +13 -14
@@ -553,13 +553,10 @@ static const VMStateDescription vmstate_usb_kbd = { } }; -static void usb_tablet_class_initfn (ObjectClass *klass,void *data) +static void usb_hid_class_initfn (ObjectClass *klass,void *data) {USBDeviceClass *uc =USB_DEVICE_CLASS (klass); - uc->init = usb_tablet_initfn; - uc->product_desc ="QEMU USB Tablet" ; - uc->usb_desc = &desc_tablet; uc->handle_packet = usb_generic_handle_packet; uc->handle_reset = usb_hid_handle_reset; uc->handle_control = usb_hid_handle_control;
@@ -567,6 +564,16 @@ static void usb_tablet_class_initfn(ObjectClass *klass, void *data) uc->handle_destroy = usb_hid_handle_destroy; } +static void usb_tablet_class_initfn (ObjectClass *klass,void *data) +{ +USBDeviceClass *uc =USB_DEVICE_CLASS (klass); + +usb_hid_class_initfn (klass, data); + uc->init = usb_tablet_initfn; + uc->product_desc ="QEMU USB Tablet" ; + uc->usb_desc = &desc_tablet; +} +static struct DeviceInfo usb_tablet_info = { .name ="usb-tablet" , .size =sizeof (USBHIDState),
@@ -578,14 +585,10 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data) {USBDeviceClass *uc =USB_DEVICE_CLASS (klass); +usb_hid_class_initfn (klass, data); uc->init = usb_mouse_initfn; uc->product_desc ="QEMU USB Mouse" ; uc->usb_desc = &desc_mouse; - uc->handle_packet = usb_generic_handle_packet; - uc->handle_reset = usb_hid_handle_reset; - uc->handle_control = usb_hid_handle_control; - uc->handle_data = usb_hid_handle_data; - uc->handle_destroy = usb_hid_handle_destroy; }static struct DeviceInfo usb_mouse_info = {
@@ -599,14 +602,10 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data) {USBDeviceClass *uc =USB_DEVICE_CLASS (klass); +usb_hid_class_initfn (klass, data); uc->init = usb_keyboard_initfn; uc->product_desc ="QEMU USB Keyboard" ; uc->usb_desc = &desc_keyboard; - uc->handle_packet = usb_generic_handle_packet; - uc->handle_reset = usb_hid_handle_reset; - uc->handle_control = usb_hid_handle_control; - uc->handle_data = usb_hid_handle_data; - uc->handle_destroy = usb_hid_handle_destroy; }static struct DeviceInfo usb_keyboard_info = {
Signature · 1 line
1.7.4.1
PATCH 3/23 qdev: make DeviceInfo private
Introduce accessors and remove any code that directly accesses DeviceInfo members.
--- hw/pci.c | 13 ++++++++----- hw/qdev-properties.c | 4 ++-- hw/qdev.c | 30 +++++++++++++++++++++++++++++- hw/qdev.h | 24 +++++++++--------------- 4 files changed, 48 insertions(+), 23 deletions(-)
hw/pci.c +8 -5
@@ -1673,6 +1673,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)char *path;void *ptr;char name[32 ]; +const VMStateDescription *vmsd;if (!pdev->romfile)return 0 ;
@@ -1709,10 +1710,13 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) size =1 <<qemu_fls (size); } -if (qdev_get_info (&pdev->qdev)->vmsd) -snprintf (name,sizeof (name),"%s.rom" ,qdev_get_info (&pdev->qdev)->vmsd->name); -else + vmsd =qdev_get_vmsd (DEVICE (pdev)); + +if (vmsd) { +snprintf (name,sizeof (name),"%s.rom" , vmsd->name); + }else {snprintf (name,sizeof (name),"%s.rom" ,object_get_typename (OBJECT (pdev))); + } pdev->has_rom = true;memory_region_init_ram (&pdev->rom, name, size);vmstate_register_ram (&pdev->rom, &pdev->qdev);
@@ -1953,8 +1957,7 @@ static int pci_qdev_find_recursive(PCIBus *bus, }/* roughly check if given qdev is pci device */ -if (qdev_get_info (qdev)->init == &pci_qdev_init && - qdev->parent_bus->info == &pci_bus_info) { +if (object_dynamic_cast (OBJECT (qdev),TYPE_PCI_DEVICE )) { *pdev =PCI_DEVICE (qdev);return 0 ; }
hw/qdev-properties.c +2 -2
@@ -966,7 +966,7 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)Property *prop;/* device properties */ - prop =qdev_prop_walk (qdev_get_info (dev)->props, name); + prop =qdev_prop_walk (qdev_get_props (dev), name);if (prop)return prop;
@@ -1166,7 +1166,7 @@ void qdev_prop_set_globals(DeviceState *dev) QTAILQ_FOREACH(prop, &global_props, next) {if (strcmp (object_get_typename (OBJECT (dev)), prop->driver) !=0 && -strcmp (qdev_get_info (dev)->bus_info->name, prop->driver) !=0 ) { +strcmp (qdev_get_bus_info (dev)->name, prop->driver) !=0 ) {continue ; }if (qdev_prop_parse (dev, prop->property, prop->value) !=0 ) {
hw/qdev.c +29 -1
@@ -60,11 +60,39 @@ static void qdev_subclass_init(ObjectClass *klass, void *data) } } -DeviceInfo *qdev_get_info (DeviceState *dev) +static DeviceInfo *qdev_get_info (DeviceState *dev) {return DEVICE_GET_CLASS (dev)->info; } +const VMStateDescription *qdev_get_vmsd (DeviceState *dev) +{ +return qdev_get_info (dev)->vmsd; +} + +BusInfo *qdev_get_bus_info (DeviceState *dev) +{ +return qdev_get_info (dev)->bus_info; +} + +Property *qdev_get_props (DeviceState *dev) +{ +return qdev_get_info (dev)->props; +} + +const char *qdev_fw_name (DeviceState *dev) +{ +DeviceInfo *info =qdev_get_info (dev); + +if (info->fw_name) { +return info->fw_name; + }else if (info->alias) { +return info->alias; + } + +return object_get_typename (OBJECT (dev)); +} +void qdev_register_subclass (DeviceInfo *info,const char *parent) {TypeInfo type_info = {};
hw/qdev.h +9 -15
@@ -398,22 +398,8 @@ void qdev_prop_set_globals(DeviceState *dev);void error_set_from_qdev_prop_error (Error **errp,int ret,DeviceState *dev,Property *prop,const char *value); -DeviceInfo *qdev_get_info (DeviceState *dev); - -static inline const char *qdev_fw_name (DeviceState *dev) -{ -DeviceInfo *info =qdev_get_info (dev); - -if (info->fw_name) { -return info->fw_name; - }else if (info->alias) { -return info->alias; - } - -return object_get_typename (OBJECT (dev)); -} -char *qdev_get_fw_dev_path (DeviceState *dev); +/* This is a nasty hack to allow passing a NULL bus to qdev_create. */ extern struct BusInfo system_bus_info;
@@ -661,4 +647,12 @@ void qdev_machine_init(void);*/ void device_reset (DeviceState *dev); +const VMStateDescription *qdev_get_vmsd (DeviceState *dev); + +const char *qdev_fw_name (DeviceState *dev); + +BusInfo *qdev_get_bus_info (DeviceState *dev); + +Property *qdev_get_props (DeviceState *dev); +#endif
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 03/23] qdev: make DeviceInfo private
Am 30.01.2012 22:08, schrieb Anthony Liguori:
Quoted 4 lines
Introduce accessors and remove any code that directly accesses DeviceInfo members.
Signed-off-by Anthony Liguori <[email protected]>
/-F
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 4/23 qdev: remove info from class
In reply to Anthony LiguoriNow DeviceInfo is no longer used after object construction. All of the relevant members have been moved to DeviceClass.
--- hw/pci.c | 4 ++- hw/qdev.c | 94 ++++++++++++++++++++++++++++++++++++------------------------ hw/qdev.h | 26 +++++++++++++--- 3 files changed, 80 insertions(+), 44 deletions(-)
hw/pci.c +3 -1
@@ -1467,7 +1467,9 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) } bus =FROM_QBUS (PCIBus,qdev_get_parent_bus (qdev)); - pci_dev =do_pci_register_device (pci_dev, bus, base->name, pci_dev->devfn); + pci_dev =do_pci_register_device (pci_dev, bus, +object_get_typename (OBJECT (qdev)), + pci_dev->devfn);if (pci_dev ==NULL )return -1 ;if (qdev->hotplugged && pc->no_hotplug) {
hw/qdev.c +56 -38
197 lines not on this page · raw message
hw/qdev.h +21 -5
@@ -72,10 +72,30 @@ typedef struct DeviceProperty#define DEVICE_CLASS (klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)#define DEVICE_GET_CLASS (obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE) +typedef int (*qdev_initfn )(DeviceState *dev,DeviceInfo *info); +typedef int (*qdev_event )(DeviceState *dev); +typedef void (*qdev_resetfn )(DeviceState *dev); +typedef struct DeviceClass {ObjectClass parent_class; -DeviceInfo *info; + +const char *fw_name; +const char *alias; +const char *desc; +Property *props; +int no_user; + +/* callbacks */ void (*reset)(DeviceState *dev); + +/* device state */ +const VMStateDescription *vmsd; + +/* Private to qdev / bus. */ +qdev_initfn init; +qdev_event unplug; +qdev_event exit; +BusInfo *bus_info; }DeviceClass ;/* This structure should not be accessed directly. We declare it here
@@ -212,10 +232,6 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name);/*** Device API. ***/ -typedef int (*qdev_initfn )(DeviceState *dev,DeviceInfo *info); -typedef int (*qdev_event )(DeviceState *dev); -typedef void (*qdev_resetfn )(DeviceState *dev); -struct DeviceInfo {const char *name;const char *fw_name;
Signature · 1 line
1.7.4.1
PATCH 5/23 qdev: allow classes to overload qdev functions
In reply to Anthony LiguoriThis allows us to drop per-Device registration functions by allowing the class_init functions to overload qdev methods.
--- hw/qdev.c | 53 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 33 insertions(+), 20 deletions(-)
hw/qdev.c +33 -20
@@ -50,21 +50,39 @@ static void qdev_subclass_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);DeviceInfo *info = data; - dc->fw_name = info->fw_name; - dc->alias = info->alias; - dc->desc = info->desc; - dc->props = info->props; - dc->no_user = info->no_user; - - dc->reset = info->reset; - - dc->vmsd = info->vmsd; - - dc->init = info->init; - dc->unplug = info->unplug; - dc->exit = info->exit; - dc->bus_info = info->bus_info; - +if (info->fw_name) { + dc->fw_name = info->fw_name; + } +if (info->alias) { + dc->alias = info->alias; + } +if (info->desc) { + dc->desc = info->desc; + } +if (info->props) { + dc->props = info->props; + } +if (info->no_user) { + dc->no_user = info->no_user; + } +if (info->reset) { + dc->reset = info->reset; + } +if (info->vmsd) { + dc->vmsd = info->vmsd; + } +if (info->init) { + dc->init = info->init; + } +if (info->unplug) { + dc->unplug = info->unplug; + } +if (info->exit) { + dc->exit = info->exit; + } +if (info->bus_info) { + dc->bus_info = info->bus_info; + }if (info->class_init) { info->class_init (klass, data); }
@@ -131,8 +149,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)/* first check device names */ for (info = device_info_list; info !=NULL ; info = info->next) { -if (bus_info && info->bus_info != bus_info) -continue ;if (strcmp (info->name, name) !=0 )continue ;return info;
@@ -140,8 +156,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)/* failing that check the aliases */ for (info = device_info_list; info !=NULL ; info = info->next) { -if (bus_info && info->bus_info != bus_info) -continue ;if (!info->alias)continue ;if (strcmp (info->alias, name) !=0 )
@@ -164,7 +178,6 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)DeviceState *dev;Property *prop; -assert (bus->info == info->bus_info); dev =DEVICE (object_new (info->name)); dev->parent_bus = bus;qdev_prop_set_defaults (dev,qdev_get_props (dev));
Signature · 1 line
1.7.4.1
PATCH 6/23 qdev: refactor device creation to allow bus_info to be set only in class
In reply to Anthony LiguoriAs we use class_init to set class members, DeviceInfo no longer holds this information.
--- hw/qdev.c | 42 +++++++++++++++++++----------------------- 1 files changed, 19 insertions(+), 23 deletions(-)
hw/qdev.c +19 -23
@@ -119,21 +119,29 @@ const char *qdev_fw_name(DeviceState *dev)return object_get_typename (OBJECT (dev)); } -void qdev_register_subclass (DeviceInfo *info,const char *parent) +static void qdev_do_register_subclass (DeviceInfo *info,const char *parent, +const char *name) {TypeInfo type_info = {};assert (info->size >=sizeof (DeviceState));assert (!info->next); - type_info.name = info->name; + type_info.name = name; type_info.parent = parent; type_info.instance_size = info->size; type_info.class_init = qdev_subclass_init; type_info.class_data = info;type_register_static (&type_info); +} +void qdev_register_subclass (DeviceInfo *info,const char *parent) +{ +qdev_do_register_subclass (info, parent, info->name); +if (info->alias) { +qdev_do_register_subclass (info, parent, info->alias); + } info->next = device_info_list; device_info_list = info; }
@@ -173,12 +181,12 @@ bool qdev_exists(const char *name)static void qdev_property_add_legacy (DeviceState *dev,Property *prop,Error **errp); -static DeviceState *qdev_create_from_info (BusState *bus,DeviceInfo *info) +static DeviceState *qdev_create_from_info (BusState *bus,const char *typename) {DeviceState *dev;Property *prop; - dev =DEVICE (object_new (info->name)); + dev =DEVICE (object_new (typename)); dev->parent_bus = bus;qdev_prop_set_defaults (dev,qdev_get_props (dev));qdev_prop_set_defaults (dev, dev->parent_bus->info->props);
@@ -230,18 +238,11 @@ DeviceState *qdev_create(BusState *bus, const char *name)DeviceState *qdev_try_create (BusState *bus,const char *name) { -DeviceInfo *info; -if (!bus) { bus =sysbus_get_default (); } - info =qdev_find_info (bus->info, name); -if (!info) { -return NULL ; - } - -return qdev_create_from_info (bus, info); +return qdev_create_from_info (bus, name); }static void qdev_print_devinfo (DeviceInfo *info)
@@ -352,8 +353,8 @@ static DeviceState *qdev_get_peripheral_anon(void)DeviceState *qdev_device_add (QemuOpts *opts) { +DeviceClass *k;const char *driver, *path, *id; -DeviceInfo *info;DeviceState *qdev;BusState *bus;
@@ -364,12 +365,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) }/* find driver */ - info =qdev_find_info (NULL , driver); -if (!info || info->no_user) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"driver" ,"a driver name" ); -error_printf_unless_qmp ("Try with argument '?' for a list.\n" ); -return NULL ; - } + k =DEVICE_CLASS (object_class_by_name (driver));/* find bus */ path =qemu_opt_get (opts,"bus" );
@@ -378,16 +374,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)if (!bus) {return NULL ; } -if (bus->info != info->bus_info) { +if (bus->info != k->bus_info) {qerror_report (QERR_BAD_BUS_FOR_DEVICE , driver, bus->info->name);return NULL ; } }else { - bus =qbus_find_recursive (main_system_bus,NULL , info->bus_info); + bus =qbus_find_recursive (main_system_bus,NULL , k->bus_info);if (!bus) {qerror_report (QERR_NO_BUS_FOR_DEVICE , - info->name, info->bus_info->name); + driver, k->bus_info->name);return NULL ; } }
@@ -397,7 +393,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) }/* create device, set properties */ - qdev =qdev_create_from_info (bus, info); + qdev =qdev_create_from_info (bus, driver); id =qemu_opts_id (opts);if (id) { qdev->id = id;
Signature · 1 line
1.7.4.1
PATCH 7/23 qdev: kill off DeviceInfo list
In reply to Anthony LiguoriTeach the various bits of code that need to walk through available devices to do so via QOM.
--- hw/qdev.c | 87 +++++++++++++++++++++---------------------------------------- hw/qdev.h | 2 - 2 files changed, 30 insertions(+), 59 deletions(-)
hw/qdev.c +30 -57
@@ -38,8 +38,6 @@ static bool qdev_hot_removed = false;static BusState *main_system_bus;static void main_system_bus_create (void ); -DeviceInfo *device_info_list; -static BusState *qbus_find_recursive (BusState *bus,const char *name,const BusInfo *info);static BusState *qbus_find (const char *path);
@@ -125,7 +123,6 @@ static void qdev_do_register_subclass(DeviceInfo *info, const char *parent,TypeInfo type_info = {};assert (info->size >=sizeof (DeviceState)); -assert (!info->next); type_info.name = name; type_info.parent = parent;
@@ -142,40 +139,11 @@ void qdev_register_subclass(DeviceInfo *info, const char *parent)if (info->alias) {qdev_do_register_subclass (info, parent, info->alias); } - info->next = device_info_list; - device_info_list = info; -} - -void qdev_register (DeviceInfo *info) -{ -qdev_register_subclass (info,TYPE_DEVICE ); -} - -static DeviceInfo *qdev_find_info (BusInfo *bus_info,const char *name) -{ -DeviceInfo *info; - -/* first check device names */ -for (info = device_info_list; info !=NULL ; info = info->next) { -if (strcmp (info->name, name) !=0 ) -continue ; -return info; - } - -/* failing that check the aliases */ -for (info = device_info_list; info !=NULL ; info = info->next) { -if (!info->alias) -continue ; -if (strcmp (info->alias, name) !=0 ) -continue ; -return info; - } -return NULL ; }bool qdev_exists (const char *name) { -return !!qdev_find_info (NULL , name); +return !!object_class_by_name (name); } static void qdev_property_add_legacy(DeviceState *dev, Property *prop,
@@ -245,17 +213,28 @@ DeviceState *qdev_try_create(BusState *bus, const char *name)return qdev_create_from_info (bus, name); } -static void qdev_print_devinfo (DeviceInfo *info) +static void qdev_print_devinfo (ObjectClass *klass,void *opaque) { -error_printf ("name \"%s\", bus %s" , - info->name, info->bus_info->name); -if (info->alias) { -error_printf (", alias \"%s\"" , info->alias); +DeviceClass *dc; +bool *show_no_user = opaque; + + dc = (DeviceClass *)object_class_dynamic_cast (klass,TYPE_DEVICE ); + +if (!dc || (show_no_user && !*show_no_user && dc->no_user)) { +return ; } -if (info->desc) { -error_printf (", desc \"%s\"" , info->desc); + +error_printf ("name \"%s\"" ,object_class_get_name (klass)); +if (dc->bus_info) { +error_printf (", bus %s" , dc->bus_info->name); } -if (info->no_user) { +if (dc->alias) { +error_printf (", alias \"%s\"" , dc->alias); + } +if (dc->desc) { +error_printf (", desc \"%s\"" , dc->desc); + } +if (dc->no_user) {error_printf (", no-user" ); }error_printf ("\n" );
@@ -279,17 +258,14 @@ static int set_property(const char *name, const char *value, void *opaque)int qdev_device_help (QemuOpts *opts) {const char *driver; -DeviceInfo *info;Property *prop; +ObjectClass *klass; +DeviceClass *info; driver =qemu_opt_get (opts,"driver" );if (driver && !strcmp (driver,"?" )) { -for (info = device_info_list; info !=NULL ; info = info->next) { -if (info->no_user) { -continue ;/* not available, don't show */ - } -qdev_print_devinfo (info); - } +bool show_no_user = false; +object_class_foreach (qdev_print_devinfo, &show_no_user);return 1 ; }
@@ -297,10 +273,11 @@ int qdev_device_help(QemuOpts *opts)return 0 ; } - info =qdev_find_info (NULL , driver); -if (!info) { + klass =object_class_by_name (driver); +if (!klass) {return 0 ; } + info =DEVICE_CLASS (klass);for (prop = info->props; prop && prop->name; prop++) {/*
@@ -312,14 +289,14 @@ int qdev_device_help(QemuOpts *opts)if (!prop->info->parse) {continue ;/* no way to set it, don't show */ } -error_printf ("%s.%s=%s\n" , info->name, prop->name, +error_printf ("%s.%s=%s\n" , driver, prop->name, prop->info->legacy_name ?: prop->info->name); }for (prop = info->bus_info->props; prop && prop->name; prop++) {if (!prop->info->parse) {continue ;/* no way to set it, don't show */ } -error_printf ("%s.%s=%s\n" , info->name, prop->name, +error_printf ("%s.%s=%s\n" , driver, prop->name, prop->info->legacy_name ?: prop->info->name); }return 1 ;
@@ -1085,11 +1062,7 @@ void do_info_qtree(Monitor *mon)void do_info_qdm (Monitor *mon) { -DeviceInfo *info; - -for (info = device_info_list; info !=NULL ; info = info->next) { -qdev_print_devinfo (info); - } +object_class_foreach (qdev_print_devinfo,NULL ); }int do_device_add (Monitor *mon,const QDict *qdict,QObject **ret_data)
hw/qdev.h +0 -2
@@ -257,9 +257,7 @@ struct DeviceInfo {qdev_event unplug;qdev_event exit;BusInfo *bus_info; -struct DeviceInfo *next; }; -extern DeviceInfo *device_info_list;void qdev_register (DeviceInfo *info);void qdev_register_subclass (DeviceInfo *info,const char *parent);
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 07/23] qdev: kill off DeviceInfo list
Am 30.01.2012 22:08, schrieb Anthony Liguori:
Quoted 4 lines
Teach the various bits of code that need to walk through available devices to do so via QOM.
Signed-off-by Anthony Liguori
(Email missing.)
NACK. This introduces broken code, see below.
hw/qdev.c void qdev_register_subclass(DeviceInfo *info, const char *parent) · line 147
Quoted 5 lines
bool
qdev_exists(const char *name)
{hw/qdev.c +1
-1-return !!qdev_find_info (NULL , name); +return !!object_class_by_name (name); }
Minor nit: I'd find object_class_by_name(name) != NULL easier to read than double negation.
hw/qdev.c DeviceState *qdev_try_create(BusState *bus, const char *name) · line 219
Quoted 13 lines
hw/qdev.c +3
-5@@ -245,17 +213,28 @@ DeviceState *qdev_try_create(BusState *bus, const char *name)return qdev_create_from_info (bus, name); } -static void qdev_print_devinfo (DeviceInfo *info) +static void qdev_print_devinfo (ObjectClass *klass,void *opaque) { -error_printf ("name \"%s\", bus %s" , - info->name, info->bus_info->name); -if (info->alias) { -error_printf (", alias \"%s\"" , info->alias); +DeviceClass *dc; +bool *show_no_user = opaque;
Due to this...
hw/qdev.c DeviceState *qdev_try_create(BusState *bus, const char *name) · line 221
Quoted 2 lines
hw/qdev.c +2
-0+ + dc = (DeviceClass *)object_class_dynamic_cast (klass,TYPE_DEVICE );
...and this, ...
Quoted 31 lines
hw/qdev.c +16
-4+ +if (!dc || (show_no_user && !*show_no_user && dc->no_user)) { +return ; } -if (info->desc) { -error_printf (", desc \"%s\"" , info->desc); + +error_printf ("name \"%s\"" ,object_class_get_name (klass)); +if (dc->bus_info) { +error_printf (", bus %s" , dc->bus_info->name); } -if (info->no_user) { +if (dc->alias) { +error_printf (", alias \"%s\"" , dc->alias); + } +if (dc->desc) { +error_printf (", desc \"%s\"" , dc->desc); + } +if (dc->no_user) {error_printf (", no-user" ); }error_printf ("\n" );@@ -279,17 +258,14 @@ static int set_property(const char *name, const char *value, void *opaque)int qdev_device_help (QemuOpts *opts) {const char *driver; -DeviceInfo *info;Property *prop; +ObjectClass *klass; +DeviceClass *info;
hw/qdev.c static int set_property(const char *name, const char *value, void *opaque) · line 268
Quoted 10 lines
hw/qdev.c +2
-6driver =qemu_opt_get (opts,"driver" );if (driver && !strcmp (driver,"?" )) { -for (info = device_info_list; info !=NULL ; info = info->next) { -if (info->no_user) { -continue ;/* not available, don't show */ - } -qdev_print_devinfo (info); - } +bool show_no_user = false; +object_class_foreach (qdev_print_devinfo, &show_no_user);
This...
Quoted 35 lines
hw/qdev.c +5
-4return 1 ; }@@ -297,10 +273,11 @@ int qdev_device_help(QemuOpts *opts)return 0 ; } - info =qdev_find_info (NULL , driver); -if (!info) { + klass =object_class_by_name (driver); +if (!klass) {return 0 ; } + info =DEVICE_CLASS (klass);for (prop = info->props; prop && prop->name; prop++) {/* @@ -312,14 +289,14 @@ int qdev_device_help(QemuOpts *opts)if (!prop->info->parse) {continue ;/* no way to set it, don't show */ } -error_printf ("%s.%s=%s\n" , info->name, prop->name, +error_printf ("%s.%s=%s\n" , driver, prop->name, prop->info->legacy_name ?: prop->info->name); }for (prop = info->bus_info->props; prop && prop->name; prop++) {if (!prop->info->parse) {continue ;/* no way to set it, don't show */ } -error_printf ("%s.%s=%s\n" , info->name, prop->name, +error_printf ("%s.%s=%s\n" , driver, prop->name, prop->info->legacy_name ?: prop->info->name); }return 1 ;
hw/qdev.c void do_info_qtree(Monitor *mon) · line 1065
Quoted 9 lines
hw/qdev.c +1
-5@@ -1085,11 +1062,7 @@ void do_info_qtree(Monitor *mon)void do_info_qdm (Monitor *mon) { -DeviceInfo *info; - -for (info = device_info_list; info !=NULL ; info = info->next) { -qdev_print_devinfo (info); - } +object_class_foreach (qdev_print_devinfo,NULL );
...and this is broken, as pointed out before:
http://patchwork.ozlabs.org/patch/138396/
Easiest would be to reorder 11/23 before this one so that we don't introduce a broken, bloated user of foreach in the first place.
Otherwise looking good.
Andreas
Quoted 3 lines
hw/qdev.c +0
-0}int do_device_add (Monitor *mon,const QDict *qdict,QObject **ret_data)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 8/23 qdev: register all types natively through QEMU Object Model
In reply to Anthony LiguoriThis 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.
--- hw/9pfs/virtio-9p-device.c | 16 +++-- hw/a9mpcore.c | 40 +++++++------ hw/ac97.c | 18 +++--- hw/acpi_piix4.c | 20 ++++--- hw/ads7846.c | 11 ++-- hw/alpha_typhoon.c | 14 +++-- hw/apb_pci.c | 41 +++++++------ hw/apic.c | 10 ++- hw/apic_common.c | 15 ++--- hw/apic_internal.h | 1 - hw/applesmc.c | 28 +++++---- hw/arm11mpcore.c | 28 +++++---- hw/arm_l2x0.c | 24 +++++--- hw/arm_mptimer.c | 28 +++++---- hw/arm_sysctl.c | 18 +++--- hw/arm_timer.c | 35 ++++++----- hw/armv7m.c | 14 +++-- hw/armv7m_nvic.c | 32 ++++++----- hw/bitbang_i2c.c | 14 +++-- hw/bonito.c | 32 ++++++----- hw/ccid-card-emulated.c | 35 ++++++----- hw/ccid-card-passthru.c | 28 +++++---- hw/ccid.h | 1 - hw/cirrus_vga.c | 30 ++++++---- hw/container.c | 14 +++-- hw/cs4231.c | 18 +++--- hw/cs4231a.c | 30 ++++++---- hw/debugcon.c | 26 +++++---- hw/dec_pci.c | 40 +++++++------ hw/ds1225y.c | 16 +++-- hw/ds1338.c | 11 ++-- hw/e1000.c | 20 ++++--- hw/eccmemctl.c | 18 +++--- hw/eepro100.c | 83 ++++++++++++++------------ hw/empty_slot.c | 11 ++-- hw/es1370.c | 16 +++-- hw/escc.c | 18 +++--- hw/esp.c | 18 +++--- hw/etraxfs_eth.c | 14 +++-- hw/etraxfs_pic.c | 14 +++-- hw/etraxfs_ser.c | 14 +++-- hw/etraxfs_timer.c | 11 ++-- hw/fdc.c | 76 +++++++++++++----------- hw/fw_cfg.c | 20 ++++--- hw/g364fb.c | 20 ++++--- hw/grackle_pci.c | 26 +++++---- hw/grlib_apbuart.c | 14 +++-- hw/grlib_gptimer.c | 16 +++-- hw/grlib_irqmp.c | 16 +++-- hw/gt64xxx.c | 22 ++++--- hw/gus.c | 32 ++++++----- hw/hda-audio.c | 36 ++++++----- hw/highbank.c | 18 +++--- hw/hpet.c | 20 ++++--- hw/i2c.c | 21 +++---- hw/i2c.h | 3 - hw/i82374.c | 22 ++++--- hw/i82378.c | 22 ++++--- hw/i8254.c | 30 ++++++---- hw/i8259.c | 11 ++- hw/i8259_common.c | 13 +--- hw/i8259_internal.h | 1 - hw/ide/ahci.c | 24 +++++--- hw/ide/cmd646.c | 14 +++-- hw/ide/ich.c | 17 +++-- hw/ide/isa.c | 30 ++++++---- hw/ide/piix.c | 44 ++++++++------ hw/ide/qdev.c | 93 +++++++++++++++++------------- hw/ide/via.c | 14 +++-- hw/integratorcp.c | 25 +++++---- hw/intel-hda.c | 37 ++++++------ hw/intel-hda.h | 1 - hw/ioapic.c | 14 +++-- hw/ioapic_common.c | 10 +-- hw/ioapic_internal.h | 1 - hw/ioh3420.c | 20 ++++--- hw/isa-bus.c | 36 ++++++------ hw/isa.h | 2 - hw/ivshmem.c | 16 +++-- hw/kvm/apic.c | 5 +- hw/kvm/clock.c | 16 +++-- hw/kvm/i8259.c | 8 ++- hw/kvm/ioapic.c | 20 ++++--- hw/lan9118.c | 18 +++--- hw/lance.c | 20 ++++--- hw/lm32_juart.c | 16 +++-- hw/lm32_pic.c | 16 +++-- hw/lm32_sys.c | 18 +++--- hw/lm32_timer.c | 18 +++--- hw/lm32_uart.c | 16 +++-- hw/lm832x.c | 14 +++-- hw/lsi53c895a.c | 19 ++++--- hw/m48t59.c | 46 ++++++++------ hw/macio.c | 11 ++-- hw/marvell_88w8618_audio.c | 18 +++--- hw/max111x.c | 22 ++++--- hw/max7310.c | 16 +++-- hw/mc146818rtc.c | 26 +++++---- hw/milkymist-ac97.c | 16 +++-- hw/milkymist-hpdmc.c | 16 +++-- hw/milkymist-memcard.c | 16 +++-- hw/milkymist-minimac2.c | 18 +++--- hw/milkymist-pfpu.c | 16 +++-- hw/milkymist-softusb.c | 18 +++--- hw/milkymist-sysctl.c | 18 +++--- hw/milkymist-tmu2.c | 16 +++-- hw/milkymist-uart.c | 16 +++-- hw/milkymist-vgafb.c | 18 +++--- hw/mips_malta.c | 14 ++--- hw/mipsnet.c | 20 ++++--- hw/mpc8544_guts.c | 11 ++-- hw/mst_fpga.c | 16 +++-- hw/musicpal.c | 117 +++++++++++++++++++++---------------- hw/nand.c | 18 +++--- hw/ne2000-isa.c | 26 +++++---- hw/ne2000.c | 16 +++-- hw/omap_gpio.c | 32 ++++++----- hw/omap_intc.c | 32 ++++++----- hw/onenand.c | 16 +++-- hw/opencores_eth.c | 18 +++--- hw/parallel.c | 28 +++++---- hw/pc.c | 18 +++--- hw/pci.c | 21 +++---- hw/pci.h | 2 - hw/pckbd.c | 16 +++-- hw/pcnet-pci.c | 18 +++--- hw/piix4.c | 18 +++--- hw/piix_pci.c | 70 ++++++++++++---------- hw/pl011.c | 22 ++++--- hw/pl022.c | 11 ++-- hw/pl031.c | 16 +++-- hw/pl041.c | 20 ++++--- hw/pl050.c | 28 +++++---- hw/pl061.c | 28 +++++---- hw/pl080.c | 32 ++++++----- hw/pl110.c | 48 +++++++++------- hw/pl181.c | 18 +++--- hw/pl190.c | 18 +++--- hw/ppc4xx_pci.c | 28 +++++---- hw/ppc_prep.c | 2 +- hw/ppce500_pci.c | 28 +++++---- hw/ppce500_spin.c | 11 ++-- hw/prep_pci.c | 26 +++++---- hw/pxa2xx.c | 56 ++++++++++-------- hw/pxa2xx_dma.c | 18 +++--- hw/pxa2xx_gpio.c | 16 +++-- hw/pxa2xx_pic.c | 16 +++-- hw/pxa2xx_timer.c | 36 ++++++----- hw/qdev.h | 1 - hw/qxl.c | 40 +++++++------ hw/realview.c | 11 ++-- hw/realview_gic.c | 11 ++-- hw/rtl8139.c | 18 +++--- hw/s390-virtio-bus.c | 138 ++++++++++++++++++++++---------------------- hw/s390-virtio-bus.h | 19 ++++++- hw/sb16.c | 34 ++++++----- hw/sbi.c | 16 +++-- hw/scsi-bus.c | 19 +++--- hw/scsi-disk.c | 116 +++++++++++++++++++++---------------- hw/scsi-generic.c | 28 +++++---- hw/scsi.h | 1 - hw/serial.c | 30 ++++++---- hw/sga.c | 14 +++-- hw/sh_pci.c | 22 ++++--- hw/slavio_intctl.c | 16 +++-- hw/slavio_misc.c | 27 +++++---- hw/slavio_timer.c | 18 +++--- hw/smbus.c | 6 -- hw/smbus.h | 2 - hw/smbus_eeprom.c | 22 ++++--- hw/smc91c111.c | 18 +++--- hw/spapr_llan.c | 14 +++-- hw/spapr_pci.c | 22 ++++--- hw/spapr_vio.c | 35 ++++++------ hw/spapr_vio.h | 1 - hw/spapr_vscsi.c | 14 +++-- hw/spapr_vty.c | 14 +++-- hw/sparc32_dma.c | 18 +++--- hw/spitz.c | 60 +++++++++++-------- hw/ssd0303.c | 14 +++-- hw/ssd0323.c | 11 ++-- hw/ssi-sd.c | 11 ++-- hw/ssi.c | 24 ++++++-- hw/ssi.h | 2 - hw/stellaris.c | 44 ++++++++------ hw/stellaris_enet.c | 14 +++-- hw/strongarm.c | 98 +++++++++++++++++-------------- hw/sun4c_intctl.c | 16 +++-- hw/sun4m.c | 50 +++++++++------- hw/sun4m_iommu.c | 18 +++--- hw/sun4u.c | 39 +++++++------ hw/sysbus.c | 22 +++----- hw/sysbus.h | 4 - hw/tcx.c | 18 +++--- hw/tmp105.c | 14 +++-- hw/tosa.c | 24 ++++---- hw/tusb6010.c | 14 +++-- hw/twl92230.c | 14 +++-- hw/unin_pci.c | 74 +++++++++++++----------- hw/usb-audio.c | 29 ++++++---- hw/usb-bt.c | 14 +++-- hw/usb-bus.c | 19 +++--- hw/usb-ccid.c | 43 ++++++++------ hw/usb-ehci.c | 32 ++++++----- hw/usb-hid.c | 42 ++++++++------ hw/usb-hub.c | 18 +++--- hw/usb-msd.c | 30 ++++++---- hw/usb-net.c | 26 +++++---- hw/usb-ohci.c | 42 ++++++++------ hw/usb-serial.c | 48 +++++++++------ hw/usb-uhci.c | 96 +++++++++++++++++------------- hw/usb-wacom.c | 20 ++++--- hw/usb-xhci.c | 25 +++++---- hw/usb.h | 1 - hw/versatile_pci.c | 33 ++++++----- hw/versatilepb.c | 16 +++-- hw/vga-isa.c | 16 +++-- hw/vga-pci.c | 14 +++-- hw/virtio-console.c | 28 +++++---- hw/virtio-pci.c | 76 ++++++++++++++---------- hw/virtio-serial-bus.c | 19 +++--- hw/virtio-serial.h | 6 -- hw/vmmouse.c | 28 +++++---- hw/vmport.c | 14 +++-- hw/vmware_vga.c | 16 +++-- hw/vt82c686.c | 64 +++++++++++--------- hw/wdt_i6300esb.c | 16 +++-- hw/wdt_ib700.c | 16 +++-- hw/wm8750.c | 14 +++-- hw/xen_platform.c | 18 +++--- hw/xgmac.c | 25 +++++--- hw/xilinx_axidma.c | 14 +++-- hw/xilinx_axienet.c | 14 +++-- hw/xilinx_ethlite.c | 14 +++-- hw/xilinx_intc.c | 14 +++-- hw/xilinx_timer.c | 14 +++-- hw/xilinx_uartlite.c | 11 ++-- hw/xio3130_downstream.c | 20 ++++--- hw/xio3130_upstream.c | 20 ++++--- hw/z2.c | 28 +++++---- hw/zaurus.c | 18 +++--- usb-linux.c | 34 ++++++----- 242 files changed, 3169 insertions(+), 2544 deletions(-)
hw/9pfs/virtio-9p-device.c +9 -7
@@ -174,6 +174,7 @@ static Property virtio_9p_properties[] = {static void virtio_9p_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = virtio_9p_init_pci;
@@ -181,19 +182,20 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data) k->device_id =0x1009 ; k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =0x2 ; + dc->props = virtio_9p_properties; + dc->reset = virtio_pci_reset; } -static DeviceInfo virtio_9p_info = { - .name ="virtio-9p-pci" , - .size =sizeof (VirtIOPCIProxy), - .props = virtio_9p_properties, - .class_init = virtio_9p_class_init, - .reset = virtio_pci_reset, +static TypeInfo virtio_9p_info = { + .name ="virtio-9p-pci" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (VirtIOPCIProxy), + .class_init = virtio_9p_class_init, };static void virtio_9p_register_devices (void ) { -pci_qdev_register (&virtio_9p_info); +type_register_static (&virtio_9p_info);virtio_9p_set_fd_limit (); }
hw/a9mpcore.c +22 -18
@@ -208,35 +208,39 @@ static const VMStateDescription vmstate_a9mp_priv = { } }; +static Property a9mp_priv_properties[] = { +DEFINE_PROP_UINT32 ("num-cpu" , a9mp_priv_state, num_cpu,1 ), +/* The Cortex-A9MP may have anything from 0 to 224 external interrupt +* IRQ lines (with another 32 internal). We default to 64+32, which +* is the number provided by the Cortex-A9MP test chip in the +* Realview PBX-A9 and Versatile Express A9 development boards. +* Other boards may differ and should set this property appropriately. +*/ +DEFINE_PROP_UINT32 ("num-irq" , a9mp_priv_state, num_irq,96 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void a9mp_priv_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = a9mp_priv_init; + dc->props = a9mp_priv_properties; + dc->vmsd = &vmstate_a9mp_priv; + dc->reset = a9mp_priv_reset; } -static DeviceInfo a9mp_priv_info = { - .name ="a9mpcore_priv" , - .size =sizeof (a9mp_priv_state), - .vmsd = &vmstate_a9mp_priv, - .reset = a9mp_priv_reset, - .class_init = a9mp_priv_class_init, - .props = (Property []) { -DEFINE_PROP_UINT32 ("num-cpu" , a9mp_priv_state, num_cpu,1 ), -/* The Cortex-A9MP may have anything from 0 to 224 external interrupt -* IRQ lines (with another 32 internal). We default to 64+32, which -* is the number provided by the Cortex-A9MP test chip in the -* Realview PBX-A9 and Versatile Express A9 development boards. -* Other boards may differ and should set this property appropriately. -*/ -DEFINE_PROP_UINT32 ("num-irq" , a9mp_priv_state, num_irq,96 ), -DEFINE_PROP_END_OF_LIST (), - } +static TypeInfo a9mp_priv_info = { + .name ="a9mpcore_priv" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (a9mp_priv_state), + .class_init = a9mp_priv_class_init, };static void a9mp_register_devices (void ) { -sysbus_register_withprop (&a9mp_priv_info); +type_register_static (&a9mp_priv_info); }device_init (a9mp_register_devices)
hw/ac97.c +10 -8
@@ -1351,6 +1351,7 @@ static Property ac97_properties[] = {static void ac97_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = ac97_initfn;
@@ -1359,20 +1360,21 @@ static void ac97_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_INTEL_82801AA_5 ; k->revision =0x01 ; k->class_id =PCI_CLASS_MULTIMEDIA_AUDIO ; + dc->desc ="Intel 82801AA AC97 Audio" ; + dc->vmsd = &vmstate_ac97; + dc->props = ac97_properties; } -static DeviceInfo ac97_info = { - .name ="AC97" , - .desc ="Intel 82801AA AC97 Audio" , - .size =sizeof (AC97LinkState), - .vmsd = &vmstate_ac97, - .props = ac97_properties, - .class_init = ac97_class_init, +static TypeInfo ac97_info = { + .name ="AC97" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (AC97LinkState), + .class_init = ac97_class_init, };static void ac97_register (void ) { -pci_qdev_register (&ac97_info); +type_register_static (&ac97_info); }device_init (ac97_register);
hw/acpi_piix4.c +11 -9
@@ -403,6 +403,7 @@ static Property piix4_pm_properties[] = {static void piix4_pm_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->no_hotplug =1 ;
@@ -412,21 +413,22 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_INTEL_82371AB_3 ; k->revision =0x03 ; k->class_id =PCI_CLASS_BRIDGE_OTHER ; + dc->desc ="PM" ; + dc->no_user =1 ; + dc->vmsd = &vmstate_acpi; + dc->props = piix4_pm_properties; } -static DeviceInfo piix4_pm_info = { - .name ="PIIX4_PM" , - .desc ="PM" , - .size =sizeof (PIIX4PMState), - .vmsd = &vmstate_acpi, - .no_user =1 , - .props = piix4_pm_properties, - .class_init = piix4_pm_class_init, +static TypeInfo piix4_pm_info = { + .name ="PIIX4_PM" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PIIX4PMState), + .class_init = piix4_pm_class_init, };static void piix4_pm_register (void ) { -pci_qdev_register (&piix4_pm_info); +type_register_static (&piix4_pm_info); }device_init (piix4_pm_register);
hw/ads7846.c +6 -5
@@ -161,15 +161,16 @@ static void ads7846_class_init(ObjectClass *klass, void *data) k->transfer = ads7846_transfer; } -static DeviceInfo ads7846_info = { - .name ="ads7846" , - .size =sizeof (ADS7846State), - .class_init = ads7846_class_init, +static TypeInfo ads7846_info = { + .name ="ads7846" , + .parent =TYPE_SSI_SLAVE , + .instance_size =sizeof (ADS7846State), + .class_init = ads7846_class_init, };static void ads7846_register_devices (void ) { -ssi_register_slave (&ads7846_info); +type_register_static (&ads7846_info); }device_init (ads7846_register_devices)
hw/alpha_typhoon.c +8 -6
@@ -810,20 +810,22 @@ static int typhoon_pcihost_init(SysBusDevice *dev)static void typhoon_pcihost_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = typhoon_pcihost_init; + dc->no_user =1 ; } -static DeviceInfo typhoon_pcihost_info = { - .name ="typhoon-pcihost" , - .size =sizeof (TyphoonState), - .no_user =1 , - .class_init = typhoon_pcihost_class_init, +static TypeInfo typhoon_pcihost_info = { + .name ="typhoon-pcihost" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (TyphoonState), + .class_init = typhoon_pcihost_class_init, };static void typhoon_register (void ) { -sysbus_register_withprop (&typhoon_pcihost_info); +type_register_static (&typhoon_pcihost_info); }device_init (typhoon_register);
hw/apb_pci.c +23 -18
72 lines not on this page · raw message
hw/apic.c +6 -4
@@ -774,14 +774,16 @@ static void apic_class_init(ObjectClass *klass, void *data) k->post_load = apic_post_load; } -static DeviceInfo apic_info = { - .name ="apic" , - .class_init = apic_class_init, +static TypeInfo apic_info = { + .name ="apic" , + .instance_size =sizeof (APICCommonState), + .parent =TYPE_APIC_COMMON , + .class_init = apic_class_init, };static void apic_register_devices (void ) { -apic_qdev_register (&apic_info); +type_register_static (&apic_info); }device_init (apic_register_devices)
hw/apic_common.c +5 -10
@@ -295,7 +295,12 @@ static Property apic_properties_common[] = {static void apic_common_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *sc =SYS_BUS_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + dc->vmsd = &vmstate_apic_common; + dc->reset = apic_reset_common; + dc->no_user =1 ; + dc->props = apic_properties_common; sc->init = apic_init_common; }
@@ -308,16 +313,6 @@ static TypeInfo apic_common_type = { .abstract = true, }; -void apic_qdev_register (DeviceInfo *info) -{ - info->size =sizeof (APICCommonState), - info->vmsd = &vmstate_apic_common; - info->reset = apic_reset_common; - info->no_user =1 ; - info->props = apic_properties_common; -sysbus_qdev_register_subclass (info,TYPE_APIC_COMMON ); -} -static void register_devices (void ) {type_register_static (&apic_common_type);
hw/apic_internal.h +0 -1
@@ -117,7 +117,6 @@ struct APICCommonState { };void apic_report_irq_delivered (int delivered); -void apic_qdev_register (DeviceInfo *info);bool apic_next_timer (APICCommonState *s,int64_t current_time);#endif /* !QEMU_APIC_INTERNAL_H */
hw/applesmc.c +16 -12
@@ -220,28 +220,32 @@ static int applesmc_isa_init(ISADevice *dev)return 0 ; } +static Property applesmc_isa_properties[] = { + DEFINE_PROP_HEX32("iobase", struct AppleSMCStatus, iobase, +APPLESMC_DEFAULT_IOBASE ), + DEFINE_PROP_STRING("osk", struct AppleSMCStatus, osk), +DEFINE_PROP_END_OF_LIST (), +}; +static void qdev_applesmc_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = applesmc_isa_init; + dc->reset = qdev_applesmc_isa_reset; + dc->props = applesmc_isa_properties; } -static DeviceInfo applesmc_isa_info = { - .name ="isa-applesmc" , - .size =sizeof (struct AppleSMCStatus ), - .reset = qdev_applesmc_isa_reset, - .class_init = qdev_applesmc_class_init, - .props = (Property []) { - DEFINE_PROP_HEX32("iobase", struct AppleSMCStatus, iobase, -APPLESMC_DEFAULT_IOBASE ), - DEFINE_PROP_STRING("osk", struct AppleSMCStatus, osk), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo applesmc_isa_info = { + .name ="isa-applesmc" , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (struct AppleSMCStatus ), + .class_init = qdev_applesmc_class_init, };static void applesmc_register_devices (void ) { -isa_qdev_register (&applesmc_isa_info); +type_register_static (&applesmc_isa_info); }device_init (applesmc_register_devices)
hw/arm11mpcore.c +16 -12
@@ -217,16 +217,18 @@ static Property mpcore_rirq_properties[] = {static void mpcore_rirq_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = realview_mpcore_init; + dc->props = mpcore_rirq_properties; } -static DeviceInfo mpcore_rirq_info = { - .name ="realview_mpcore" , - .size =sizeof (mpcore_rirq_state), - .props = mpcore_rirq_properties, - .class_init = mpcore_rirq_class_init, +static TypeInfo mpcore_rirq_info = { + .name ="realview_mpcore" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (mpcore_rirq_state), + .class_init = mpcore_rirq_class_init, };static Property mpcore_priv_properties[] = {
@@ -236,22 +238,24 @@ static Property mpcore_priv_properties[] = {static void mpcore_priv_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = mpcore_priv_init; + dc->props = mpcore_priv_properties; } -static DeviceInfo mpcore_priv_info = { - .name ="arm11mpcore_priv" , - .size =sizeof (mpcore_priv_state), - .props = mpcore_priv_properties, - .class_init = mpcore_priv_class_init, +static TypeInfo mpcore_priv_info = { + .name ="arm11mpcore_priv" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (mpcore_priv_state), + .class_init = mpcore_priv_class_init, };static void arm11mpcore_register_devices (void ) { -sysbus_register_withprop (&mpcore_rirq_info); -sysbus_register_withprop (&mpcore_priv_info); +type_register_static (&mpcore_rirq_info); +type_register_static (&mpcore_priv_info); }device_init (arm11mpcore_register_devices)
hw/arm_l2x0.c +14 -10
@@ -160,29 +160,33 @@ static int l2x0_priv_init(SysBusDevice *dev)return 0 ; } +static Property l2x0_properties[] = { +DEFINE_PROP_UINT32 ("type" , l2x0_state, cache_type,0x1c100100 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void l2x0_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->init = l2x0_priv_init; + dc->vmsd = &vmstate_l2x0; + dc->no_user =1 ; + dc->props = l2x0_properties; + dc->reset = l2x0_priv_reset; } -static DeviceInfo l2x0_info = { +static TypeInfo l2x0_info = { .name ="l2x0" , - .size =sizeof (l2x0_state), - .vmsd = &vmstate_l2x0, - .no_user =1 , - .props = (Property []) { -DEFINE_PROP_UINT32 ("type" , l2x0_state, cache_type,0x1c100100 ), -DEFINE_PROP_END_OF_LIST (), - }, - .reset = l2x0_priv_reset, + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (l2x0_state), .class_init = l2x0_class_init, };static void l2x0_register_device (void ) { -sysbus_qdev_register (&l2x0_info); +type_register_static (&l2x0_info); }device_init (l2x0_register_device)
hw/arm_mptimer.c +16 -12
@@ -311,29 +311,33 @@ static const VMStateDescription vmstate_arm_mptimer = { } }; +static Property arm_mptimer_properties[] = { +DEFINE_PROP_UINT32 ("num-cpu" , arm_mptimer_state, num_cpu,0 ), +DEFINE_PROP_END_OF_LIST () +}; +static void arm_mptimer_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *sbc =SYS_BUS_DEVICE_CLASS (klass); sbc->init = arm_mptimer_init; + dc->vmsd = &vmstate_arm_mptimer; + dc->reset = arm_mptimer_reset; + dc->no_user =1 ; + dc->props = arm_mptimer_properties; } -static DeviceInfo arm_mptimer_info = { - .name ="arm_mptimer" , - .size =sizeof (arm_mptimer_state), - .vmsd = &vmstate_arm_mptimer, - .reset = arm_mptimer_reset, - .no_user =1 , - .class_init = arm_mptimer_class_init, - .props = (Property []) { -DEFINE_PROP_UINT32 ("num-cpu" , arm_mptimer_state, num_cpu,0 ), -DEFINE_PROP_END_OF_LIST () - } +static TypeInfo arm_mptimer_info = { + .name ="arm_mptimer" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (arm_mptimer_state), + .class_init = arm_mptimer_class_init, };static void arm_mptimer_register_devices (void ) { -sysbus_register_withprop (&arm_mptimer_info); +type_register_static (&arm_mptimer_info); }device_init (arm_mptimer_register_devices)
hw/arm_sysctl.c +10 -8
@@ -409,23 +409,25 @@ static Property arm_sysctl_properties[] = {static void arm_sysctl_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = arm_sysctl_init1; + dc->reset = arm_sysctl_reset; + dc->vmsd = &vmstate_arm_sysctl; + dc->props = arm_sysctl_properties; } -static DeviceInfo arm_sysctl_info = { - .name ="realview_sysctl" , - .size =sizeof (arm_sysctl_state), - .vmsd = &vmstate_arm_sysctl, - .reset = arm_sysctl_reset, - .props = arm_sysctl_properties, - .class_init = arm_sysctl_class_init, +static TypeInfo arm_sysctl_info = { + .name ="realview_sysctl" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (arm_sysctl_state), + .class_init = arm_sysctl_class_init, };static void arm_sysctl_register_devices (void ) { -sysbus_register_withprop (&arm_sysctl_info); +type_register_static (&arm_sysctl_info); }device_init (arm_sysctl_register_devices)
hw/arm_timer.c +20 -15
@@ -354,34 +354,39 @@ static void icp_pit_class_init(ObjectClass *klass, void *data) sdc->init = icp_pit_init; } -static DeviceInfo icp_pit_info = { - .name ="integrator_pit" , - .size =sizeof (icp_pit_state), - .class_init = icp_pit_class_init, +static TypeInfo icp_pit_info = { + .name ="integrator_pit" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (icp_pit_state), + .class_init = icp_pit_class_init, +}; + +static Property sp804_properties[] = { +DEFINE_PROP_UINT32 ("freq0" , sp804_state, freq0,1000000 ), +DEFINE_PROP_UINT32 ("freq1" , sp804_state, freq1,1000000 ), +DEFINE_PROP_END_OF_LIST (), };static void sp804_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *sdc =SYS_BUS_DEVICE_CLASS (klass); +DeviceClass *k =DEVICE_CLASS (klass); sdc->init = sp804_init; + k->props = sp804_properties; } -static DeviceInfo sp804_info = { - .name ="sp804" , - .size =sizeof (sp804_state), - .class_init = sp804_class_init, - .props = (Property []) { -DEFINE_PROP_UINT32 ("freq0" , sp804_state, freq0,1000000 ), -DEFINE_PROP_UINT32 ("freq1" , sp804_state, freq1,1000000 ), -DEFINE_PROP_END_OF_LIST (), - } +static TypeInfo sp804_info = { + .name ="sp804" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (sp804_state), + .class_init = sp804_class_init, };static void arm_timer_register_devices (void ) { -sysbus_qdev_register (&icp_pit_info); -sysbus_qdev_register (&sp804_info); +type_register_static (&icp_pit_info); +type_register_static (&sp804_info); }device_init (arm_timer_register_devices)
hw/armv7m.c +8 -6
@@ -252,21 +252,23 @@ static Property bitband_properties[] = {static void bitband_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = bitband_init; + dc->props = bitband_properties; } -static DeviceInfo bitband_info = { - .name ="ARM,bitband-memory" , - .size =sizeof (BitBandState), - .props = bitband_properties, - .class_init = bitband_class_init, +static TypeInfo bitband_info = { + .name ="ARM,bitband-memory" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (BitBandState), + .class_init = bitband_class_init, };static void armv7m_register_devices (void ) { -sysbus_register_withprop (&bitband_info); +type_register_static (&bitband_info); }device_init (armv7m_register_devices)
hw/armv7m_nvic.c +18 -14
@@ -391,31 +391,35 @@ static int armv7m_nvic_init(SysBusDevice *dev)return 0 ; } +static Property armv7m_nvic_properties[] = { +/* The ARM v7m may have anything from 0 to 496 external interrupt +* IRQ lines. We default to 64. Other boards may differ and should +* set this property appropriately. +*/ +DEFINE_PROP_UINT32 ("num-irq" , nvic_state, num_irq,64 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void armv7m_nvic_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *sdc =SYS_BUS_DEVICE_CLASS (klass); sdc->init = armv7m_nvic_init; + dc->vmsd = &vmstate_nvic; + dc->props = armv7m_nvic_properties; } -static DeviceInfo armv7m_nvic_priv_info = { - .name ="armv7m_nvic" , - .size =sizeof (nvic_state), - .vmsd = &vmstate_nvic, - .class_init = armv7m_nvic_class_init, - .props = (Property []) { -/* The ARM v7m may have anything from 0 to 496 external interrupt -* IRQ lines. We default to 64. Other boards may differ and should -* set this property appropriately. -*/ -DEFINE_PROP_UINT32 ("num-irq" , nvic_state, num_irq,64 ), -DEFINE_PROP_END_OF_LIST (), - } +static TypeInfo armv7m_nvic_info = { + .name ="armv7m_nvic" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (nvic_state), + .class_init = armv7m_nvic_class_init, };static void armv7m_nvic_register_devices (void ) { -sysbus_qdev_register (&armv7m_nvic_priv_info); +type_register_static (&armv7m_nvic_info); }device_init (armv7m_nvic_register_devices)
hw/bitbang_i2c.c +8 -6
@@ -223,21 +223,23 @@ static int gpio_i2c_init(SysBusDevice *dev)static void gpio_i2c_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = gpio_i2c_init; + dc->desc ="Virtual GPIO to I2C bridge" ; } -static DeviceInfo gpio_i2c_info = { - .name ="gpio_i2c" , - .desc ="Virtual GPIO to I2C bridge" , - .size =sizeof (GPIOI2CState), - .class_init = gpio_i2c_class_init, +static TypeInfo gpio_i2c_info = { + .name ="gpio_i2c" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (GPIOI2CState), + .class_init = gpio_i2c_class_init, };static void bitbang_i2c_register (void ) { -sysbus_register_withprop (&gpio_i2c_info); +type_register_static (&gpio_i2c_info); }device_init (bitbang_i2c_register)
hw/bonito.c +18 -14
@@ -768,6 +768,7 @@ PCIBus *bonito_init(qemu_irq *pic)static void bonito_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = bonito_initfn;
@@ -775,34 +776,37 @@ static void bonito_class_init(ObjectClass *klass, void *data) k->device_id =0x00d5 ; k->revision =0x01 ; k->class_id =PCI_CLASS_BRIDGE_HOST ; + dc->desc ="Host bridge" ; + dc->no_user =1 ; + dc->vmsd = &vmstate_bonito; } -static DeviceInfo bonito_info = { - .name ="Bonito" , - .desc ="Host bridge" , - .size =sizeof (PCIBonitoState), - .vmsd = &vmstate_bonito, - .no_user =1 , - .class_init = bonito_class_init, +static TypeInfo bonito_info = { + .name ="Bonito" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIBonitoState), + .class_init = bonito_class_init, };static void bonito_pcihost_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = bonito_pcihost_initfn; + dc->no_user =1 ; } -static DeviceInfo bonito_pcihost_info = { - .name ="Bonito-pcihost" , - .size =sizeof (BonitoState), - .no_user =1 , - .class_init = bonito_pcihost_class_init, +static TypeInfo bonito_pcihost_info = { + .name ="Bonito-pcihost" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (BonitoState), + .class_init = bonito_pcihost_class_init, };static void bonito_register (void ) { -sysbus_register_withprop (&bonito_pcihost_info); -pci_qdev_register (&bonito_info); +type_register_static (&bonito_pcihost_info); +type_register_static (&bonito_info); }device_init (bonito_register);
hw/ccid-card-emulated.c +19 -16
@@ -564,36 +564,39 @@ static int emulated_exitfn(CCIDCardState *base)return 0 ; } +static Property emulated_card_properties[] = { +DEFINE_PROP_STRING ("backend" , EmulatedState, backend_str), +DEFINE_PROP_STRING ("cert1" , EmulatedState, cert1), +DEFINE_PROP_STRING ("cert2" , EmulatedState, cert2), +DEFINE_PROP_STRING ("cert3" , EmulatedState, cert3), +DEFINE_PROP_STRING ("db" , EmulatedState, db), +DEFINE_PROP_UINT8 ("debug" , EmulatedState, debug,0 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void emulated_class_initfn (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);CCIDCardClass *cc =CCID_CARD_CLASS (klass); cc->initfn = emulated_initfn; cc->exitfn = emulated_exitfn; cc->get_atr = emulated_get_atr; cc->apdu_from_guest = emulated_apdu_from_guest; + dc->desc ="emulated smartcard" ; + dc->props = emulated_card_properties; } -static DeviceInfo emulated_card_info = { - .name =EMULATED_DEV_NAME , - .desc ="emulated smartcard" , - .size =sizeof (EmulatedState), - .unplug = qdev_simple_unplug_cb, - .class_init = emulated_class_initfn, - .props = (Property []) { -DEFINE_PROP_STRING ("backend" , EmulatedState, backend_str), -DEFINE_PROP_STRING ("cert1" , EmulatedState, cert1), -DEFINE_PROP_STRING ("cert2" , EmulatedState, cert2), -DEFINE_PROP_STRING ("cert3" , EmulatedState, cert3), -DEFINE_PROP_STRING ("db" , EmulatedState, db), -DEFINE_PROP_UINT8 ("debug" , EmulatedState, debug,0 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo emulated_card_info = { + .name =EMULATED_DEV_NAME , + .parent =TYPE_CCID_CARD , + .instance_size =sizeof (EmulatedState), + .class_init = emulated_class_initfn, };static void ccid_card_emulated_register_devices (void ) { -ccid_card_qdev_register (&emulated_card_info); +type_register_static (&emulated_card_info); }device_init (ccid_card_emulated_register_devices)
hw/ccid-card-passthru.c +16 -12
@@ -316,32 +316,36 @@ static VMStateDescription passthru_vmstate = { } }; +static Property passthru_card_properties[] = { +DEFINE_PROP_CHR ("chardev" , PassthruState, cs), +DEFINE_PROP_UINT8 ("debug" , PassthruState, debug,0 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void passthru_class_initfn (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);CCIDCardClass *cc =CCID_CARD_CLASS (klass); cc->initfn = passthru_initfn; cc->exitfn = passthru_exitfn; cc->get_atr = passthru_get_atr; cc->apdu_from_guest = passthru_apdu_from_guest; + dc->desc ="passthrough smartcard" ; + dc->vmsd = &passthru_vmstate; + dc->props = passthru_card_properties; } -static DeviceInfo passthru_card_info = { - .name =PASSTHRU_DEV_NAME , - .desc ="passthrough smartcard" , - .size =sizeof (PassthruState), - .vmsd = &passthru_vmstate, - .class_init = passthru_class_initfn, - .props = (Property []) { -DEFINE_PROP_CHR ("chardev" , PassthruState, cs), -DEFINE_PROP_UINT8 ("debug" , PassthruState, debug,0 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo passthru_card_info = { + .name =PASSTHRU_DEV_NAME , + .parent =TYPE_CCID_CARD , + .instance_size =sizeof (PassthruState), + .class_init = passthru_class_initfn, };static void ccid_card_passthru_register_devices (void ) { -ccid_card_qdev_register (&passthru_card_info); +type_register_static (&passthru_card_info); }device_init (ccid_card_passthru_register_devices)
hw/ccid.h +0 -1
@@ -54,7 +54,6 @@ void ccid_card_send_apdu_to_guest(CCIDCardState *card,void ccid_card_card_removed (CCIDCardState *card);void ccid_card_card_inserted (CCIDCardState *card);void ccid_card_card_error (CCIDCardState *card,uint64_t error); -void ccid_card_qdev_register (DeviceInfo *card);/* * support guest visible insertion/removal of ccid devices based on actual
hw/cirrus_vga.c +17 -13
@@ -2901,20 +2901,22 @@ static int vga_initfn(ISADevice *dev)static void isa_cirrus_vga_class_init (ObjectClass *klass,void *data) {ISADeviceClass *k =ISA_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); - k->init = vga_initfn; + dc->vmsd = &vmstate_cirrus_vga; + k->init = vga_initfn; } -static DeviceInfo isa_cirrus_vga_info = { - .name ="isa-cirrus-vga" , - .size =sizeof (ISACirrusVGAState), - .vmsd = &vmstate_cirrus_vga, +static TypeInfo isa_cirrus_vga_info = { + .name ="isa-cirrus-vga" , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISACirrusVGAState), .class_init = isa_cirrus_vga_class_init, };static void isa_cirrus_vga_register (void ) { -isa_qdev_register (&isa_cirrus_vga_info); +type_register_static (&isa_cirrus_vga_info); }device_init (isa_cirrus_vga_register)
@@ -2965,6 +2967,7 @@ DeviceState *pci_cirrus_vga_init(PCIBus *bus)static void cirrus_vga_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->no_hotplug =1 ;
@@ -2973,18 +2976,19 @@ static void cirrus_vga_class_init(ObjectClass *klass, void *data) k->vendor_id =PCI_VENDOR_ID_CIRRUS ; k->device_id =CIRRUS_ID_CLGD5446 ; k->class_id =PCI_CLASS_DISPLAY_VGA ; + dc->desc ="Cirrus CLGD 54xx VGA" ; + dc->vmsd = &vmstate_pci_cirrus_vga; } -static DeviceInfo cirrus_vga_info = { - .name ="cirrus-vga" , - .desc ="Cirrus CLGD 54xx VGA" , - .size =sizeof (PCICirrusVGAState), - .vmsd = &vmstate_pci_cirrus_vga, - .class_init = cirrus_vga_class_init, +static TypeInfo cirrus_vga_info = { + .name ="cirrus-vga" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCICirrusVGAState), + .class_init = cirrus_vga_class_init, };static void cirrus_vga_register (void ) { -pci_qdev_register (&cirrus_vga_info); +type_register_static (&cirrus_vga_info); }device_init (cirrus_vga_register);
hw/container.c +8 -6
@@ -7,21 +7,23 @@ static int container_initfn(SysBusDevice *dev)static void container_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = container_initfn; + dc->no_user =1 ; } -static DeviceInfo container_info = { - .name ="container" , - .size =sizeof (SysBusDevice), - .no_user =1 , - .class_init = container_class_init, +static TypeInfo container_info = { + .name ="container" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SysBusDevice), + .class_init = container_class_init, };static void container_init (void ) { -sysbus_register_withprop (&container_info); +type_register_static (&container_info); }device_init (container_init);
hw/cs4231.c +10 -8
@@ -157,23 +157,25 @@ static Property cs4231_properties[] = {static void cs4231_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = cs4231_init1; + dc->reset = cs_reset; + dc->vmsd = &vmstate_cs4231; + dc->props = cs4231_properties; } -static DeviceInfo cs4231_info = { - .name ="SUNW,CS4231" , - .size =sizeof (CSState), - .vmsd = &vmstate_cs4231, - .reset = cs_reset, - .props = cs4231_properties, - .class_init = cs4231_class_init, +static TypeInfo cs4231_info = { + .name ="SUNW,CS4231" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (CSState), + .class_init = cs4231_class_init, };static void cs4231_register_devices (void ) { -sysbus_register_withprop (&cs4231_info); +type_register_static (&cs4231_info); }device_init (cs4231_register_devices)
hw/cs4231a.c +17 -13
@@ -665,28 +665,32 @@ int cs4231a_init (ISABus *bus)return 0 ; } +static Property cs4231a_properties[] = { +DEFINE_PROP_HEX32 ("iobase" , CSState, port,0x534 ), +DEFINE_PROP_UINT32 ("irq" , CSState, irq,9 ), +DEFINE_PROP_UINT32 ("dma" , CSState, dma,3 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void cs4231a_class_initfn (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = cs4231a_initfn; + dc->desc ="Crystal Semiconductor CS4231A" ; + dc->vmsd = &vmstate_cs4231a; + dc->props = cs4231a_properties; } -static DeviceInfo cs4231a_info = { - .name ="cs4231a" , - .desc ="Crystal Semiconductor CS4231A" , - .size =sizeof (CSState), - .vmsd = &vmstate_cs4231a, - .class_init = cs4231a_class_initfn, - .props = (Property []) { -DEFINE_PROP_HEX32 ("iobase" , CSState, port,0x534 ), -DEFINE_PROP_UINT32 ("irq" , CSState, irq,9 ), -DEFINE_PROP_UINT32 ("dma" , CSState, dma,3 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo cs4231a_info = { + .name ="cs4231a" , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (CSState), + .class_init = cs4231a_class_initfn, };static void cs4231a_register (void ) { -isa_qdev_register (&cs4231a_info); +type_register_static (&cs4231a_info); }device_init (cs4231a_register)
hw/debugcon.c +15 -11
@@ -87,27 +87,31 @@ static int debugcon_isa_initfn(ISADevice *dev)return 0 ; } +static Property debugcon_isa_properties[] = { +DEFINE_PROP_HEX32 ("iobase" , ISADebugconState, iobase,0xe9 ), +DEFINE_PROP_CHR ("chardev" , ISADebugconState, state.chr), +DEFINE_PROP_HEX32 ("readback" , ISADebugconState, state.readback,0xe9 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void debugcon_isa_class_initfn (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = debugcon_isa_initfn; + dc->props = debugcon_isa_properties; } -static DeviceInfo debugcon_isa_info = { - .name ="isa-debugcon" , - .size =sizeof (ISADebugconState), - .class_init = debugcon_isa_class_initfn, - .props = (Property []) { -DEFINE_PROP_HEX32 ("iobase" , ISADebugconState, iobase,0xe9 ), -DEFINE_PROP_CHR ("chardev" , ISADebugconState, state.chr), -DEFINE_PROP_HEX32 ("readback" , ISADebugconState, state.readback,0xe9 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo debugcon_isa_info = { + .name ="isa-debugcon" , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISADebugconState), + .class_init = debugcon_isa_class_initfn, };static void debugcon_register_devices (void ) { -isa_qdev_register (&debugcon_isa_info); +type_register_static (&debugcon_isa_info); }device_init (debugcon_register_devices)
hw/dec_pci.c +22 -18
@@ -52,6 +52,7 @@ static int dec_map_irq(PCIDevice *pci_dev, int irq_num)static void dec_21154_pci_bridge_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = pci_bridge_initfn;
@@ -60,15 +61,16 @@ static void dec_21154_pci_bridge_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_DEC_21154 ; k->config_write = pci_bridge_write_config; k->is_bridge =1 ; + dc->desc ="DEC 21154 PCI-PCI bridge" ; + dc->reset = pci_bridge_reset; + dc->vmsd = &vmstate_pci_device; } -static DeviceInfo dec_21154_pci_bridge_info = { - .name ="dec-21154-p2p-bridge" , - .desc ="DEC 21154 PCI-PCI bridge" , - .size =sizeof (PCIBridge), - .vmsd = &vmstate_pci_device, - .reset = pci_bridge_reset, - .class_init = dec_21154_pci_bridge_class_init, +static TypeInfo dec_21154_pci_bridge_info = { + .name ="dec-21154-p2p-bridge" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIBridge), + .class_init = dec_21154_pci_bridge_class_init, };PCIBus *pci_dec_21154_init (PCIBus *parent_bus,int devfn)
@@ -117,10 +119,11 @@ static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data) k->is_bridge =1 ; } -static DeviceInfo dec_21154_pci_host_info = { - .name ="dec-21154" , - .size =sizeof (PCIDevice), - .class_init = dec_21154_pci_host_class_init, +static TypeInfo dec_21154_pci_host_info = { + .name ="dec-21154" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIDevice), + .class_init = dec_21154_pci_host_class_init, };static void pci_dec_21154_device_class_init (ObjectClass *klass,void *data)
@@ -130,17 +133,18 @@ static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data) sdc->init = pci_dec_21154_device_init; } -static DeviceInfo pci_dec_21154_device_info = { - .name ="dec-21154-sysbus" , - .size =sizeof (DECState), - .class_init = pci_dec_21154_device_class_init, +static TypeInfo pci_dec_21154_device_info = { + .name ="dec-21154-sysbus" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (DECState), + .class_init = pci_dec_21154_device_class_init, };static void dec_register_devices (void ) { -sysbus_qdev_register (&pci_dec_21154_device_info); -pci_qdev_register (&dec_21154_pci_host_info); -pci_qdev_register (&dec_21154_pci_bridge_info); +type_register_static (&pci_dec_21154_device_info); +type_register_static (&dec_21154_pci_host_info); +type_register_static (&dec_21154_pci_bridge_info); }device_init (dec_register_devices)
hw/ds1225y.c +9 -7
@@ -142,22 +142,24 @@ static Property nvram_sysbus_properties[] = {static void nvram_sysbus_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = nvram_sysbus_initfn; + dc->vmsd = &vmstate_nvram; + dc->props = nvram_sysbus_properties; } -static DeviceInfo nvram_sysbus_info = { - .name ="ds1225y" , - .size =sizeof (SysBusNvRamState), - .vmsd = &vmstate_nvram, - .props = nvram_sysbus_properties, - .class_init = nvram_sysbus_class_init, +static TypeInfo nvram_sysbus_info = { + .name ="ds1225y" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SysBusNvRamState), + .class_init = nvram_sysbus_class_init, };static void nvram_register (void ) { -sysbus_register_withprop (&nvram_sysbus_info); +type_register_static (&nvram_sysbus_info); }device_init (nvram_register)
hw/ds1338.c +6 -5
@@ -128,15 +128,16 @@ static void ds1338_class_init(ObjectClass *klass, void *data) k->send = ds1338_send; } -static DeviceInfo ds1338_info = { - .name ="ds1338" , - .size =sizeof (DS1338State), - .class_init = ds1338_class_init, +static TypeInfo ds1338_info = { + .name ="ds1338" , + .parent =TYPE_I2C_SLAVE , + .instance_size =sizeof (DS1338State), + .class_init = ds1338_class_init, };static void ds1338_register_devices (void ) { -i2c_register_slave (&ds1338_info); +type_register_static (&ds1338_info); }device_init (ds1338_register_devices)
hw/e1000.c +11 -9
@@ -1204,6 +1204,7 @@ static Property e1000_properties[] = {static void e1000_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = pci_e1000_init;
@@ -1213,21 +1214,22 @@ static void e1000_class_init(ObjectClass *klass, void *data) k->device_id =E1000_DEVID ; k->revision =0x03 ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ; + dc->desc ="Intel Gigabit Ethernet" ; + dc->reset = qdev_e1000_reset; + dc->vmsd = &vmstate_e1000; + dc->props = e1000_properties; } -static DeviceInfo e1000_info = { - .name ="e1000" , - .desc ="Intel Gigabit Ethernet" , - .size =sizeof (E1000State), - .reset = qdev_e1000_reset, - .vmsd = &vmstate_e1000, - .props = e1000_properties, - .class_init = e1000_class_init, +static TypeInfo e1000_info = { + .name ="e1000" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (E1000State), + .class_init = e1000_class_init, };static void e1000_register_devices (void ) { -pci_qdev_register (&e1000_info); +type_register_static (&e1000_info); }device_init (e1000_register_devices)
hw/eccmemctl.c +10 -8
@@ -315,24 +315,26 @@ static Property ecc_properties[] = {static void ecc_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = ecc_init1; + dc->reset = ecc_reset; + dc->vmsd = &vmstate_ecc; + dc->props = ecc_properties; } -static DeviceInfo ecc_info = { - .name ="eccmemctl" , - .size =sizeof (ECCState), - .vmsd = &vmstate_ecc, - .reset = ecc_reset, - .props = ecc_properties, - .class_init = ecc_class_init, +static TypeInfo ecc_info = { + .name ="eccmemctl" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (ECCState), + .class_init = ecc_class_init, };static void ecc_register_devices (void ) { -sysbus_register_withprop (&ecc_info); +type_register_static (&ecc_info); }device_init (ecc_register_devices)
hw/eepro100.c +44 -39
195 lines not on this page · raw message
hw/empty_slot.c +6 -5
@@ -83,15 +83,16 @@ static void empty_slot_class_init(ObjectClass *klass, void *data) k->init = empty_slot_init1; } -static DeviceInfo empty_slot_info = { - .name ="empty_slot" , - .size =sizeof (EmptySlot), - .class_init = empty_slot_class_init, +static TypeInfo empty_slot_info = { + .name ="empty_slot" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (EmptySlot), + .class_init = empty_slot_class_init, };static void empty_slot_register_devices (void ) { -sysbus_register_withprop (&empty_slot_info); +type_register_static (&empty_slot_info); }device_init (empty_slot_register_devices);
hw/es1370.c +9 -7
@@ -1033,6 +1033,7 @@ int es1370_init (PCIBus *bus)static void es1370_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = es1370_initfn;
@@ -1042,19 +1043,20 @@ static void es1370_class_init(ObjectClass *klass, void *data) k->class_id =PCI_CLASS_MULTIMEDIA_AUDIO ; k->subsystem_vendor_id =0x4942 ; k->subsystem_id =0x4c4c ; + dc->desc ="ENSONIQ AudioPCI ES1370" ; + dc->vmsd = &vmstate_es1370; } -static DeviceInfo es1370_info = { - .name ="ES1370" , - .desc ="ENSONIQ AudioPCI ES1370" , - .size =sizeof (ES1370State), - .vmsd = &vmstate_es1370, - .class_init = es1370_class_init, +static TypeInfo es1370_info = { + .name ="ES1370" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (ES1370State), + .class_init = es1370_class_init, };static void es1370_register (void ) { -pci_qdev_register (&es1370_info); +type_register_static (&es1370_info); }device_init (es1370_register);
hw/escc.c +10 -8
@@ -915,23 +915,25 @@ static Property escc_properties[] = {static void escc_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = escc_init1; + dc->reset = escc_reset; + dc->vmsd = &vmstate_escc; + dc->props = escc_properties; } -static DeviceInfo escc_info = { - .name ="escc" , - .size =sizeof (SerialState), - .vmsd = &vmstate_escc, - .reset = escc_reset, - .props = escc_properties, - .class_init = escc_class_init, +static TypeInfo escc_info = { + .name ="escc" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SerialState), + .class_init = escc_class_init, };static void escc_register_devices (void ) { -sysbus_register_withprop (&escc_info); +type_register_static (&escc_info); }device_init (escc_register_devices)
hw/esp.c +10 -8
@@ -759,23 +759,25 @@ static Property esp_properties[] = {static void esp_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = esp_init1; + dc->reset = esp_hard_reset; + dc->vmsd = &vmstate_esp; + dc->props = esp_properties; } -static DeviceInfo esp_info = { - .name ="esp" , - .size =sizeof (ESPState), - .vmsd = &vmstate_esp, - .reset = esp_hard_reset, - .props = esp_properties, - .class_init = esp_class_init, +static TypeInfo esp_info = { + .name ="esp" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (ESPState), + .class_init = esp_class_init, };static void esp_register_devices (void ) { -sysbus_register_withprop (&esp_info); +type_register_static (&esp_info); }device_init (esp_register_devices)
hw/etraxfs_eth.c +8 -6
@@ -623,21 +623,23 @@ static Property etraxfs_eth_properties[] = {static void etraxfs_eth_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = fs_eth_init; + dc->props = etraxfs_eth_properties; } -static DeviceInfo etraxfs_eth_info = { - .name ="etraxfs-eth" , - .size =sizeof (struct fs_eth ), - .props = etraxfs_eth_properties, - .class_init = etraxfs_eth_class_init, +static TypeInfo etraxfs_eth_info = { + .name ="etraxfs-eth" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (struct fs_eth ), + .class_init = etraxfs_eth_class_init, };static void etraxfs_eth_register (void ) { -sysbus_register_withprop (&etraxfs_eth_info); +type_register_static (&etraxfs_eth_info); }device_init (etraxfs_eth_register)
hw/etraxfs_pic.c +8 -6
@@ -158,21 +158,23 @@ static Property etraxfs_pic_properties[] = {static void etraxfs_pic_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = etraxfs_pic_init; + dc->props = etraxfs_pic_properties; } -static DeviceInfo etraxfs_pic_info = { - .name ="etraxfs,pic" , - .size =sizeof (struct etrax_pic ), - .props = etraxfs_pic_properties, - .class_init = etraxfs_pic_class_init, +static TypeInfo etraxfs_pic_info = { + .name ="etraxfs,pic" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (struct etrax_pic ), + .class_init = etraxfs_pic_class_init, };static void etraxfs_pic_register (void ) { -sysbus_register_withprop (&etraxfs_pic_info); +type_register_static (&etraxfs_pic_info); }device_init (etraxfs_pic_register)
hw/etraxfs_ser.c +8 -6
@@ -226,21 +226,23 @@ static int etraxfs_ser_init(SysBusDevice *dev)static void etraxfs_ser_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = etraxfs_ser_init; + dc->reset = etraxfs_ser_reset; } -static DeviceInfo etraxfs_ser_info = { - .name ="etraxfs,serial" , - .size =sizeof (struct etrax_serial ), - .reset = etraxfs_ser_reset, - .class_init = etraxfs_ser_class_init, +static TypeInfo etraxfs_ser_info = { + .name ="etraxfs,serial" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (struct etrax_serial ), + .class_init = etraxfs_ser_class_init, };static void etraxfs_serial_register (void ) { -sysbus_register_withprop (&etraxfs_ser_info); +type_register_static (&etraxfs_ser_info); }device_init (etraxfs_serial_register)
hw/etraxfs_timer.c +6 -5
@@ -336,15 +336,16 @@ static void etraxfs_timer_class_init(ObjectClass *klass, void *data) sdc->init = etraxfs_timer_init; } -static DeviceInfo etraxfs_timer_info = { - .name ="etraxfs,timer" , - .size =sizeof (struct etrax_timer ), - .class_init = etraxfs_timer_class_init, +static TypeInfo etraxfs_timer_info = { + .name ="etraxfs,timer" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (struct etrax_timer ), + .class_init = etraxfs_timer_class_init, };static void etraxfs_timer_register (void ) { -sysbus_qdev_register (&etraxfs_timer_info); +type_register_static (&etraxfs_timer_info); }device_init (etraxfs_timer_register)
hw/fdc.c +42 -34
112 lines not on this page · raw message
hw/fw_cfg.c +11 -9
@@ -539,24 +539,26 @@ static Property fw_cfg_properties[] = {static void fw_cfg_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = fw_cfg_init1; + dc->no_user =1 ; + dc->reset = fw_cfg_reset; + dc->vmsd = &vmstate_fw_cfg; + dc->props = fw_cfg_properties; } -static DeviceInfo fw_cfg_info = { - .name ="fw_cfg" , - .size =sizeof (FWCfgState), - .vmsd = &vmstate_fw_cfg, - .reset = fw_cfg_reset, - .no_user =1 , - .props = fw_cfg_properties, - .class_init = fw_cfg_class_init, +static TypeInfo fw_cfg_info = { + .name ="fw_cfg" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (FWCfgState), + .class_init = fw_cfg_class_init, };static void fw_cfg_register_devices (void ) { -sysbus_register_withprop (&fw_cfg_info); +type_register_static (&fw_cfg_info); }device_init (fw_cfg_register_devices)
hw/g364fb.c +11 -9
@@ -556,24 +556,26 @@ static Property g364fb_sysbus_properties[] = {static void g364fb_sysbus_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = g364fb_sysbus_init; + dc->desc ="G364 framebuffer" ; + dc->reset = g364fb_sysbus_reset; + dc->vmsd = &vmstate_g364fb; + dc->props = g364fb_sysbus_properties; } -static DeviceInfo g364fb_sysbus_info = { - .name ="sysbus-g364" , - .desc ="G364 framebuffer" , - .size =sizeof (G364SysBusState), - .vmsd = &vmstate_g364fb, - .reset = g364fb_sysbus_reset, - .props = g364fb_sysbus_properties, - .class_init = g364fb_sysbus_class_init, +static TypeInfo g364fb_sysbus_info = { + .name ="sysbus-g364" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (G364SysBusState), + .class_init = g364fb_sysbus_class_init, };static void g364fb_register (void ) { -sysbus_register_withprop (&g364fb_sysbus_info); +type_register_static (&g364fb_sysbus_info); }device_init (g364fb_register);
hw/grackle_pci.c +15 -11
@@ -124,39 +124,43 @@ static int grackle_pci_host_init(PCIDevice *d)static void grackle_pci_class_init (ObjectClass *klass,void *data) {PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->init = grackle_pci_host_init; k->vendor_id =PCI_VENDOR_ID_MOTOROLA ; k->device_id =PCI_DEVICE_ID_MOTOROLA_MPC106 ; k->revision =0x00 ; k->class_id =PCI_CLASS_BRIDGE_HOST ; + dc->no_user =1 ; } -static DeviceInfo grackle_pci_info = { - .name ="grackle" , - .size =sizeof (PCIDevice), - .no_user =1 , +static TypeInfo grackle_pci_info = { + .name ="grackle" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIDevice), .class_init = grackle_pci_class_init, };static void pci_grackle_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->init = pci_grackle_init_device; + dc->no_user =1 ; } -static DeviceInfo grackle_pci_host_info = { - .name ="grackle-pcihost" , - .size =sizeof (GrackleState), - .no_user =1 , - .class_init = pci_grackle_class_init, +static TypeInfo grackle_pci_host_info = { + .name ="grackle-pcihost" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (GrackleState), + .class_init = pci_grackle_class_init, };static void grackle_register_devices (void ) { -sysbus_qdev_register (&grackle_pci_host_info); -pci_qdev_register (&grackle_pci_info); +type_register_static (&grackle_pci_info); +type_register_static (&grackle_pci_host_info); }device_init (grackle_register_devices)
hw/grlib_apbuart.c +8 -6
@@ -177,21 +177,23 @@ static Property grlib_gptimer_properties[] = {static void grlib_gptimer_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = grlib_apbuart_init; + dc->props = grlib_gptimer_properties; } -static DeviceInfo grlib_gptimer_info = { - .name ="grlib,apbuart" , - .size =sizeof (UART ), - .props = grlib_gptimer_properties, - .class_init = grlib_gptimer_class_init, +static TypeInfo grlib_gptimer_info = { + .name ="grlib,apbuart" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (UART ), + .class_init = grlib_gptimer_class_init, };static void grlib_gptimer_register (void ) { -sysbus_register_withprop (&grlib_gptimer_info); +type_register_static (&grlib_gptimer_info); }device_init (grlib_gptimer_register)
hw/grlib_gptimer.c +9 -7
@@ -381,22 +381,24 @@ static Property grlib_gptimer_properties[] = {static void grlib_gptimer_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = grlib_gptimer_init; + dc->reset = grlib_gptimer_reset; + dc->props = grlib_gptimer_properties; } -static DeviceInfo grlib_gptimer_info = { - .name ="grlib,gptimer" , - .reset = grlib_gptimer_reset, - .size =sizeof (GPTimerUnit), - .props = grlib_gptimer_properties, - .class_init = grlib_gptimer_class_init, +static TypeInfo grlib_gptimer_info = { + .name ="grlib,gptimer" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (GPTimerUnit), + .class_init = grlib_gptimer_class_init, };static void grlib_gptimer_register (void ) { -sysbus_register_withprop (&grlib_gptimer_info); +type_register_static (&grlib_gptimer_info); }device_init (grlib_gptimer_register)
hw/grlib_irqmp.c +9 -7
@@ -362,22 +362,24 @@ static Property grlib_irqmp_properties[] = {static void grlib_irqmp_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = grlib_irqmp_init; + dc->reset = grlib_irqmp_reset; + dc->props = grlib_irqmp_properties; } -static DeviceInfo grlib_irqmp_info = { - .name ="grlib,irqmp" , - .reset = grlib_irqmp_reset, - .size =sizeof (IRQMP ), - .props = grlib_irqmp_properties, - .class_init = grlib_irqmp_class_init, +static TypeInfo grlib_irqmp_info = { + .name ="grlib,irqmp" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (IRQMP ), + .class_init = grlib_irqmp_class_init, };static void grlib_irqmp_register (void ) { -sysbus_register_withprop (&grlib_irqmp_info); +type_register_static (&grlib_irqmp_info); }device_init (grlib_irqmp_register)
hw/gt64xxx.c +12 -10
@@ -1147,10 +1147,11 @@ static void gt64120_pci_class_init(ObjectClass *klass, void *data) k->class_id =PCI_CLASS_BRIDGE_HOST ; } -static DeviceInfo gt64120_pci_info = { - .name ="gt64120_pci" , - .size =sizeof (PCIDevice), - .class_init = gt64120_pci_class_init, +static TypeInfo gt64120_pci_info = { + .name ="gt64120_pci" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIDevice), + .class_init = gt64120_pci_class_init, };static void gt64120_class_init (ObjectClass *klass,void *data)
@@ -1160,16 +1161,17 @@ static void gt64120_class_init(ObjectClass *klass, void *data) sdc->init = gt64120_init; } -static DeviceInfo gt64120_info = { - .name ="gt64120" , - .size =sizeof (GT64120State), - .class_init = gt64120_class_init, +static TypeInfo gt64120_info = { + .name ="gt64120" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (GT64120State), + .class_init = gt64120_class_init, };static void gt64120_pci_register_devices (void ) { -sysbus_qdev_register (>64120_info); -pci_qdev_register (>64120_pci_info); +type_register_static (>64120_info); +type_register_static (>64120_pci_info); }device_init (gt64120_pci_register_devices)
hw/gus.c +18 -14
@@ -299,29 +299,33 @@ int GUS_init (ISABus *bus)return 0 ; } +static Property gus_properties[] = { +DEFINE_PROP_UINT32 ("freq" , GUSState, freq,44100 ), +DEFINE_PROP_HEX32 ("iobase" , GUSState, port,0x240 ), +DEFINE_PROP_UINT32 ("irq" , GUSState, emu.gusirq,7 ), +DEFINE_PROP_UINT32 ("dma" , GUSState, emu.gusdma,3 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void gus_class_initfn (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = gus_initfn; + dc->desc ="Gravis Ultrasound GF1" ; + dc->vmsd = &vmstate_gus; + dc->props = gus_properties; } -static DeviceInfo gus_info = { - .name ="gus" , - .desc ="Gravis Ultrasound GF1" , - .size =sizeof (GUSState), - .vmsd = &vmstate_gus, - .class_init = gus_class_initfn, - .props = (Property []) { -DEFINE_PROP_UINT32 ("freq" , GUSState, freq,44100 ), -DEFINE_PROP_HEX32 ("iobase" , GUSState, port,0x240 ), -DEFINE_PROP_UINT32 ("irq" , GUSState, emu.gusirq,7 ), -DEFINE_PROP_UINT32 ("dma" , GUSState, emu.gusdma,3 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo gus_info = { + .name ="gus" , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (GUSState), + .class_init = gus_class_initfn, };static void gus_register (void ) { -isa_qdev_register (&gus_info); +type_register_static (&gus_info); }device_init (gus_register)
hw/hda-audio.c +20 -16
@@ -908,45 +908,49 @@ static int hda_audio_init_duplex(HDACodecDevice *hda)static void hda_audio_output_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);HDACodecDeviceClass *k =HDA_CODEC_DEVICE_CLASS (klass); k->init = hda_audio_init_output; k->exit = hda_audio_exit; k->command = hda_audio_command; k->stream = hda_audio_stream; + dc->desc ="HDA Audio Codec, output-only" ; + dc->vmsd = &vmstate_hda_audio; + dc->props = hda_audio_properties; } -static DeviceInfo hda_audio_output_info = { - .name ="hda-output" , - .desc ="HDA Audio Codec, output-only" , - .size =sizeof (HDAAudioState), - .vmsd = &vmstate_hda_audio, - .props = hda_audio_properties, - .class_init = hda_audio_output_class_init, +static TypeInfo hda_audio_output_info = { + .name ="hda-output" , + .parent =TYPE_HDA_CODEC_DEVICE , + .instance_size =sizeof (HDAAudioState), + .class_init = hda_audio_output_class_init, };static void hda_audio_duplex_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);HDACodecDeviceClass *k =HDA_CODEC_DEVICE_CLASS (klass); k->init = hda_audio_init_duplex; k->exit = hda_audio_exit; k->command = hda_audio_command; k->stream = hda_audio_stream; + dc->desc ="HDA Audio Codec, duplex" ; + dc->vmsd = &vmstate_hda_audio; + dc->props = hda_audio_properties; } -static DeviceInfo hda_audio_duplex_info = { - .name ="hda-duplex" , - .desc ="HDA Audio Codec, duplex" , - .size =sizeof (HDAAudioState), - .vmsd = &vmstate_hda_audio, - .props = hda_audio_properties, - .class_init = hda_audio_duplex_class_init, +static TypeInfo hda_audio_duplex_info = { + .name ="hda-duplex" , + .parent =TYPE_HDA_CODEC_DEVICE , + .instance_size =sizeof (HDAAudioState), + .class_init = hda_audio_duplex_class_init, };static void hda_audio_register (void ) { -hda_codec_register (&hda_audio_output_info); -hda_codec_register (&hda_audio_duplex_info); +type_register_static (&hda_audio_output_info); +type_register_static (&hda_audio_duplex_info); }device_init (hda_audio_register);
hw/highbank.c +10 -8
@@ -162,22 +162,24 @@ static int highbank_regs_init(SysBusDevice *dev)static void highbank_regs_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *sbc =SYS_BUS_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); sbc->init = highbank_regs_init; + dc->desc ="Calxeda Highbank registers" ; + dc->vmsd = &vmstate_highbank_regs; + dc->reset = highbank_regs_reset; } -static DeviceInfo highbank_regs_info = { - .name ="highbank-regs" , - .desc ="Calxeda Highbank registers" , - .size =sizeof (HighbankRegsState), - .vmsd = &vmstate_highbank_regs, - .class_init = highbank_regs_class_init, - .reset = highbank_regs_reset, +static TypeInfo highbank_regs_info = { + .name ="highbank-regs" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (HighbankRegsState), + .class_init = highbank_regs_class_init, };static void highbank_regs_register_device (void ) { -sysbus_qdev_register (&highbank_regs_info); +type_register_static (&highbank_regs_info); }device_init (highbank_regs_register_device)
hw/hpet.c +11 -9
@@ -703,24 +703,26 @@ static Property hpet_device_properties[] = {static void hpet_device_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = hpet_init; + dc->no_user =1 ; + dc->reset = hpet_reset; + dc->vmsd = &vmstate_hpet; + dc->props = hpet_device_properties; } -static DeviceInfo hpet_device_info = { - .name ="hpet" , - .size =sizeof (HPETState), - .no_user =1 , - .vmsd = &vmstate_hpet, - .reset = hpet_reset, - .props = hpet_device_properties, - .class_init = hpet_device_class_init, +static TypeInfo hpet_device_info = { + .name ="hpet" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (HPETState), + .class_init = hpet_device_class_init, };static void hpet_register_device (void ) { -sysbus_register_withprop (&hpet_device_info); +type_register_static (&hpet_device_info); }device_init (hpet_register_device)
hw/i2c.c +8 -13
@@ -204,19 +204,6 @@ static int i2c_slave_qdev_init(DeviceState *dev, DeviceInfo *base)return sc->init (s); } -void i2c_register_slave_subclass (DeviceInfo *info,const char *parent) -{ -assert (info->size >=sizeof (I2CSlave)); - info->init = i2c_slave_qdev_init; - info->bus_info = &i2c_bus_info; -qdev_register_subclass (info, parent); -} - -void i2c_register_slave (DeviceInfo *info) -{ -i2c_register_slave_subclass (info,TYPE_I2C_SLAVE ); -} -DeviceState *i2c_create_slave (i2c_bus *bus,const char *name,uint8_t addr) {DeviceState *dev;
@@ -227,12 +214,20 @@ DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr)return dev; } +static void i2c_slave_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *k =DEVICE_CLASS (klass); + k->init = i2c_slave_qdev_init; + k->bus_info = &i2c_bus_info; +} +static TypeInfo i2c_slave_type_info = { .name =TYPE_I2C_SLAVE , .parent =TYPE_DEVICE , .instance_size =sizeof (I2CSlave), .abstract = true, .class_size =sizeof (I2CSlaveClass), + .class_init = i2c_slave_class_init, };static void i2c_slave_register_devices (void )
hw/i2c.h +0 -3
@@ -62,9 +62,6 @@ int i2c_recv(i2c_bus *bus);#define I2C_SLAVE_FROM_QDEV (dev) DO_UPCAST(I2CSlave, qdev, dev)#define FROM_I2C_SLAVE (type, dev) DO_UPCAST(type, i2c, dev) -void i2c_register_slave (DeviceInfo *type); -void i2c_register_slave_subclass (DeviceInfo *info,const char *parent); -DeviceState *i2c_create_slave (i2c_bus *bus,const char *name,uint8_t addr);/* wm8750.c */
hw/i82374.c +13 -9
@@ -135,27 +135,31 @@ static int i82374_isa_init(ISADevice *dev)return 0 ; } +static Property i82374_properties[] = { +DEFINE_PROP_HEX32 ("iobase" , ISAi82374State, iobase,0x400 ), +DEFINE_PROP_END_OF_LIST () +}; +static void i82374_class_init (ObjectClass *klass,void *data) {ISADeviceClass *k =ISA_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); - k->init = i82374_isa_init; + k->init = i82374_isa_init; + dc->vmsd = &vmstate_isa_i82374; + dc->props = i82374_properties; } -static DeviceInfo i82374_isa_info = { +static TypeInfo i82374_isa_info = { .name ="i82374" , - .size =sizeof (ISAi82374State), - .vmsd = &vmstate_isa_i82374, + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISAi82374State), .class_init = i82374_class_init, - .props = (Property []) { -DEFINE_PROP_HEX32 ("iobase" , ISAi82374State, iobase,0x400 ), -DEFINE_PROP_END_OF_LIST () - }, };static void i82374_register_devices (void ) { -isa_qdev_register (&i82374_isa_info); +type_register_static (&i82374_isa_info); }device_init (i82374_register_devices)
hw/i82378.c +13 -9
@@ -238,9 +238,16 @@ static int pci_i82378_init(PCIDevice *dev)return 0 ; } +static Property i82378_properties[] = { +DEFINE_PROP_HEX32 ("iobase" , PCIi82378State, isa_io_base,0x80000000 ), +DEFINE_PROP_HEX32 ("membase" , PCIi82378State, isa_mem_base,0xc0000000 ), +DEFINE_PROP_END_OF_LIST () +}; +static void pci_i82378_class_init (ObjectClass *klass,void *data) {PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->init = pci_i82378_init; k->vendor_id =PCI_VENDOR_ID_INTEL ;
@@ -249,23 +256,20 @@ static void pci_i82378_class_init(ObjectClass *klass, void *data) k->class_id =PCI_CLASS_BRIDGE_ISA ; k->subsystem_vendor_id =0x0 ; k->subsystem_id =0x0 ; + dc->vmsd = &vmstate_pci_i82378; + dc->props = i82378_properties; } -static DeviceInfo pci_i82378_info = { +static TypeInfo pci_i82378_info = { .name ="i82378" , - .size =sizeof (PCIi82378State), - .vmsd = &vmstate_pci_i82378, + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIi82378State), .class_init = pci_i82378_class_init, - .props = (Property []) { -DEFINE_PROP_HEX32 ("iobase" , PCIi82378State, isa_io_base,0x80000000 ), -DEFINE_PROP_HEX32 ("membase" , PCIi82378State, isa_mem_base,0xc0000000 ), -DEFINE_PROP_END_OF_LIST () - }, };static void i82378_register_devices (void ) { -pci_qdev_register (&pci_i82378_info); +type_register_static (&pci_i82378_info); }device_init (i82378_register_devices)
hw/i8254.c +17 -13
@@ -535,28 +535,32 @@ static int pit_initfn(ISADevice *dev)return 0 ; } +static Property pit_properties[] = { +DEFINE_PROP_UINT32 ("irq" , PITState, irq,-1 ), +DEFINE_PROP_HEX32 ("iobase" , PITState, iobase,-1 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void pit_class_initfn (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = pit_initfn; + dc->no_user =1 ; + dc->reset = pit_reset; + dc->vmsd = &vmstate_pit; + dc->props = pit_properties; } -static DeviceInfo pit_info = { - .name ="isa-pit" , - .size =sizeof (PITState), - .vmsd = &vmstate_pit, - .reset = pit_reset, - .no_user =1 , - .class_init = pit_class_initfn, - .props = (Property []) { -DEFINE_PROP_UINT32 ("irq" , PITState, irq,-1 ), -DEFINE_PROP_HEX32 ("iobase" , PITState, iobase,-1 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo pit_info = { + .name ="isa-pit" , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (PITState), + .class_init = pit_class_initfn, };static void pit_register (void ) { -isa_qdev_register (&pit_info); +type_register_static (&pit_info); }device_init (pit_register)
hw/i8259.c +7 -4
@@ -475,19 +475,22 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)static void i8259_class_init (ObjectClass *klass,void *data) {PICCommonClass *k =PIC_COMMON_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->init = pic_init; + dc->reset = pic_reset; } -static DeviceInfo i8259_info = { - .name ="isa-i8259" , - .reset = pic_reset, +static TypeInfo i8259_info = { + .name ="isa-i8259" , + .instance_size =sizeof (PICCommonState), + .parent =TYPE_PIC_COMMON , .class_init = i8259_class_init, };static void pic_register (void ) { -pic_qdev_register (&i8259_info); +type_register_static (&i8259_info); }device_init (pic_register)
hw/i8259_common.c +4 -9
@@ -133,19 +133,14 @@ static Property pic_properties_common[] = { DEFINE_PROP_END_OF_LIST(), }; -void pic_qdev_register (DeviceInfo *info) -{ - info->size =sizeof (PICCommonState); - info->vmsd = &vmstate_pic_common; - info->no_user =1 ; - info->props = pic_properties_common; -isa_qdev_register_subclass (info,TYPE_PIC_COMMON ); -} -static void pic_common_class_init (ObjectClass *klass,void *data) {ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + dc->vmsd = &vmstate_pic_common; + dc->no_user =1 ; + dc->props = pic_properties_common; ic->init = pic_init_common; }
hw/i8259_internal.h +0 -1
@@ -78,6 +78,5 @@ void pic_reset_common(PICCommonState *s);ISADevice *i8259_init_chip (const char *name,ISABus *bus,bool master); -void pic_qdev_register (DeviceInfo *info);#endif /* !QEMU_I8259_INTERNAL_H */
hw/ide/ahci.c +14 -10
@@ -1239,27 +1239,31 @@ static int sysbus_ahci_init(SysBusDevice *dev)return 0 ; } +static Property sysbus_ahci_properties[] = { +DEFINE_PROP_UINT32 ("num-ports" , SysbusAHCIState, num_ports,1 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void sysbus_ahci_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *sbc =SYS_BUS_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); sbc->init = sysbus_ahci_init; + dc->vmsd = &vmstate_sysbus_ahci; + dc->props = sysbus_ahci_properties; } -static DeviceInfo sysbus_ahci_info = { - .name ="sysbus-ahci" , - .size =sizeof (SysbusAHCIState), - .vmsd = &vmstate_sysbus_ahci, - .class_init = sysbus_ahci_class_init, - .props = (Property []) { -DEFINE_PROP_UINT32 ("num-ports" , SysbusAHCIState, num_ports,1 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo sysbus_ahci_info = { + .name ="sysbus-ahci" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SysbusAHCIState), + .class_init = sysbus_ahci_class_init, };static void sysbus_ahci_register (void ) { -sysbus_qdev_register (&sysbus_ahci_info); +type_register_static (&sysbus_ahci_info); }device_init (sysbus_ahci_register);
hw/ide/cmd646.c +8 -6
@@ -332,6 +332,7 @@ static Property cmd646_ide_properties[] = {static void cmd646_ide_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = pci_cmd646_ide_initfn;
@@ -340,17 +341,18 @@ static void cmd646_ide_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_CMD_646 ; k->revision =0x07 ; k->class_id =PCI_CLASS_STORAGE_IDE ; + dc->props = cmd646_ide_properties; } -static DeviceInfo cmd646_ide_info = { - .name ="cmd646-ide" , - .size =sizeof (PCIIDEState), - .props = cmd646_ide_properties, - .class_init = cmd646_ide_class_init, +static TypeInfo cmd646_ide_info = { + .name ="cmd646-ide" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIIDEState), + .class_init = cmd646_ide_class_init, };static void cmd646_ide_register (void ) { -pci_qdev_register (&cmd646_ide_info); +type_register_static (&cmd646_ide_info); }device_init (cmd646_ide_register);
hw/ide/ich.c +10 -7
@@ -148,6 +148,7 @@ static void pci_ich9_write_config(PCIDevice *pci, uint32_t addr,static void ich_ahci_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = pci_ich9_ahci_init;
@@ -157,18 +158,20 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_INTEL_82801IR ; k->revision =0x02 ; k->class_id =PCI_CLASS_STORAGE_SATA ; + dc->alias ="ahci" ; + dc->vmsd = &vmstate_ahci; } -static DeviceInfo ich_ahci_info = { - .name ="ich9-ahci" , - .alias ="ahci" , - .size =sizeof (AHCIPCIState), - .vmsd = &vmstate_ahci, - .class_init = ich_ahci_class_init, +static TypeInfo ich_ahci_info = { + .name ="ich9-ahci" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (AHCIPCIState), + .class_init = ich_ahci_class_init, };static void ich_ahci_register (void ) { -pci_qdev_register (&ich_ahci_info); +type_register_static (&ich_ahci_info); +type_register_static_alias (&ich_ahci_info,"ahci" ); }device_init (ich_ahci_register);
hw/ide/isa.c +17 -13
@@ -94,29 +94,33 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,return dev; } +static Property isa_ide_properties[] = { +DEFINE_PROP_HEX32 ("iobase" , ISAIDEState, iobase,0x1f0 ), +DEFINE_PROP_HEX32 ("iobase2" , ISAIDEState, iobase2,0x3f6 ), +DEFINE_PROP_UINT32 ("irq" , ISAIDEState, isairq,14 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void isa_ide_class_initfn (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = isa_ide_initfn; + dc->fw_name ="ide" ; + dc->reset = isa_ide_reset; + dc->props = isa_ide_properties; } -static DeviceInfo isa_ide_info = { - .name ="isa-ide" , - .fw_name ="ide" , - .size =sizeof (ISAIDEState), - .class_init = isa_ide_class_initfn, - .reset = isa_ide_reset, - .props = (Property []) { -DEFINE_PROP_HEX32 ("iobase" , ISAIDEState, iobase,0x1f0 ), -DEFINE_PROP_HEX32 ("iobase2" , ISAIDEState, iobase2,0x3f6 ), -DEFINE_PROP_UINT32 ("irq" , ISAIDEState, isairq,14 ), -DEFINE_PROP_END_OF_LIST (), - }, +static TypeInfo isa_ide_info = { + .name ="isa-ide" , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISAIDEState), + .class_init = isa_ide_class_initfn, };static void isa_ide_register_devices (void ) { -isa_qdev_register (&isa_ide_info); +type_register_static (&isa_ide_info); }device_init (isa_ide_register_devices)
hw/ide/piix.c +25 -19
85 lines not on this page · raw message
hw/ide/qdev.c +53 -40
139 lines not on this page · raw message
hw/ide/via.c +8 -6
@@ -215,6 +215,7 @@ void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)static void via_ide_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = vt82c686b_ide_initfn;
@@ -223,17 +224,18 @@ static void via_ide_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_VIA_IDE ; k->revision =0x06 ; k->class_id =PCI_CLASS_STORAGE_IDE ; + dc->no_user =1 ; } -static DeviceInfo via_ide_info = { - .name ="via-ide" , - .size =sizeof (PCIIDEState), - .no_user =1 , - .class_init = via_ide_class_init, +static TypeInfo via_ide_info = { + .name ="via-ide" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIIDEState), + .class_init = via_ide_class_init, };static void via_ide_register (void ) { -pci_qdev_register (&via_ide_info); +type_register_static (&via_ide_info); }device_init (via_ide_register);
hw/integratorcp.c +14 -11
@@ -525,16 +525,18 @@ static Property core_properties[] = {static void core_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = integratorcm_init; + dc->props = core_properties; } -static DeviceInfo core_info = { - .name ="integrator_core" , - .size =sizeof (integratorcm_state), - .props = core_properties, - .class_init = core_class_init, +static TypeInfo core_info = { + .name ="integrator_core" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (integratorcm_state), + .class_init = core_class_init, };static void icp_pic_class_init (ObjectClass *klass,void *data)
@@ -544,16 +546,17 @@ static void icp_pic_class_init(ObjectClass *klass, void *data) sdc->init = icp_pic_init; } -static DeviceInfo icp_pic_info = { - .name ="integrator_pic" , - .size =sizeof (icp_pic_state), - .class_init = icp_pic_class_init, +static TypeInfo icp_pic_info = { + .name ="integrator_pic" , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (icp_pic_state), + .class_init = icp_pic_class_init, };static void integratorcp_register_devices (void ) { -sysbus_qdev_register (&icp_pic_info); -sysbus_register_withprop (&core_info); +type_register_static (&icp_pic_info); +type_register_static (&core_info); }device_init (integratorcp_register_devices)
hw/intel-hda.c +20 -17
@@ -74,14 +74,6 @@ static int hda_codec_dev_exit(DeviceState *qdev)return 0 ; } -void hda_codec_register (DeviceInfo *info) -{ - info->init = hda_codec_dev_init; - info->exit = hda_codec_dev_exit; - info->bus_info = &hda_codec_bus_info; -qdev_register_subclass (info,TYPE_HDA_CODEC_DEVICE ); -} -HDACodecDevice *hda_codec_find (HDACodecBus *bus,uint32_t cad) {DeviceState *qdev;
@@ -1255,6 +1247,7 @@ static Property intel_hda_properties[] = {static void intel_hda_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); k->init = intel_hda_init;
@@ -1264,29 +1257,39 @@ static void intel_hda_class_init(ObjectClass *klass, void *data) k->device_id =0x2668 ; k->revision =1 ; k->class_id =PCI_CLASS_MULTIMEDIA_HD_AUDIO ; + dc->desc ="Intel HD Audio Controller" ; + dc->reset = intel_hda_reset; + dc->vmsd = &vmstate_intel_hda; + dc->props = intel_hda_properties; } -static DeviceInfo intel_hda_info = { - .name ="intel-hda" , - .desc ="Intel HD Audio Controller" , - .size =sizeof (IntelHDAState), - .vmsd = &vmstate_intel_hda, - .reset = intel_hda_reset, - .props = intel_hda_properties, - .class_init = intel_hda_class_init, +static TypeInfo intel_hda_info = { + .name ="intel-hda" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (IntelHDAState), + .class_init = intel_hda_class_init, }; +static void hda_codec_device_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *k =DEVICE_CLASS (klass); + k->init = hda_codec_dev_init; + k->exit = hda_codec_dev_exit; + k->bus_info = &hda_codec_bus_info; +} +
Lines of this file are not shown. View the raw message.
hw/m48t59.c +26 -20
46 lines not on this page · raw message
hw/musicpal.c +66 -51
117 lines not on this page · raw message
hw/piix_pci.c +39 -31
70 lines not on this page · raw message
hw/pl110.c +27 -21
48 lines not on this page · raw message
hw/pxa2xx.c +31 -25
56 lines not on this page · raw message
hw/s390-virtio-bus.c +69 -69
138 lines not on this page · raw message
hw/scsi-disk.c +66 -50
116 lines not on this page · raw message
hw/spitz.c +34 -26
60 lines not on this page · raw message
hw/stellaris.c +24 -20
44 lines not on this page · raw message
hw/strongarm.c +55 -43
98 lines not on this page · raw message
hw/sun4m.c +28 -22
50 lines not on this page · raw message
hw/unin_pci.c +41 -33
74 lines not on this page · raw message
hw/usb-ccid.c +24 -19
43 lines not on this page · raw message
hw/usb-hid.c +24 -18
42 lines not on this page · raw message
hw/usb-ohci.c +24 -18
42 lines not on this page · raw message
hw/usb-serial.c +28 -20
48 lines not on this page · raw message
hw/usb-uhci.c +54 -42
96 lines not on this page · raw message
hw/virtio-pci.c +44 -32
76 lines not on this page · raw message
hw/vt82c686.c +36 -28
64 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.4.1
Part of the diff is not shown here. View the raw message.
Re: [Qemu-devel] [PATCH 08/23] qdev: register all types natively through QEMU Object Model
Quoted 7 lines · Anthony Liguori
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.
Quoted 7 lines
The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a
class_initfunction as appropriate.Finally, a python script was used to convert the DeviceInfo structures and
qdev_register_subclassfunctions to TypeInfo structures,class_initfunctions, andtype_register_staticcalls.
Can you document this process in enough detail so that those of us with trees/branches not yet upstream can use it to ease the process of rebasing after this lands, please?
Thanks
-- PMM
Re: [Qemu-devel] [PATCH 08/23] qdev: register all types natively through QEMU Object Model
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Anthony Liguori
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_initfunction as appropriate.
Quoted 7 lines
Quoted 3 lines
Finally, a python script was used to convert the DeviceInfo structures and
qdev_register_subclassfunctions to TypeInfo structures,class_initfunctions, andtype_register_staticcalls.Can you document this process in enough detail so that those of us with trees/branches not yet upstream can use it to ease the process of rebasing after this lands, please?
Replace DeviceInfo with TypeInfo, mapping:
TypeInfo::name = DeviceInfo::nameTypeInfo::parent = subclass argument to qdev_register_subclass TypeInfo::instance_size = DeviceInfo::size TypeInfo::class_init = DeviceInfo::class_init
Any remaining DeviceInfo members being initialized should be moved to the class_init function as assignment to DeviceClass. Use DEVICE_CLASS() to case the ObjectClass in the argument to DeviceClass *dc and then assign the members.
Replace qdev_register_subclass calls with type_register_static.
Regards,
Anthony Liguori
Quoted 4 lines
Thanks
-- PMM
PATCH 9/23 qdev: kill of DeviceInfo
In reply to Anthony LiguoriIt is no longer used in the tree since everything is done natively through QEMU Object Model.
--- hw/i2c.c | 2 +- hw/ide/qdev.c | 2 +- hw/intel-hda.c | 2 +- hw/isa-bus.c | 2 +- hw/pci.c | 2 +- hw/qdev.c | 70 +----------------------------------------------- hw/qdev.h | 33 +---------------------- hw/s390-virtio-bus.c | 2 +- hw/scsi-bus.c | 2 +- hw/spapr_vio.c | 2 +- hw/ssi.c | 2 +- hw/sysbus.c | 2 +- hw/usb-bus.c | 2 +- hw/usb-ccid.c | 2 +- hw/virtio-serial-bus.c | 2 +- 15 files changed, 15 insertions(+), 114 deletions(-)
hw/i2c.c +1 -1
@@ -196,7 +196,7 @@ const VMStateDescription vmstate_i2c_slave = { } }; -static int i2c_slave_qdev_init (DeviceState *dev,DeviceInfo *base) +static int i2c_slave_qdev_init (DeviceState *dev) {I2CSlave *s =I2C_SLAVE_FROM_QDEV (dev);I2CSlaveClass *sc =I2C_SLAVE_GET_CLASS (s);
hw/ide/qdev.c +1 -1
@@ -53,7 +53,7 @@ static char *idebus_get_fw_dev_path(DeviceState *dev)return strdup (path); } -static int ide_qdev_init (DeviceState *qdev,DeviceInfo *base) +static int ide_qdev_init (DeviceState *qdev) {IDEDevice *dev =IDE_DEVICE (qdev);IDEDeviceClass *dc =IDE_DEVICE_GET_CLASS (dev);
hw/intel-hda.c +1 -1
@@ -47,7 +47,7 @@ void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, bus->xfer = xfer; } -static int hda_codec_dev_init (DeviceState *qdev,DeviceInfo *base) +static int hda_codec_dev_init (DeviceState *qdev) {HDACodecBus *bus =DO_UPCAST (HDACodecBus, qbus, qdev->parent_bus);HDACodecDevice *dev =DO_UPCAST (HDACodecDevice, qdev, qdev);
hw/isa-bus.c +1 -1
@@ -110,7 +110,7 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start,portio_list_add (piolist, isabus->address_space_io, start); } -static int isa_qdev_init (DeviceState *qdev,DeviceInfo *base) +static int isa_qdev_init (DeviceState *qdev) {ISADevice *dev =ISA_DEVICE (qdev);ISADeviceClass *klass =ISA_DEVICE_GET_CLASS (dev);
hw/pci.c +1 -1
@@ -1453,7 +1453,7 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn)return bus->devices[devfn]; } -static int pci_qdev_init (DeviceState *qdev,DeviceInfo *base) +static int pci_qdev_init (DeviceState *qdev) {PCIDevice *pci_dev = (PCIDevice *)qdev;PCIDeviceClass *pc =PCI_DEVICE_GET_CLASS (pci_dev);
hw/qdev.c +1 -69
88 lines not on this page · raw message
hw/qdev.h +1 -32
@@ -14,8 +14,6 @@ typedef struct PropertyInfo PropertyInfo;typedef struct CompatProperty CompatProperty ; -typedef struct DeviceInfo DeviceInfo ; -typedef struct BusState BusState ;typedef struct BusInfo BusInfo ;
@@ -72,7 +70,7 @@ typedef struct DeviceProperty#define DEVICE_CLASS (klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)#define DEVICE_GET_CLASS (obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE) -typedef int (*qdev_initfn )(DeviceState *dev,DeviceInfo *info); +typedef int (*qdev_initfn )(DeviceState *dev);typedef int (*qdev_event )(DeviceState *dev);typedef void (*qdev_resetfn )(DeviceState *dev);
@@ -232,35 +230,6 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name);/*** Device API. ***/ -struct DeviceInfo { -const char *name; -const char *fw_name; -const char *alias; -const char *desc; -size_t size; -Property *props; -int no_user; - -/* callbacks */ -qdev_resetfn reset; - -/* device state */ -const VMStateDescription *vmsd; - -/** -* See #TypeInfo::class_init() -*/ -void (*class_init)(ObjectClass *klass,void *data); - -/* Private to qdev / bus. */ -qdev_initfn init; -qdev_event unplug; -qdev_event exit; -BusInfo *bus_info; -}; - -void qdev_register_subclass (DeviceInfo *info,const char *parent); -/* Register device properties. */ /* GPIO inputs also double as IRQ sinks. */ void qdev_init_gpio_in (DeviceState *dev,qemu_irq_handler handler,int n);
hw/s390-virtio-bus.c +1 -1
@@ -410,7 +410,7 @@ static TypeInfo s390_virtio_serial = { .class_init = s390_virtio_serial_class_init, }; -static int s390_virtio_busdev_init (DeviceState *dev,DeviceInfo *info) +static int s390_virtio_busdev_init (DeviceState *dev) {VirtIOS390Device *_dev = (VirtIOS390Device *)dev;VirtIOS390DeviceClass *_info =VIRTIO_S390_DEVICE_GET_CLASS (dev);
hw/scsi-bus.c +1 -1
@@ -115,7 +115,7 @@ static void scsi_dma_restart_cb(void *opaque, int running, RunState state) } } -static int scsi_qdev_init (DeviceState *qdev,DeviceInfo *base) +static int scsi_qdev_init (DeviceState *qdev) {SCSIDevice *dev =SCSI_DEVICE (qdev);SCSIBus *bus =DO_UPCAST (SCSIBus, qbus, dev->qdev.parent_bus);
hw/spapr_vio.c +1 -1
@@ -649,7 +649,7 @@ static int spapr_vio_check_reg(VIOsPAPRDevice *sdev)return 0 ; } -static int spapr_vio_busdev_init (DeviceState *qdev,DeviceInfo *qinfo) +static int spapr_vio_busdev_init (DeviceState *qdev) {VIOsPAPRDevice *dev = (VIOsPAPRDevice *)qdev;VIOsPAPRDeviceClass *pc =VIO_SPAPR_DEVICE_GET_CLASS (dev);
hw/ssi.c +1 -1
@@ -21,7 +21,7 @@ static struct BusInfo ssi_bus_info = { .size = sizeof(SSIBus), }; -static int ssi_slave_init (DeviceState *dev,DeviceInfo *base_info) +static int ssi_slave_init (DeviceState *dev) {SSISlave *s =SSI_SLAVE (dev);SSISlaveClass *ssc =SSI_SLAVE_GET_CLASS (s);
hw/sysbus.c +1 -1
@@ -105,7 +105,7 @@ void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size) } } -static int sysbus_device_init (DeviceState *dev,DeviceInfo *base) +static int sysbus_device_init (DeviceState *dev) {SysBusDevice *sd =SYS_BUS_DEVICE (dev);SysBusDeviceClass *sbc =SYS_BUS_DEVICE_GET_CLASS (sd);
hw/usb-bus.c +1 -1
@@ -156,7 +156,7 @@ void usb_device_set_interface(USBDevice *dev, int interface, } } -static int usb_qdev_init (DeviceState *qdev,DeviceInfo *base) +static int usb_qdev_init (DeviceState *qdev) {USBDevice *dev =USB_DEVICE (qdev);int rc;
hw/usb-ccid.c +1 -1
@@ -1161,7 +1161,7 @@ static int ccid_card_exit(DeviceState *qdev)return ret; } -static int ccid_card_init (DeviceState *qdev,DeviceInfo *base) +static int ccid_card_init (DeviceState *qdev) {CCIDCardState *card =CCID_CARD (qdev); USBCCIDState *s =
hw/virtio-serial-bus.c +1 -1
@@ -748,7 +748,7 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)send_control_event (port,VIRTIO_CONSOLE_PORT_REMOVE ,1 ); } -static int virtser_port_qdev_init (DeviceState *qdev,DeviceInfo *base) +static int virtser_port_qdev_init (DeviceState *qdev) {VirtIOSerialPort *port =DO_UPCAST (VirtIOSerialPort, dev, qdev);VirtIOSerialPortClass *vsc =VIRTIO_SERIAL_PORT_GET_CLASS (port);
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 09/23] qdev: kill of DeviceInfo
Am 30.01.2012 22:08, schrieb Anthony Liguori:
Quoted 4 lines
It is no longer used in the tree since everything is done natively through QEMU Object Model.
Signed-off-by Anthony Liguori <[email protected]>
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 09/23] qdev: kill of DeviceInfo
In reply to Anthony LiguoriQuoted 1 line · Anthony Liguori
Subject: [PATCH 09/23] qdev: kill of DeviceInfo
"kill off".
-- PMM
Re: [Qemu-devel] [PATCH 09/23] qdev: kill of DeviceInfo
Quoted 4 lines · Peter Maydell
Quoted 1 line · Anthony Liguori
Subject: [PATCH 09/23] qdev: kill of DeviceInfo
"kill off".
Tanks!
Regards,
Anthony Liguori
Quoted 3 lines
-- PMM
PATCH 10/23 qdev: remove baked in notion of aliases
In reply to Anthony LiguoriLimit them to the device_add functionality. Device aliases were a hack based on the fact that virtio was modeled the wrong way. The mechanism for aliasing is very limited in that only one alias can exist for any device.
We have to support it for the purposes of compatibility but we only need to support it in device_add so restrict it to that piece of code.
--- hw/ide/ich.c | 2 - hw/lsi53c895a.c | 2 - hw/qdev.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++--- hw/qdev.h | 1 - hw/s390-virtio-bus.c | 3 -- hw/virtio-pci.c | 8 ---- 6 files changed, 89 insertions(+), 22 deletions(-)
hw/ide/ich.c +0 -2
@@ -158,7 +158,6 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_INTEL_82801IR ; k->revision =0x02 ; k->class_id =PCI_CLASS_STORAGE_SATA ; - dc->alias ="ahci" ; dc->vmsd = &vmstate_ahci; }
@@ -172,6 +171,5 @@ static TypeInfo ich_ahci_info = {static void ich_ahci_register (void ) {type_register_static (&ich_ahci_info); -type_register_static_alias (&ich_ahci_info,"ahci" ); }device_init (ich_ahci_register);
hw/lsi53c895a.c +0 -2
@@ -2131,7 +2131,6 @@ static void lsi_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_LSI_53C895A ; k->class_id =PCI_CLASS_STORAGE_SCSI ; k->subsystem_id =0x1000 ; - dc->alias ="lsi" ; dc->reset = lsi_scsi_reset; dc->vmsd = &vmstate_lsi_scsi; }
@@ -2146,7 +2145,6 @@ static TypeInfo lsi_info = {static void lsi53c895a_register_devices (void ) {type_register_static (&lsi_info); -type_register_static_alias (&lsi_info,"lsi" ); }device_init (lsi53c895a_register_devices);
hw/qdev.c +89 -6
143 lines not on this page · raw message
hw/qdev.h +0 -1
@@ -78,7 +78,6 @@ typedef struct DeviceClass {ObjectClass parent_class;const char *fw_name; -const char *alias;const char *desc;Property *props;int no_user;
hw/s390-virtio-bus.c +0 -3
@@ -354,7 +354,6 @@ static void s390_virtio_net_class_init(ObjectClass *klass, void *data) k->init = s390_virtio_net_init; dc->props = s390_virtio_net_properties; - dc->alias ="virtio-net" ; }static TypeInfo s390_virtio_net = {
@@ -377,7 +376,6 @@ static void s390_virtio_blk_class_init(ObjectClass *klass, void *data) k->init = s390_virtio_blk_init; dc->props = s390_virtio_blk_properties; - dc->alias ="virtio-blk" ; }static TypeInfo s390_virtio_blk = {
@@ -400,7 +398,6 @@ static void s390_virtio_serial_class_init(ObjectClass *klass, void *data) k->init = s390_virtio_serial_init; dc->props = s390_virtio_serial_properties; - dc->alias ="virtio-serial" ; }static TypeInfo s390_virtio_serial = {
hw/virtio-pci.c +0 -8
@@ -827,7 +827,6 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_VIRTIO_BLOCK ; k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_STORAGE_SCSI ; - dc->alias ="virtio-blk" ; dc->reset = virtio_pci_reset; dc->props = virtio_blk_properties; }
@@ -862,7 +861,6 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_VIRTIO_NET ; k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ; - dc->alias ="virtio-net" ; dc->reset = virtio_pci_reset; dc->props = virtio_net_properties; }
@@ -894,7 +892,6 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_VIRTIO_CONSOLE ; k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_COMMUNICATION_OTHER ; - dc->alias ="virtio-serial" ; dc->reset = virtio_pci_reset; dc->props = virtio_serial_properties; }
@@ -922,7 +919,6 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_VIRTIO_BALLOON ; k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_MEMORY_RAM ; - dc->alias ="virtio-balloon" ; dc->reset = virtio_pci_reset; dc->props = virtio_balloon_properties; }
@@ -937,13 +933,9 @@ static TypeInfo virtio_balloon_info = {static void virtio_pci_register_devices (void ) {type_register_static (&virtio_blk_info); -type_register_static_alias (&virtio_blk_info,"virtio-blk" );type_register_static (&virtio_net_info); -type_register_static_alias (&virtio_net_info,"virtio-net" );type_register_static (&virtio_serial_info); -type_register_static_alias (&virtio_serial_info,"virtio-serial" );type_register_static (&virtio_balloon_info); -type_register_static_alias (&virtio_balloon_info,"virtio-balloon" ); }device_init (virtio_pci_register_devices)
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 10/23] qdev: remove baked in notion of aliases
Quoted 61 lines · Anthony Liguori
hw/qdev.c +40
-4+/* +* Aliases were a bad idea from the start. Let's keep them +* from spreading further. +*/ +static const char *qdev_class_get_alias (DeviceClass *dc) +{ +const char *typename =object_class_get_name (OBJECT_CLASS (dc)); + +if (strcmp (typename,"virtio-blk-pci" ) ==0 ) { +return "virtio-blk" ; + }else if (strcmp (typename,"virtio-net-pci" ) ==0 ) { +return "virtio-net" ; + }else if (strcmp (typename,"virtio-serial-pci" ) ==0 ) { +return "virtio-serial" ; + }else if (strcmp (typename,"virtio-balloon-pci" ) ==0 ) { +return "virtio-balloon" ; + }else if (strcmp (typename,"virtio-blk-s390" ) ==0 ) { +return "virtio-blk" ; + }else if (strcmp (typename,"virtio-net-s390" ) ==0 ) { +return "virtio-net" ; + }else if (strcmp (typename,"virtio-serial-s390" ) ==0 ) { +return "virtio-serial" ; + }else if (strcmp (typename,"lsi53c895a" ) ==0 ) { +return "lsi" ; + }else if (strcmp (typename,"ich9-ahci" ) ==0 ) { +return "ahci" ; + } + +return NULL ; +} + +static bool qdev_class_has_alias (DeviceClass *dc) +{ +return (qdev_class_get_alias (dc) !=NULL ); +} +const char *qdev_fw_name (DeviceState *dev) {DeviceClass *dc =DEVICE_GET_CLASS (dev);if (dc->fw_name) {return dc->fw_name; - }else if (dc->alias) { -return dc->alias; + }else if (qdev_class_has_alias (dc)) { +return qdev_class_get_alias (dc); }return object_get_typename (OBJECT (dev));@@ -161,8 +197,8 @@ static void qdev_print_devinfo(ObjectClass *klass, void *opaque)if (dc->bus_info) {error_printf (", bus %s" , dc->bus_info->name); } -if (dc->alias) { -error_printf (", alias \"%s\"" , dc->alias); +if (qdev_class_has_alias (dc)) { +error_printf (", alias \"%s\"" ,qdev_class_get_alias (dc)); }if (dc->desc) {error_printf (", desc \"%s\"" , dc->desc);
hw/qdev.c static int set_property(const char *name, const char *value, void *opaque) · line 229
Quoted 6 lines
hw/qdev.c +3
-0@@ -188,6 +224,27 @@ static int set_property(const char *name, const char *value, void *opaque)return 0 ; } +static const char *find_typename_by_alias (const char *alias) +{ +/* I don't think s390 aliasing could have ever worked... */
Yes, because s390 doesn't have PCI.
Quoted 7 lines
hw/qdev.c +7
-0+if (strcmp (alias,"virtio-blk" ) ==0 ) { +return "virtio-blk-pci" ; + }else if (strcmp (alias,"virtio-net" ) ==0 ) { +return "virtio-net-pci" ; + }else if (strcmp (alias,"virtio-serial" ) ==0 ) { +return "virtio-serial-pci" ; + }else if (strcmp (alias,"virtio-balloon" ) ==0 ) {
hw/qdev.c static int set_property(const char *name, const char *value, void *opaque) · line 247
Quoted 10 lines
hw/qdev.c +10
-0+return "virtio-balloon-pci" ; + }else if (strcmp (alias,"lsi" ) ==0 ) { +return "lsi53c895a" ; + }else if (strcmp (alias,"ahci" ) ==0 ) { +return "ich9-ahci" ; + } + +return NULL ; +} +
Please change this to a table so that you can have:
if (object_class_by_name(table[i].name) &&
strcmp(alias, table[i].alias) == 0) {
return table[i].name;
}and for the other direction
if (object_class_by_name(table[i].name) &&
strcmp(name, table[i].name) == 0) {
return table[i].alias;
}Paolo
PATCH 11/23 qom: allow object_class_foreach to take additional parameters to refine search
In reply to Anthony Liguori--- hw/qdev.c | 4 ++-- include/qemu/object.h | 1 + qom/object.c | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-)
hw/qdev.c +2 -2
@@ -255,7 +255,7 @@ int qdev_device_help(QemuOpts *opts) driver =qemu_opt_get (opts,"driver" );if (driver && !strcmp (driver,"?" )) {bool show_no_user = false; -object_class_foreach (qdev_print_devinfo, &show_no_user); +object_class_foreach (qdev_print_devinfo,TYPE_DEVICE , false, &show_no_user);return 1 ; }
@@ -1077,7 +1077,7 @@ void do_info_qtree(Monitor *mon)void do_info_qdm (Monitor *mon) { -object_class_foreach (qdev_print_devinfo,NULL ); +object_class_foreach (qdev_print_devinfo,TYPE_DEVICE , false,NULL ); }int do_device_add (Monitor *mon,const QDict *qdict,QObject **ret_data)
include/qemu/object.h +1 -0
@@ -431,6 +431,7 @@ const char *object_class_get_name(ObjectClass *klass);ObjectClass *object_class_by_name (const char *typename);void object_class_foreach (void (*fn)(ObjectClass *klass,void *opaque), +const char *implements_type,bool include_abstract,void *opaque);#endif
qom/object.c +16 -2
@@ -467,6 +467,8 @@ ObjectClass *object_class_by_name(const char *typename)typedef struct OCFData {void (*fn)(ObjectClass *klass,void *opaque); +const char *implements_type; +bool include_abstract;void *opaque; }OCFData ;
@@ -475,16 +477,28 @@ static void object_class_foreach_tramp(gpointer key, gpointer value, {OCFData *data = opaque;TypeImpl *type = value; +ObjectClass *k;type_class_init (type); + k = type->class; - data->fn (value, type->class); +if (!data->include_abstract && type->abstract) { +return ; + } + +if (data->implements_type && + !object_class_dynamic_cast (k, data->implements_type)) { +return ; + } + + data->fn (k, data->opaque); }void object_class_foreach (void (*fn)(ObjectClass *klass,void *opaque), +const char *implements_type,bool include_abstract,void *opaque) { -OCFData data = { fn, opaque }; +OCFData data = { fn, implements_type, include_abstract, opaque };g_hash_table_foreach (type_table_get (), object_class_foreach_tramp, &data); }
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 11/23] qom: allow object_class_foreach to take additional parameters to refine search
$subject is a bit long.
Am 30.01.2012 22:08, schrieb Anthony Liguori:
Quoted 1 line
Signed-off-by Anthony Liguori <[email protected]>
However...
Quoted 14 lines
hw/qdev.c +1
-1@@ -255,7 +255,7 @@ int qdev_device_help(QemuOpts *opts) driver =qemu_opt_get (opts,"driver" );if (driver && !strcmp (driver,"?" )) {bool show_no_user = false; -object_class_foreach (qdev_print_devinfo, &show_no_user); +object_class_foreach (qdev_print_devinfo,TYPE_DEVICE , false, &show_no_user);return 1 ; }
hw/qdev.c void do_info_qtree(Monitor *mon) · line 1083
Quoted 8 lines
hw/qdev.c +1
-1@@ -1077,7 +1077,7 @@ void do_info_qtree(Monitor *mon)void do_info_qdm (Monitor *mon) { -object_class_foreach (qdev_print_devinfo,NULL ); +object_class_foreach (qdev_print_devinfo,TYPE_DEVICE , false,NULL ); }int do_device_add (Monitor *mon,const QDict *qdict,QObject **ret_data)
If you reordered this patch before 07/23 then you could apply it right away, unbreaking object_class_foreach().
Andreas
Quoted 56 lines
include/qemu/object.h +1
-0@@ -431,6 +431,7 @@ const char *object_class_get_name(ObjectClass *klass);ObjectClass *object_class_by_name (const char *typename);void object_class_foreach (void (*fn)(ObjectClass *klass,void *opaque), +const char *implements_type,bool include_abstract,void *opaque);#endif qom/object.c +16
-2@@ -467,6 +467,8 @@ ObjectClass *object_class_by_name(const char *typename)typedef struct OCFData {void (*fn)(ObjectClass *klass,void *opaque); +const char *implements_type; +bool include_abstract;void *opaque; }OCFData ;@@ -475,16 +477,28 @@ static void object_class_foreach_tramp(gpointer key, gpointer value, {OCFData *data = opaque;TypeImpl *type = value; +ObjectClass *k;type_class_init (type); + k = type->class; - data->fn (value, type->class); +if (!data->include_abstract && type->abstract) { +return ; + } + +if (data->implements_type && + !object_class_dynamic_cast (k, data->implements_type)) { +return ; + } + + data->fn (k, data->opaque); }void object_class_foreach (void (*fn)(ObjectClass *klass,void *opaque), +const char *implements_type,bool include_abstract,void *opaque) { -OCFData data = { fn, opaque }; +OCFData data = { fn, implements_type, include_abstract, opaque };g_hash_table_foreach (type_table_get (), object_class_foreach_tramp, &data); }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 12/23 qom: add new command to search for types
In reply to Anthony LiguoriThis adds a command that allows searching for types that implement a property. This allows you to do things like search for all available PCIDevices. In the future, we'll also have a standard interface for things with a BlockDriverState property that a PCIDevice could implement.
This will enable search queries like, "any type that implements the BlockDevice interface" which would allow management tools to present available block devices without having to hard code device names. Since an object can implement multiple interfaces, one device could act both as a BlockDevice and a NetworkDevice.
--- qapi-schema.json | 33 +++++++++++++++++++++++++++++++++ qerror.c | 2 +- qmp-commands.hx | 5 +++++ qmp.c | 27 +++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletions(-)
qapi-schema.json +33 -0
@@ -1549,3 +1549,36 @@ # Since: 1.1 ## { 'command': 'block_job_cancel', 'data': { 'device': 'str' } } + +## +# @ObjectTypeInfo: +# +# This structure describes a search result from @qom-list-types +# +# @name: the type name found in the search +# +# Since: 1.1 +# +# Notes: This command is experimental and may change syntax in future releases. +## +{ 'type': 'ObjectTypeInfo', + 'data': { 'name': 'str' } } + +## +# @qom-list-types: +# +# This command will return a list of types given search parameters +# +# @implements: if specified, only return types that implement this type name +# +# @abstract: if true, include abstract types in the results +# +# Returns: a list of @ObjectTypeInfo or an empty list if no results are found +# +# Since: 1.1 +# +# Notes: This command is experimental and may change syntax in future releases. +## +{ 'command': 'qom-list-types', + 'data': { '*implements': 'str', '*abstract': 'bool' }, + 'returns': [ 'ObjectTypeInfo' ] }
qerror.c +1 -1
@@ -161,7 +161,7 @@ static const QErrorStringTable qerror_table[] = { }, { .error_fmt = QERR_INVALID_PARAMETER_TYPE, - .desc = "Invalid parameter type, expected: %(expected)", + .desc = "Invalid parameter type for '%(name)', expected: %(expected)", }, { .error_fmt = QERR_INVALID_PARAMETER_VALUE,
qmp-commands.hx +5 -0
@@ -2042,3 +2042,8 @@ EQMP .args_type = "password:s", .mhandler.cmd_new = qmp_marshal_input_change_vnc_password, }, + { + .name = "qom-list-types", + .args_type = "implements:s?,abstract:b?", + .mhandler.cmd_new = qmp_marshal_input_qom_list_types, + },
qmp.c +27 -0
@@ -395,3 +395,30 @@ void qmp_change(const char *device, const char *target,qmp_change_blockdev (device, target, has_arg, arg, err); } } + +static void qom_list_types_tramp (ObjectClass *klass,void *data) +{ +ObjectTypeInfoList *e, **pret = data; +ObjectTypeInfo *info; + + info =g_malloc0 (sizeof (*info)); + info->name =g_strdup (object_class_get_name (klass)); + + e =g_malloc0 (sizeof (*e)); + e->value = info; + e->next = *pret; + *pret = e; +} + +ObjectTypeInfoList *qmp_qom_list_types (bool has_implements, +const char *implements, +bool has_abstract, +bool abstract, +Error **errp) +{ +ObjectTypeInfoList *ret =NULL ; + +object_class_foreach (qom_list_types_tramp, implements, abstract, &ret); + +return ret; +}
Signature · 1 line
1.7.4.1
PATCH 13/23 qdev: split out common init to instance_init
In reply to Anthony LiguoriThis gets us closer to being able to object_new() a qdev type and have a functioning object verses having to call qdev_create().
--- hw/qdev.c | 41 ++++++++++++++++++++++++++++------------- 1 files changed, 28 insertions(+), 13 deletions(-)
hw/qdev.c +28 -13
@@ -124,31 +124,22 @@ static DeviceState *qdev_create_from_info(BusState *bus, const char *typename)Property *prop; dev =DEVICE (object_new (typename)); + dev->parent_bus = bus; -qdev_prop_set_defaults (dev,qdev_get_props (dev));qdev_prop_set_defaults (dev, dev->parent_bus->info->props); -qdev_prop_set_globals (dev); -QTAILQ_INSERT_HEAD (&bus->children, dev, sibling); +if (qdev_hotplug) {assert (bus->allow_hotplug); - dev->hotplugged =1 ; - qdev_hot_added = true; } - dev->instance_id_alias =-1 ; -QTAILQ_INIT (&dev->properties); - dev->state =DEV_STATE_CREATED ; -for (prop =qdev_get_props (dev); prop && prop->name; prop++) { -qdev_property_add_legacy (dev, prop,NULL ); -qdev_property_add_static (dev, prop,NULL ); - } +QTAILQ_INSERT_HEAD (&bus->children, dev, sibling);for (prop =qdev_get_bus_info (dev)->props; prop && prop->name; prop++) {qdev_property_add_legacy (dev, prop,NULL );qdev_property_add_static (dev, prop,NULL ); } -qdev_property_add_str (dev,"type" , qdev_get_type,NULL ,NULL ); +qdev_prop_set_globals (dev);return dev; }
@@ -1649,6 +1640,29 @@ void qdev_machine_init(void)qdev_get_peripheral (); } +static void device_initfn (Object *obj) +{ +DeviceState *dev =DEVICE (obj); +Property *prop; + +if (qdev_hotplug) { + dev->hotplugged =1 ; + qdev_hot_added = true; + } + + dev->instance_id_alias =-1 ; +QTAILQ_INIT (&dev->properties); + dev->state =DEV_STATE_CREATED ; + +qdev_prop_set_defaults (dev,qdev_get_props (dev)); +for (prop =qdev_get_props (dev); prop && prop->name; prop++) { +qdev_property_add_legacy (dev, prop,NULL ); +qdev_property_add_static (dev, prop,NULL ); + } + +qdev_property_add_str (dev,"type" , qdev_get_type,NULL ,NULL ); +} +void device_reset (DeviceState *dev) {DeviceClass *klass =DEVICE_GET_CLASS (dev);
@@ -1662,6 +1676,7 @@ static TypeInfo device_type_info = { .name = TYPE_DEVICE, .parent = TYPE_OBJECT, .instance_size = sizeof(DeviceState), + .instance_init = device_initfn, .abstract = true, .class_size = sizeof(DeviceClass), };
Signature · 1 line
1.7.4.1
PATCH 14/23 qdev: refactor away qdev_create_from_info
In reply to Anthony LiguoriNote that the FIXME gets fixed in series 4/4. We need to convert BusState to QOM before we can make parent_bus a link.
--- hw/qdev.c | 35 ++++++++++++++++++++++------------- hw/qdev.h | 3 +++ 2 files changed, 25 insertions(+), 13 deletions(-)
hw/qdev.c +22 -13
@@ -118,30 +118,22 @@ bool qdev_exists(const char *name)static void qdev_property_add_legacy (DeviceState *dev,Property *prop,Error **errp); -static DeviceState *qdev_create_from_info (BusState *bus,const char *typename) +void qdev_set_parent_bus (DeviceState *dev,BusState *bus) { -DeviceState *dev;Property *prop; - dev =DEVICE (object_new (typename)); - - dev->parent_bus = bus; -qdev_prop_set_defaults (dev, dev->parent_bus->info->props); -if (qdev_hotplug) {assert (bus->allow_hotplug); } + dev->parent_bus = bus;QTAILQ_INSERT_HEAD (&bus->children, dev, sibling); +qdev_prop_set_defaults (dev, dev->parent_bus->info->props);for (prop =qdev_get_bus_info (dev)->props; prop && prop->name; prop++) {qdev_property_add_legacy (dev, prop,NULL );qdev_property_add_static (dev, prop,NULL ); } - -qdev_prop_set_globals (dev); - -return dev; }/* Create a new device. This only initializes the device state structure
@@ -166,11 +158,21 @@ DeviceState *qdev_create(BusState *bus, const char *name)DeviceState *qdev_try_create (BusState *bus,const char *name) { +DeviceState *dev; + + dev =DEVICE (object_new (name)); +if (!dev) { +return NULL ; + } +if (!bus) { bus =sysbus_get_default (); } -return qdev_create_from_info (bus, name); +qdev_set_parent_bus (dev, bus); +qdev_prop_set_globals (dev); + +return dev; }static void qdev_print_devinfo (ObjectClass *klass,void *opaque)
@@ -375,8 +377,15 @@ DeviceState *qdev_device_add(QemuOpts *opts)return NULL ; } +if (!bus) { + bus =sysbus_get_default (); + } +/* create device, set properties */ - qdev =qdev_create_from_info (bus, driver); + qdev =DEVICE (object_new (driver)); +qdev_set_parent_bus (qdev, bus); +qdev_prop_set_globals (qdev); + id =qemu_opts_id (opts);if (id) { qdev->id = id;
hw/qdev.h +3 -0
@@ -636,4 +636,7 @@ BusInfo *qdev_get_bus_info(DeviceState *dev);Property *qdev_get_props (DeviceState *dev); +/* FIXME: make this a link<> */ +void qdev_set_parent_bus (DeviceState *dev,BusState *bus); +#endif
Signature · 1 line
1.7.4.1
PATCH 15/23 qdev: split out UI portions into a new function
In reply to Anthony Liguoriqdev-monitor.c deals with the -device, device_add, and info qdm/qtree interfaces.
--- Makefile.objs | 2 +- hw/qdev-monitor.c | 587 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.c | 574 +--------------------------------------------------- hw/qdev.h | 2 + 4 files changed, 591 insertions(+), 574 deletions(-) create mode 100644 hw/qdev-monitor.c
Makefile.objs +1 -1
@@ -113,7 +113,7 @@ common-obj-y += bt-hci-csr.o common-obj-y += buffered_file.o migration.o migration-tcp.o common-obj-y += qemu-char.o #aio.o common-obj-y += msmouse.o ps2.o -common-obj-y += qdev.o qdev-properties.o +common-obj-y += qdev.o qdev-properties.o qdev-monitor.o common-obj-y += block-migration.o iohandler.o common-obj-y += pflib.o common-obj-y += bitmap.o bitops.o
hw/qdev-monitor.c new file +587 -0
587 lines not on this page · raw message
hw/qdev.c +1 -573
629 lines not on this page · raw message
hw/qdev.h +2 -0
@@ -639,4 +639,6 @@ Property *qdev_get_props(DeviceState *dev);/* FIXME: make this a link<> */ void qdev_set_parent_bus (DeviceState *dev,BusState *bus); +extern int qdev_hotplug; +#endif
Signature · 1 line
1.7.4.1
PATCH 16/23 qdev: nuke qdev_init_chardev()
In reply to Anthony LiguoriI'm sure the intentions were good here, but there's no reason this should be in qdev. Move it to qemu-char where it belongs.
--- hw/etraxfs_ser.c | 2 +- hw/lm32_juart.c | 2 +- hw/lm32_uart.c | 2 +- hw/milkymist-uart.c | 2 +- hw/pl011.c | 2 +- hw/qdev.c | 9 --------- hw/qdev.h | 2 -- hw/xilinx_uartlite.c | 2 +- qemu-char.c | 10 ++++++++++ qemu-char.h | 2 ++ 10 files changed, 18 insertions(+), 17 deletions(-)
hw/etraxfs_ser.c +1 -1
@@ -216,7 +216,7 @@ static int etraxfs_ser_init(SysBusDevice *dev)memory_region_init_io (&s->mmio, &ser_ops, s,"etraxfs-serial" ,R_MAX *4 );sysbus_init_mmio (dev, &s->mmio); - s->chr =qdev_init_chardev (&dev->qdev); + s->chr =qemu_char_get_next_serial ();if (s->chr) qemu_chr_add_handlers(s->chr, serial_can_receive, serial_receive,
hw/lm32_juart.c +1 -1
@@ -114,7 +114,7 @@ static int lm32_juart_init(SysBusDevice *dev) {LM32JuartState *s =FROM_SYSBUS (typeof (*s), dev); - s->chr =qdev_init_chardev (&dev->qdev); + s->chr =qemu_char_get_next_serial ();if (s->chr) {qemu_chr_add_handlers (s->chr, juart_can_rx, juart_rx, juart_event, s); }
hw/lm32_uart.c +1 -1
@@ -252,7 +252,7 @@ static int lm32_uart_init(SysBusDevice *dev)memory_region_init_io (&s->iomem, &uart_ops, s,"uart" ,R_MAX *4 );sysbus_init_mmio (dev, &s->iomem); - s->chr =qdev_init_chardev (&dev->qdev); + s->chr =qemu_char_get_next_serial ();if (s->chr) {qemu_chr_add_handlers (s->chr, uart_can_rx, uart_rx, uart_event, s); }
hw/milkymist-uart.c +1 -1
@@ -199,7 +199,7 @@ static int milkymist_uart_init(SysBusDevice *dev) "milkymist-uart", R_MAX * 4);sysbus_init_mmio (dev, &s->regs_region); - s->chr =qdev_init_chardev (&dev->qdev); + s->chr =qemu_char_get_next_serial ();if (s->chr) {qemu_chr_add_handlers (s->chr, uart_can_rx, uart_rx, uart_event, s); }
hw/pl011.c +1 -1
@@ -264,7 +264,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id)sysbus_init_mmio (dev, &s->iomem);sysbus_init_irq (dev, &s->irq); s->id = id; - s->chr =qdev_init_chardev (&dev->qdev); + s->chr =qemu_char_get_next_serial (); s->read_trigger =1 ; s->ifl =0x12 ;
hw/qdev.c +0 -9
@@ -336,15 +336,6 @@ bool qdev_machine_modified(void)return qdev_hot_added || qdev_hot_removed; } -/* Get a character (serial) device interface. */ -CharDriverState *qdev_init_chardev (DeviceState *dev) -{ -static int next_serial; - -/* FIXME: This function needs to go away: use chardev properties! */ -return serial_hds[next_serial++]; -} -BusState *qdev_get_parent_bus (DeviceState *dev) {return dev->parent_bus;
hw/qdev.h +0 -2
@@ -234,8 +234,6 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name);void qdev_init_gpio_in (DeviceState *dev,qemu_irq_handler handler,int n);void qdev_init_gpio_out (DeviceState *dev,qemu_irq *pins,int n); -CharDriverState *qdev_init_chardev (DeviceState *dev); -BusState *qdev_get_parent_bus (DeviceState *dev);/*** BUS API. ***/
hw/xilinx_uartlite.c +1 -1
@@ -205,7 +205,7 @@ static int xilinx_uartlite_init(SysBusDevice *dev)memory_region_init_io (&s->mmio, &uart_ops, s,"xilinx-uartlite" ,R_MAX *4 );sysbus_init_mmio (dev, &s->mmio); - s->chr =qdev_init_chardev (&dev->qdev); + s->chr =qemu_char_get_next_serial ();if (s->chr)qemu_chr_add_handlers (s->chr, uart_can_rx, uart_rx, uart_event, s);return 0 ;
qemu-char.c +10 -0
@@ -2903,3 +2903,13 @@ CharDriverState *qemu_chr_find(const char *name) }return NULL ; } + +/* Get a character (serial) device interface. */ +CharDriverState *qemu_char_get_next_serial (void ) +{ +static int next_serial; + +/* FIXME: This function needs to go away: use chardev properties! */ +return serial_hds[next_serial++]; +} +
qemu-char.h +2 -0
@@ -248,4 +248,6 @@ void qemu_chr_close_mem(CharDriverState *chr);QString *qemu_chr_mem_to_qs (CharDriverState *chr);size_t qemu_chr_mem_osize (const CharDriverState *chr); +CharDriverState *qemu_char_get_next_serial (void ); +#endif
Signature · 1 line
1.7.4.1
PATCH 17/23 qom: move properties from qdev to object
In reply to Anthony LiguoriThis is mostly code movement although not entirely. This makes properties part of the Object base class which means that we can now start using Object in a meaningful way outside of qdev.
--- hw/mc146818rtc.c | 8 +- hw/pc_piix.c | 6 +- hw/piix_pci.c | 4 +- hw/qdev-addr.c | 6 +- hw/qdev-monitor.c | 21 ++- hw/qdev-properties.c | 53 ++++-- hw/qdev.c | 490 ++----------------------------------------------- hw/qdev.h | 277 +--------------------------- include/qemu/object.h | 223 ++++++++++++++++++++++- qapi-schema.json | 22 +- qmp.c | 34 ++-- qom/object.c | 457 +++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 785 insertions(+), 816 deletions(-)
hw/mc146818rtc.c +4 -4
@@ -626,10 +626,10 @@ static void visit_type_int32(Visitor *v, int *value, const char *name, Error **evisit_type_int (v, &val, name, errp); } -static void rtc_get_date (DeviceState *dev,Visitor *v,void *opaque, +static void rtc_get_date (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -ISADevice *isa =ISA_DEVICE (dev); +ISADevice *isa =ISA_DEVICE (obj);RTCState *s =DO_UPCAST (RTCState, dev, isa);visit_start_struct (v,NULL ,"struct tm" , name,0 , errp);
@@ -676,8 +676,8 @@ static int rtc_initfn(ISADevice *dev)qdev_set_legacy_instance_id (&dev->qdev, base,2 );qemu_register_reset (rtc_reset, s); -qdev_property_add (&s->dev.qdev,"date" ,"struct tm" , - rtc_get_date,NULL ,NULL , s,NULL ); +object_property_add (OBJECT (s),"date" ,"struct tm" , + rtc_get_date,NULL ,NULL , s,NULL );return 0 ; }
hw/pc_piix.c +3 -3
@@ -229,7 +229,7 @@ static void pc_init1(MemoryRegion *system_memory, dev =pc_vga_init (isa_bus, pci_enabled ? pci_bus :NULL );if (dev) { -qdev_property_add_child (qdev_get_root (),"vga" , dev,NULL ); +object_property_add_child (object_get_root (),"vga" ,OBJECT (dev),NULL ); }if (xen_enabled ()) {
@@ -267,8 +267,8 @@ static void pc_init1(MemoryRegion *system_memory,* For now, let's "fix" this by making judicious use of paths. This * is not generally the right way to do this. */ -qdev_property_add_child (qdev_resolve_path ("/i440fx/piix3" ,NULL ), -"rtc" , (DeviceState *)rtc_state,NULL ); +object_property_add_child (object_resolve_path ("/i440fx/piix3" ,NULL ), +"rtc" , (Object *)rtc_state,NULL ); }else {for (i =0 ; i <MAX_IDE_BUS ; i++) {ISADevice *dev;
hw/piix_pci.c +2 -2
@@ -277,7 +277,7 @@ static PCIBus *i440fx_common_init(const char *device_name, address_space_io, 0); s->bus = b;qdev_init_nofail (dev); -qdev_property_add_child (qdev_get_root (),"i440fx" , dev,NULL ); +object_property_add_child (object_get_root (),"i440fx" ,OBJECT (dev),NULL ); d =pci_create_simple (b,0 , device_name); *pi440fx_state =DO_UPCAST (PCII440FXState, dev, d);
@@ -316,7 +316,7 @@ static PCIBus *i440fx_common_init(const char *device_name,pci_bus_irqs (b, piix3_set_irq, pci_slot_get_pirq, piix3,PIIX_NUM_PIRQS ); } -qdev_property_add_child (dev,"piix3" , &piix3->dev.qdev,NULL ); +object_property_add_child (OBJECT (dev),"piix3" ,OBJECT (piix3),NULL ); piix3->pic = pic; *isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&piix3->dev.qdev,"isa.0" ));
hw/qdev-addr.c +4 -2
@@ -18,9 +18,10 @@ static int print_taddr(DeviceState *dev, Property *prop, char *dest, size_t len)return snprintf (dest, len,"0x" TARGET_FMT_plx, *ptr); } -static void get_taddr (DeviceState *dev,Visitor *v,void *opaque, +static void get_taddr (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { +DeviceState *dev =DEVICE (obj);Property *prop = opaque;target_phys_addr_t *ptr =qdev_get_prop_ptr (dev, prop);int64_t value;
@@ -29,9 +30,10 @@ static void get_taddr(DeviceState *dev, Visitor *v, void *opaque,visit_type_int (v, &value, name, errp); } -static void set_taddr (DeviceState *dev,Visitor *v,void *opaque, +static void set_taddr (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { +DeviceState *dev =DEVICE (obj);Property *prop = opaque;target_phys_addr_t *ptr =qdev_get_prop_ptr (dev, prop);Error *local_err =NULL ;
hw/qdev-monitor.c +12 -9
@@ -175,30 +175,32 @@ int qdev_device_help(QemuOpts *opts)return 1 ; } -static DeviceState *qdev_get_peripheral (void ) +static Object *qdev_get_peripheral (void ) {static DeviceState *dev;if (dev ==NULL ) { dev =qdev_create (NULL ,"container" ); -qdev_property_add_child (qdev_get_root (),"peripheral" , dev,NULL ); +object_property_add_child (object_get_root (),"peripheral" , +OBJECT (dev),NULL );qdev_init_nofail (dev); } -return dev; +return OBJECT (dev); } -static DeviceState *qdev_get_peripheral_anon (void ) +static Object *qdev_get_peripheral_anon (void ) {static DeviceState *dev;if (dev ==NULL ) { dev =qdev_create (NULL ,"container" ); -qdev_property_add_child (qdev_get_root (),"peripheral-anon" , dev,NULL ); +object_property_add_child (object_get_root (),"peripheral-anon" , +OBJECT (dev),NULL );qdev_init_nofail (dev); } -return dev; +return OBJECT (dev); }static void qbus_list_bus (DeviceState *dev)
@@ -457,12 +459,13 @@ DeviceState *qdev_device_add(QemuOpts *opts) id =qemu_opts_id (opts);if (id) { qdev->id = id; -qdev_property_add_child (qdev_get_peripheral (), qdev->id, qdev,NULL ); +object_property_add_child (qdev_get_peripheral (), qdev->id, +OBJECT (qdev),NULL ); }else {static int anon_count;gchar *name =g_strdup_printf ("device[%d]" , anon_count++); -qdev_property_add_child (qdev_get_peripheral_anon (), name, - qdev,NULL ); +object_property_add_child (qdev_get_peripheral_anon (), name, +OBJECT (qdev),NULL );g_free (name); }if (qemu_opt_foreach (opts, set_property, qdev,1 ) !=0 ) {
hw/qdev-properties.c +35 -18
188 lines not on this page · raw message
hw/qdev.c +16 -474
555 lines not on this page · raw message
hw/qdev.h +2 -275
307 lines not on this page · raw message
include/qemu/object.h +222 -1
247 lines not on this page · raw message
qapi-schema.json +11 -11
@@ -1228,20 +1228,20 @@ # # Notes: This type is experimental. Its syntax may change in future releases. ## -{ 'type': 'DevicePropertyInfo', +{ 'type': 'ObjectPropertyInfo', 'data': { 'name': 'str', 'type': 'str' } } ## # @qom-list: # -# This command will list any properties of a device given a path in the device +# This command will list any properties of a object given a path in the object # model. # -# @path: the path within the device model. See @qom-get for a description of +# @path: the path within the object model. See @qom-get for a description of # this parameter. # -# Returns: a list of @DevicePropertyInfo that describe the properties of the -# device. +# Returns: a list of @ObjectPropertyInfo that describe the properties of the +# object. # # Since: 1.1 #
@@ -1250,25 +1250,25 @@ ## { 'command': 'qom-list', 'data': { 'path': 'str' }, - 'returns': [ 'DevicePropertyInfo' ] } + 'returns': [ 'ObjectPropertyInfo' ] } ## # @qom-get: # -# This command will get a property from a device model path and return the +# This command will get a property from a object model path and return the # value. # -# @path: The path within the device model. There are two forms of supported +# @path: The path within the object model. There are two forms of supported # paths--absolute and partial paths. # -# Absolute paths are derived from the root device and can follow child<> +# Absolute paths are derived from the root object and can follow child<> # or link<> properties. Since they can follow link<> properties, they # can be arbitrarily long. Absolute paths look like absolute filenames # and are prefixed with a leading slash. # # Partial paths look like relative filenames. They do not begin # with a prefix. The matching rules for partial paths are subtle but -# designed to make specifying devices easy. At each level of the +# designed to make specifying objects easy. At each level of the # composition tree, the partial path is matched as an absolute path. # The first match is not returned. At least two matches are searched # for. A successful result is only returned if only one match is
@@ -1294,7 +1294,7 @@ ## # @qom-set: # -# This command will set a property from a device model path. +# This command will set a property from a object model path. # # @path: see @qom-get for a description of this parameter #
qmp.c +17 -17
@@ -164,23 +164,23 @@ void qmp_cont(Error **errp)vm_start (); } -DevicePropertyInfoList *qmp_qom_list (const char *path,Error **errp) +ObjectPropertyInfoList *qmp_qom_list (const char *path,Error **errp) { -DeviceState *dev; +Object *obj;bool ambiguous = false; -DevicePropertyInfoList *props =NULL ; -DeviceProperty *prop; +ObjectPropertyInfoList *props =NULL ; +ObjectProperty *prop; - dev =qdev_resolve_path (path, &ambiguous); -if (dev ==NULL ) { + obj =object_resolve_path (path, &ambiguous); +if (obj ==NULL ) {error_set (errp,QERR_DEVICE_NOT_FOUND , path);return NULL ; } - QTAILQ_FOREACH(prop, &dev->properties, node) { -DevicePropertyInfoList *entry =g_malloc0 (sizeof (*entry)); + QTAILQ_FOREACH(prop, &obj->properties, node) { +ObjectPropertyInfoList *entry =g_malloc0 (sizeof (*entry)); - entry->value =g_malloc0 (sizeof (DevicePropertyInfo)); + entry->value =g_malloc0 (sizeof (ObjectPropertyInfo)); entry->next = props; props = entry;
@@ -199,16 +199,16 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)QObject *value =qdict_get (qdict,"value" );Error *local_err =NULL ;QmpInputVisitor *mi; -DeviceState *dev; +Object *obj; - dev =qdev_resolve_path (path,NULL ); -if (!dev) { + obj =object_resolve_path (path,NULL ); +if (!obj) {error_set (&local_err,QERR_DEVICE_NOT_FOUND , path); goto out; } mi =qmp_input_visitor_new (value); -qdev_property_set (dev,qmp_input_get_visitor (mi), property, &local_err); +object_property_set (obj,qmp_input_get_visitor (mi), property, &local_err);qmp_input_visitor_cleanup (mi);
@@ -228,16 +228,16 @@ int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret)const char *property =qdict_get_str (qdict,"property" );Error *local_err =NULL ;QmpOutputVisitor *mo; -DeviceState *dev; +Object *obj; - dev =qdev_resolve_path (path,NULL ); -if (!dev) { + obj =object_resolve_path (path,NULL ); +if (!obj) {error_set (&local_err,QERR_DEVICE_NOT_FOUND , path); goto out; } mo =qmp_output_visitor_new (); -qdev_property_get (dev,qmp_output_get_visitor (mo), property, &local_err); +object_property_get (obj,qmp_output_get_visitor (mo), property, &local_err);if (!local_err) { *ret =qmp_output_get_qobject (mo); }
qom/object.c +457 -0
490 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 17/23] qom: move properties from qdev to object
Quoted 3 lines · Anthony Liguori
This is mostly code movement although not entirely. This makes properties part of the Object base class which means that we can now start using Object in a meaningful way outside of qdev.
Can we move them to an intermediate base class? I would like to use QOM refcounting for other objects, such as SCSIRequest, so it is important to have Object as a pretty light-weight class. Also (and perhaps more importantly), interface implementations are Objects too and they do not need properties.
I cannot think of any better name than IntrospectableObject, which is quite a mouthful. I suppose that we could have the base class but still pass the objects to the function as Object * and use the OBJECT macro. Nothing of this is in a hot path anyway.
Paolo
Re: [Qemu-devel] [PATCH 17/23] qom: move properties from qdev to object
Quoted 10 lines · Paolo Bonzini
Quoted 3 lines · Anthony Liguori
This is mostly code movement although not entirely. This makes properties part of the Object base class which means that we can now start using Object in a meaningful way outside of qdev.
Can we move them to an intermediate base class? I would like to use QOM refcounting for other objects, such as SCSIRequest, so it is important to have Object as a pretty light-weight class. Also (and perhaps more importantly), interface implementations are Objects too and they do not need properties.
Quoted 4 lines
I cannot think of any better name than IntrospectableObject, which is quite a mouthful. I suppose that we could have the base class but still pass the objects to the function as Object * and use the OBJECT macro. Nothing of this is in a hot path anyway.
I'm just not sure how I feel about this.
The overhead of properties are small in terms of object size. It's just sizeof(void *).
I think that read-only properties could be interesting for SCSIRequest. For instance, I can imagine having SCSIRequest is-a BlockRequest and having an error property associated with it. That would provide a nice way to have an info io operation that returned a list of failed I/O requests or something like that.
Regards,
Anthony Liguori
Quoted 3 lines
Paolo
Re: [Qemu-devel] [PATCH 17/23] qom: move properties from qdev to object
Quoted 5 lines · Anthony Liguori
I think that read-only properties could be interesting for SCSIRequest. For instance, I can imagine having SCSIRequest is-a BlockRequest and having an error property associated with it. That would provide a nice way to have an info io operation that returned a list of failed I/O requests or something like that.
SCSIRequests can have a BlockRequest as a child; not all SCSIRequests have I/O attached to them, but I see the general concept. I'm not sure we'll be able to optimize enough, but we can certainly try...
Paolo
PATCH 18/23 qom: accept any compatible type when setting a link property
In reply to Anthony LiguoriLinks had limited utility before as they only allowed a concrete type to be specified. Now we can support abstract types and interfaces which means it's now possible to have a link<PCIDevice>.
--- qom/object.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
qom/object.c +5 -4
@@ -724,11 +724,12 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,if (target) {gchar *target_type; - target_type =g_strdup_printf ("link<%s>" , -object_get_typename (OBJECT (target))); -if (strcmp (target_type, type) ==0 ) { - *child = target; + target_type =g_strdup (&type[5 ]); + target_type[strlen (target_type) -2 ] =0 ; + +if (object_dynamic_cast (target, target_type)) {object_ref (target); + *child = target; }else {error_set (errp,QERR_INVALID_PARAMETER_TYPE , name, type); }
Signature · 1 line
1.7.4.1
PATCH 19/23 qdev: implement cleanup logic in finalize
In reply to Anthony Liguori--- hw/qdev.c | 57 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 32 insertions(+), 25 deletions(-)
hw/qdev.c +32 -25
@@ -246,31 +246,6 @@ void qdev_init_nofail(DeviceState *dev)/* Unlink device from bus and free the structure. */ void qdev_free (DeviceState *dev) { -BusState *bus; -Property *prop; -DeviceClass *dc =DEVICE_GET_CLASS (dev); - -if (dev->state ==DEV_STATE_INITIALIZED ) { -while (dev->num_child_bus) { - bus =QLIST_FIRST (&dev->child_bus); -qbus_free (bus); - } -if (qdev_get_vmsd (dev)) { -vmstate_unregister (dev,qdev_get_vmsd (dev), dev); - } -if (dc->exit) { - dc->exit (dev); - } -if (dev->opts) { -qemu_opts_del (dev->opts); - } - } -QTAILQ_REMOVE (&dev->parent_bus->children, dev, sibling); -for (prop =qdev_get_props (dev); prop && prop->name; prop++) { -if (prop->info->free) { - prop->info->free (dev, prop); - } - }object_delete (OBJECT (dev)); }
@@ -633,6 +608,37 @@ static void device_initfn(Object *obj)object_property_add_str (OBJECT (dev),"type" , qdev_get_type,NULL ,NULL ); } +/* Unlink device from bus and free the structure. */ +static void device_finalize (Object *obj) +{ +DeviceState *dev =DEVICE (obj); +BusState *bus; +Property *prop; +DeviceClass *dc =DEVICE_GET_CLASS (dev); + +if (dev->state ==DEV_STATE_INITIALIZED ) { +while (dev->num_child_bus) { + bus =QLIST_FIRST (&dev->child_bus); +qbus_free (bus); + } +if (qdev_get_vmsd (dev)) { +vmstate_unregister (dev,qdev_get_vmsd (dev), dev); + } +if (dc->exit) { + dc->exit (dev); + } +if (dev->opts) { +qemu_opts_del (dev->opts); + } + } +QTAILQ_REMOVE (&dev->parent_bus->children, dev, sibling); +for (prop =qdev_get_props (dev); prop && prop->name; prop++) { +if (prop->info->free) { + prop->info->free (dev, prop); + } + } +} +void device_reset (DeviceState *dev) {DeviceClass *klass =DEVICE_GET_CLASS (dev);
@@ -647,6 +653,7 @@ static TypeInfo device_type_info = { .parent = TYPE_OBJECT, .instance_size = sizeof(DeviceState), .instance_init = device_initfn, + .instance_finalize = device_finalize, .abstract = true, .class_size = sizeof(DeviceClass), };
Signature · 1 line
1.7.4.1
PATCH 20/23 info qdm: do not require a parent_bus to be set
In reply to Anthony Liguori--- hw/qdev-monitor.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
hw/qdev-monitor.c +7 -5
@@ -165,12 +165,14 @@ int qdev_device_help(QemuOpts *opts)error_printf ("%s.%s=%s\n" , driver, prop->name, prop->info->legacy_name ?: prop->info->name); } -for (prop = info->bus_info->props; prop && prop->name; prop++) { -if (!prop->info->parse) { -continue ;/* no way to set it, don't show */ +if (info->bus_info) { +for (prop = info->bus_info->props; prop && prop->name; prop++) { +if (!prop->info->parse) { +continue ;/* no way to set it, don't show */ + } +error_printf ("%s.%s=%s\n" , driver, prop->name, + prop->info->legacy_name ?: prop->info->name); } -error_printf ("%s.%s=%s\n" , driver, prop->name, - prop->info->legacy_name ?: prop->info->name); }return 1 ; }
Signature · 1 line
1.7.4.1
PATCH 21/23 object: sure up reference counting
In reply to Anthony LiguoriNow we have the following behavior:
1) object_new() returns an object with ref = 1
2) object_initialize() does not increase the reference count (ref may be 0).
3) object_deref() will finalize the object when ref = 0. it does not free the memory associated with the object.
4) both link and child properties correctly set the reference count.
The expected usage is the following:
1) child devices should generally be created via object_initialize() using memory from the parent device. Adding the object as a child property will take ownership of the object and tie the child's life cycle to the parent.
2) If a child device is created via qdev_create() or some other form of object_new(), there must be an object_delete() call in the parent device's finalize function.
--- qom/object.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-)
qom/object.c +18 -2
@@ -331,6 +331,8 @@ void object_finalize(void *data)object_deinit (obj, ti);object_property_del_all (obj); + +g_assert (obj->ref ==0 ); }Object *object_new_with_type (Type type)
@@ -341,6 +343,7 @@ Object *object_new_with_type(Type type) obj =g_malloc (type->instance_size);object_initialize_with_type (obj, type); +object_ref (obj);return obj; }
@@ -354,7 +357,8 @@ Object *object_new(const char *typename)void object_delete (Object *obj) { -object_finalize (obj); +object_unref (obj); +g_assert (obj->ref ==0 );g_free (obj); }
@@ -552,6 +556,10 @@ void object_unref(Object *obj) {g_assert (obj->ref >0 ); obj->ref--; + +if (obj->ref ==0 ) { +object_finalize (obj); + } } void object_property_add(Object *obj, const char *name, const char *type,
@@ -668,6 +676,14 @@ static void object_get_child_property(Object *obj, Visitor *v, void *opaque,g_free (path); } +static void object_finalize_child_property (Object *obj,const char *name, +void *opaque) +{ +Object *child = opaque; + +object_unref (child); +} +void object_property_add_child (Object *obj,const char *name,Object *child,Error **errp) {
@@ -676,7 +692,7 @@ void object_property_add_child(Object *obj, const char *name, type =g_strdup_printf ("child<%s>" ,object_get_typename (OBJECT (child)));object_property_add (obj, name, type, object_get_child_property, -NULL ,NULL , child, errp); +NULL , object_finalize_child_property, child, errp);object_ref (child);g_assert (child->parent ==NULL );
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 21/23] object: sure up reference counting
Quoted 10 lines · Anthony Liguori
Now we have the following behavior:
1)
object_new()returns an object with ref = 1
2)object_initialize()does not increase the reference count (ref may be 0).
3)object_deref()will finalize the object when ref = 0. it does not free the memory associated with the object.
4) both link and child properties correctly set the reference count.The expected usage is the following:
Quoted 7 lines
1) child devices should generally be created via
object_initialize()using memory from the parent device. Adding the object as a child property will take ownership of the object and tie the child's life cycle to the parent.2) If a child device is created via
qdev_create()or some other form ofobject_new(), there must be anobject_delete()call in the parent device's finalize function.
We might want to fix this by adding a special "created as child" refcount value, so that the object_delete can still be automatic. Adding floating references as they have them in GObject is also possible. I agree that it can be left for later, though.
Paolo
Re: [Qemu-devel] [PATCH 21/23] object: sure up reference counting
In reply to Anthony LiguoriSubject: [PATCH 21/23] object: sure up reference counting
Quoted 1 line · Anthony Liguori
Subject: [PATCH 21/23] object: sure up reference counting
"shore up", apparently, although I found that sufficiently unlikely in this context that it might be better to reword completely :-)
-- PMM
Re: [Qemu-devel] [PATCH 21/23] object: sure up reference counting
Quoted 8 lines · Peter Maydell
Subject: [PATCH 21/23] object: sure up reference counting
Quoted 1 line · Anthony Liguori
Subject: [PATCH 21/23] object: sure up reference counting
"shore up", apparently, although I found that sufficiently unlikely in this context that it might be better to reword completely :-)
After a few weeks of repetitive code conversion and rebasing the same series a million and a half times, I'm surprised I'm not speaking entirely in tongues :-)
Regards,
Anthony Liguori
Quoted 3 lines
-- PMM
PATCH 22/23 container: make a decendent of Object
In reply to Anthony Liguori--- Makefile.objs | 2 +- hw/container.c | 29 ----------------------------- hw/qdev-monitor.c | 14 ++++++-------- qom/Makefile | 2 +- qom/container.c | 15 +++++++++++++++ qom/object.c | 9 ++++----- 6 files changed, 27 insertions(+), 44 deletions(-) delete mode 100644 hw/container.c create mode 100644 qom/container.c
Makefile.objs +1 -1
@@ -286,7 +286,7 @@ hw-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o hw-obj-$(CONFIG_ESP) += esp.o hw-obj-y += dma-helpers.o sysbus.o isa-bus.o -hw-obj-y += qdev-addr.o container.o +hw-obj-y += qdev-addr.o # VGA hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o
hw/container.c deleted +0 -29
@@ -1,29 +0,0 @@ -#include "sysbus.h" - -static int container_initfn (SysBusDevice *dev) -{ -return 0 ; -} - -static void container_class_init (ObjectClass *klass,void *data) -{ -DeviceClass *dc =DEVICE_CLASS (klass); -SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); - - k->init = container_initfn; - dc->no_user =1 ; -} - -static TypeInfo container_info = { - .name ="container" , - .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (SysBusDevice), - .class_init = container_class_init, -}; - -static void container_init (void ) -{ -type_register_static (&container_info); -} - -device_init (container_init);
hw/qdev-monitor.c +6 -8
@@ -179,30 +179,28 @@ int qdev_device_help(QemuOpts *opts)static Object *qdev_get_peripheral (void ) { -static DeviceState *dev; +static Object *dev;if (dev ==NULL ) { - dev =qdev_create (NULL ,"container" ); + dev =object_new ("container" );object_property_add_child (object_get_root (),"peripheral" ,OBJECT (dev),NULL ); -qdev_init_nofail (dev); } -return OBJECT (dev); +return dev; }static Object *qdev_get_peripheral_anon (void ) { -static DeviceState *dev; +static Object *dev;if (dev ==NULL ) { - dev =qdev_create (NULL ,"container" ); + dev =object_new ("container" );object_property_add_child (object_get_root (),"peripheral-anon" ,OBJECT (dev),NULL ); -qdev_init_nofail (dev); } -return OBJECT (dev); +return dev; }static void qbus_list_bus (DeviceState *dev)
qom/Makefile +1 -1
@@ -1 +1 @@ -qom-y = object.o +qom-y = object.o container.o
qom/container.c new file +15 -0
@@ -0,0 +1,15 @@ +#include "qemu/object.h" +#include "module.h" + +static TypeInfo container_info = { + .name ="container" , + .instance_size =sizeof (Object), + .parent =TYPE_OBJECT , +}; + +static void container_init (void ) +{ +type_register_static (&container_info); +} + +device_init (container_init);
qom/object.c +4 -5
@@ -655,14 +655,13 @@ const char *object_property_get_type(Object *obj, const char *name, Error **errpObject *object_get_root (void ) { -static DeviceState *object_root; +static Object *root; -if (!object_root) { - object_root =qdev_create (NULL ,"container" ); -qdev_init_nofail (object_root); +if (!root) { + root =object_new ("container" ); } -return OBJECT (object_root); +return root; } static void object_get_child_property(Object *obj, Visitor *v, void *opaque,
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 22/23] container: make a decendent of Object
Quoted 6 lines · Anthony Liguori
qom/container.c new file +0
-0
qom/container.c line 9
Quoted 9 lines
qom/container.c new file +9
-0@@ -0,0 +1,15 @@ +#include "qemu/object.h" +#include "module.h" + +static TypeInfo container_info = { + .name ="container" , + .instance_size =sizeof (Object), + .parent =TYPE_OBJECT , +}; +
License header, please. (GPLv2+ or LGPLv2+?)
Paolo
Re: [Qemu-devel] [PATCH 22/23] container: make a decendent of Object
Am 31.01.2012 08:50, schrieb Paolo Bonzini:
Quoted 10 lines · Anthony Liguori
Quoted 9 lines
qom/container.c new file +3
-0@@ -0,0 +1,15 @@ +#include "qemu/object.h" +#include "module.h" +
Quoted 8 lines
qom/container.c line 9
Quoted 6 lines
qom/container.c new file +6
-0+static TypeInfo container_info = { + .name ="container" , + .instance_size =sizeof (Object), + .parent =TYPE_OBJECT , +}; +License header, please. (GPLv2+ or LGPLv2+?)
Given that object.c is GPLv2+, I've sticked with that license myself; but was that choice of license intentional? Effectively means we can't really have any liberally-licensed device emulation. (But same holds for MemoryAPI.)
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 22/23] container: make a decendent of Object
Quoted 6 lines · Andreas Färber
Quoted 2 lines
Quoted 2 lines
License header, please. (GPLv2+ or LGPLv2+?)
Given that
object.cis GPLv2+, I've sticked with that license myself; but was that choice of license intentional? Effectively means we can't really have any liberally-licensed device emulation. (But same holds for MemoryAPI.)
Actually you can. It's the combination that cannot be released liberally, but that's already the case without QOM or MemoryRegion.
If somebody wishes to port such a module to a proprietary platform (which doesn't have QOM or other GPL bits), they can.
Paolo
Re: [Qemu-devel] [PATCH 22/23] container: make a decendent of Object
In reply to Anthony LiguoriQuoted 1 line · Anthony Liguori
Subject: [PATCH 22/23] container: make a decendent of Object
"descendant".
-- PMM
PATCH 23/23 not-for-upstream: fix device_del
In reply to Anthony LiguoriThis needs to be carefully merged back but I'm not 100% confident the problem is solved by this commit.
--- hw/pci.c | 1 + hw/qdev.c | 1 + include/qemu/object.h | 4 +++- qom/object.c | 13 ++++++++++--- 4 files changed, 15 insertions(+), 4 deletions(-)
hw/pci.c +1 -0
@@ -1517,6 +1517,7 @@ static int pci_unplug_device(DeviceState *qdev)qerror_report (QERR_DEVICE_NO_HOTPLUG ,object_get_typename (OBJECT (dev)));return -1 ; } +object_unparent (OBJECT (dev));return dev->bus->hotplug (dev->bus->hotplug_qdev, dev,PCI_HOTPLUG_DISABLED ); }
hw/qdev.c +1 -0
@@ -222,6 +222,7 @@ void qbus_reset_all_fn(void *opaque)int qdev_simple_unplug_cb (DeviceState *dev) {/* just zap it */ +object_unparent (OBJECT (dev));qdev_free (dev);return 0 ; }
include/qemu/object.h +3 -1
@@ -524,7 +524,9 @@ void object_property_add(Object *obj, const char *name, const char *type, ObjectPropertyRelease *release, void *opaque, struct Error **errp); -void object_property_del (Object *obj,const char *name,Error **errp); +void object_property_del (Object *obj,const char *name,struct Error **errp); + +void object_unparent (Object *obj);/** * object_property_get:
qom/object.c +10 -3
@@ -304,6 +304,13 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp) } } +void object_unparent (Object *obj) +{ +if (obj->parent) { +object_property_del_child (obj->parent, obj,NULL ); + } +} +static void object_deinit (Object *obj,TypeImpl *type) {if (type->instance_finalize) {
@@ -319,9 +326,8 @@ static void object_deinit(Object *obj, TypeImpl *type)if (type_has_parent (type)) {object_deinit (obj,type_get_parent (type)); } -if (obj->parent) { -object_property_del_child (obj->parent, obj,NULL ); - } + +object_unparent (obj); }void object_finalize (void *data)
@@ -557,6 +563,7 @@ void object_unref(Object *obj)g_assert (obj->ref >0 ); obj->ref--; +/* parent always holds a reference to its children */ if (obj->ref ==0 ) {object_finalize (obj); }
Signature · 1 line
1.7.4.1
cover qom: use Type system to register all devices
In reply to Anthony Liguori(Sorry for not posting this correctly, I didn't want to spam the list with a second submission)
This is the 3rd QOM series. I decided to post this even though there's a known issue with device_del as I wanted to give people more time to review what's going on here.
The goal of this series is to make DeviceState a first class QOM base class. The result is that you can object_new(TYPE_E1000) and have a functioning device.
qdev_create() and qdev_free() are now trivialized as QOM wrappers.
Patch 8/23 is an automated touch everything patch. I decided to leave it as one big patch because this is entirely programmatic. There's no intelligence in this patch so I think it's easier to review quickly as one big change.
The other notable feature of this series it that properties have been moved to the Object base class. This means that other subsystems can begin using QOM.
This is the last touch every file in the tree series.
b/Makefile.objs | 4 b/hw/9pfs/virtio-9p-device.c | 16 b/hw/a9mpcore.c | 40 - b/hw/ac97.c | 18 b/hw/acpi_piix4.c | 20 b/hw/ads7846.c | 11 b/hw/alpha_typhoon.c | 14 b/hw/apb_pci.c | 41 - b/hw/apic.c | 10 b/hw/apic_common.c | 15 b/hw/apic_internal.h | 1 b/hw/applesmc.c | 28 - b/hw/arm11mpcore.c | 28 - b/hw/arm_l2x0.c | 24 b/hw/arm_mptimer.c | 28 - b/hw/arm_sysctl.c | 18 b/hw/arm_timer.c | 35 - b/hw/armv7m.c | 14 b/hw/armv7m_nvic.c | 32 - b/hw/bitbang_i2c.c | 14 b/hw/bonito.c | 32 - b/hw/ccid-card-emulated.c | 35 - b/hw/ccid-card-passthru.c | 28 - b/hw/ccid.h | 1 b/hw/cirrus_vga.c | 30 - b/hw/cs4231.c | 18 b/hw/cs4231a.c | 30 - b/hw/debugcon.c | 26 b/hw/dec_pci.c | 40 - b/hw/ds1225y.c | 16 b/hw/ds1338.c | 11 b/hw/e1000.c | 20 b/hw/eccmemctl.c | 18 b/hw/eepro100.c | 83 +-- b/hw/empty_slot.c | 11 b/hw/es1370.c | 16 b/hw/escc.c | 18 b/hw/esp.c | 18 b/hw/etraxfs_eth.c | 14 b/hw/etraxfs_pic.c | 14 b/hw/etraxfs_ser.c | 16 b/hw/etraxfs_timer.c | 11 b/hw/fdc.c | 76 +- b/hw/fw_cfg.c | 20 b/hw/g364fb.c | 20 b/hw/grackle_pci.c | 26 b/hw/grlib_apbuart.c | 14 b/hw/grlib_gptimer.c | 16 b/hw/grlib_irqmp.c | 16 b/hw/gt64xxx.c | 22 b/hw/gus.c | 32 - b/hw/hda-audio.c | 36 - b/hw/highbank.c | 18 b/hw/hpet.c | 20 b/hw/i2c.c | 23 b/hw/i2c.h | 3 b/hw/i82374.c | 22 b/hw/i82378.c | 22 b/hw/i8254.c | 30 - b/hw/i8259.c | 11 b/hw/i8259_common.c | 13 b/hw/i8259_internal.h | 1 b/hw/ide/ahci.c | 24 b/hw/ide/cmd646.c | 14 b/hw/ide/ich.c | 15 b/hw/ide/isa.c | 30 - b/hw/ide/piix.c | 44 - b/hw/ide/qdev.c | 95 ++- b/hw/ide/via.c | 14 b/hw/integratorcp.c | 25 b/hw/intel-hda.c | 39 - b/hw/intel-hda.h | 1 b/hw/ioapic.c | 14 b/hw/ioapic_common.c | 10 b/hw/ioapic_internal.h | 1 b/hw/ioh3420.c | 20 b/hw/isa-bus.c | 38 - b/hw/isa.h | 2 b/hw/ivshmem.c | 16 b/hw/kvm/apic.c | 5 b/hw/kvm/clock.c | 16 b/hw/kvm/i8259.c | 8 b/hw/kvm/ioapic.c | 20 b/hw/lan9118.c | 18 b/hw/lance.c | 20 b/hw/lm32_juart.c | 18 b/hw/lm32_pic.c | 16 b/hw/lm32_sys.c | 18 b/hw/lm32_timer.c | 18 b/hw/lm32_uart.c | 18 b/hw/lm832x.c | 14 b/hw/lsi53c895a.c | 17 b/hw/m48t59.c | 46 - b/hw/macio.c | 11 b/hw/marvell_88w8618_audio.c | 18 b/hw/max111x.c | 22 b/hw/max7310.c | 16 b/hw/mc146818rtc.c | 34 - b/hw/milkymist-ac97.c | 16 b/hw/milkymist-hpdmc.c | 16 b/hw/milkymist-memcard.c | 16 b/hw/milkymist-minimac2.c | 18 b/hw/milkymist-pfpu.c | 16 b/hw/milkymist-softusb.c | 18 b/hw/milkymist-sysctl.c | 18 b/hw/milkymist-tmu2.c | 16 b/hw/milkymist-uart.c | 18 b/hw/milkymist-vgafb.c | 18 b/hw/mips_malta.c | 14 b/hw/mipsnet.c | 20 b/hw/mpc8544_guts.c | 11 b/hw/mst_fpga.c | 16 b/hw/musicpal.c | 117 ++-- b/hw/nand.c | 18 b/hw/ne2000-isa.c | 26 b/hw/ne2000.c | 16 b/hw/omap_gpio.c | 32 - b/hw/omap_intc.c | 32 - b/hw/onenand.c | 16 b/hw/opencores_eth.c | 18 b/hw/parallel.c | 28 - b/hw/pc.c | 18 b/hw/pc_piix.c | 6 b/hw/pci.c | 41 - b/hw/pci.h | 2 b/hw/pckbd.c | 16 b/hw/pcnet-pci.c | 18 b/hw/piix4.c | 18 b/hw/piix_pci.c | 74 +- b/hw/pl011.c | 24 b/hw/pl022.c | 11 b/hw/pl031.c | 16 b/hw/pl041.c | 20 b/hw/pl050.c | 28 - b/hw/pl061.c | 28 - b/hw/pl080.c | 32 - b/hw/pl110.c | 48 + b/hw/pl181.c | 18 b/hw/pl190.c | 18 b/hw/ppc4xx_pci.c | 28 - b/hw/ppc_prep.c | 2 b/hw/ppce500_pci.c | 28 - b/hw/ppce500_spin.c | 11 b/hw/prep_pci.c | 26 b/hw/pxa2xx.c | 56 +- b/hw/pxa2xx_dma.c | 18 b/hw/pxa2xx_gpio.c | 16 b/hw/pxa2xx_pic.c | 16 b/hw/pxa2xx_timer.c | 36 - b/hw/qdev-addr.c | 6 b/hw/qdev-monitor.c | 590 ++++++++++++++++++++++ b/hw/qdev-properties.c | 57 +- b/hw/qdev.c | 1144 +++---------------------------------------- b/hw/qdev.h | 367 +------------ b/hw/qxl.c | 40 - b/hw/realview.c | 11 b/hw/realview_gic.c | 11 b/hw/rtl8139.c | 18 b/hw/s390-virtio-bus.c | 137 ++--- b/hw/s390-virtio-bus.h | 19 b/hw/sb16.c | 34 - b/hw/sbi.c | 16 b/hw/scsi-bus.c | 21 b/hw/scsi-disk.c | 116 ++-- b/hw/scsi-generic.c | 28 - b/hw/scsi.h | 1 b/hw/serial.c | 30 - b/hw/sga.c | 14 b/hw/sh_pci.c | 22 b/hw/slavio_intctl.c | 16 b/hw/slavio_misc.c | 27 - b/hw/slavio_timer.c | 18 b/hw/smbus.c | 6 b/hw/smbus.h | 2 b/hw/smbus_eeprom.c | 22 b/hw/smc91c111.c | 18 b/hw/spapr_llan.c | 14 b/hw/spapr_pci.c | 22 b/hw/spapr_vio.c | 37 - b/hw/spapr_vio.h | 1 b/hw/spapr_vscsi.c | 14 b/hw/spapr_vty.c | 14 b/hw/sparc32_dma.c | 18 b/hw/spitz.c | 60 +- b/hw/ssd0303.c | 14 b/hw/ssd0323.c | 11 b/hw/ssi-sd.c | 11 b/hw/ssi.c | 26 b/hw/ssi.h | 2 b/hw/stellaris.c | 44 - b/hw/stellaris_enet.c | 14 b/hw/strongarm.c | 98 ++- b/hw/sun4c_intctl.c | 16 b/hw/sun4m.c | 50 + b/hw/sun4m_iommu.c | 18 b/hw/sun4u.c | 39 - b/hw/sysbus.c | 24 b/hw/sysbus.h | 4 b/hw/tcx.c | 18 b/hw/tmp105.c | 14 b/hw/tosa.c | 24 b/hw/tusb6010.c | 14 b/hw/twl92230.c | 14 b/hw/unin_pci.c | 74 +- b/hw/usb-audio.c | 29 - b/hw/usb-bt.c | 14 b/hw/usb-bus.c | 25 b/hw/usb-ccid.c | 46 - b/hw/usb-ehci.c | 32 - b/hw/usb-hid.c | 72 +- b/hw/usb-hub.c | 18 b/hw/usb-msd.c | 31 - b/hw/usb-net.c | 27 - b/hw/usb-ohci.c | 42 - b/hw/usb-serial.c | 50 + b/hw/usb-uhci.c | 96 ++- b/hw/usb-wacom.c | 21 b/hw/usb-xhci.c | 25 b/hw/usb.h | 5 b/hw/versatile_pci.c | 33 - b/hw/versatilepb.c | 16 b/hw/vga-isa.c | 16 b/hw/vga-pci.c | 14 b/hw/virtio-console.c | 28 - b/hw/virtio-pci.c | 68 +- b/hw/virtio-serial-bus.c | 21 b/hw/virtio-serial.h | 6 b/hw/vmmouse.c | 28 - b/hw/vmport.c | 14 b/hw/vmware_vga.c | 16 b/hw/vt82c686.c | 64 +- b/hw/wdt_i6300esb.c | 16 b/hw/wdt_ib700.c | 16 b/hw/wm8750.c | 14 b/hw/xen_platform.c | 18 b/hw/xgmac.c | 25 b/hw/xilinx_axidma.c | 14 b/hw/xilinx_axienet.c | 14 b/hw/xilinx_ethlite.c | 14 b/hw/xilinx_intc.c | 14 b/hw/xilinx_timer.c | 14 b/hw/xilinx_uartlite.c | 13 b/hw/xio3130_downstream.c | 20 b/hw/xio3130_upstream.c | 20 b/hw/z2.c | 28 - b/hw/zaurus.c | 18 b/include/qemu/object.h | 226 ++++++++ b/qapi-schema.json | 55 +- b/qemu-char.c | 10 b/qemu-char.h | 2 b/qerror.c | 2 b/qmp-commands.hx | 5 b/qmp.c | 61 +- b/qom/Makefile | 2 b/qom/container.c | 15 b/qom/object.c | 500 ++++++++++++++++++ b/usb-linux.c | 35 - hw/container.c | 27 - 258 files changed, 4817 insertions(+), 4058 deletions(-)
Re: [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices
Quoted 6 lines · Anthony Liguori
(Sorry for not posting this correctly, I didn't want to spam the list with a second submission)
This is the 3rd QOM series. I decided to post this even though there's a known issue with
device_delas I wanted to give people more time to review what's going on here.
I think the "lingering issue with device_del" is that my broken battery is causing my laptop to overheat... So I'll fold patch 23 into the right spot and repost tomorrow.
Could use another set of eyes to walk through the reference counting stuff though. It's a bit nastier than I would like it to be. I really dislike the notion of having an object_unparent in the unplug path.
Regards,
Anthony Liguori
Quoted 275 lines
The goal of this series is to make DeviceState a first class QOM base class. The result is that you can
object_new(TYPE_E1000)and have a functioning device.qdev_create()andqdev_free()are now trivialized as QOM wrappers.Patch 8/23 is an automated touch everything patch. I decided to leave it as one big patch because this is entirely programmatic. There's no intelligence in this patch so I think it's easier to review quickly as one big change.
The other notable feature of this series it that properties have been moved to the Object base class. This means that other subsystems can begin using QOM.
This is the last touch every file in the tree series.
b/Makefile.objs | 4
b/hw/9pfs/virtio-9p-device.c| 16b/hw/a9mpcore.c| 40 -b/hw/ac97.c| 18b/hw/acpi_piix4.c| 20b/hw/ads7846.c| 11b/hw/alpha_typhoon.c| 14b/hw/apb_pci.c| 41 -b/hw/apic.c| 10b/hw/apic_common.c| 15b/hw/apic_internal.h| 1b/hw/applesmc.c| 28 -b/hw/arm11mpcore.c| 28 -b/hw/arm_l2x0.c| 24b/hw/arm_mptimer.c| 28 -b/hw/arm_sysctl.c| 18b/hw/arm_timer.c| 35 -b/hw/armv7m.c| 14b/hw/armv7m_nvic.c| 32 -b/hw/bitbang_i2c.c| 14b/hw/bonito.c| 32 -b/hw/ccid-card-emulated.c| 35 -b/hw/ccid-card-passthru.c| 28 -b/hw/ccid.h| 1b/hw/cirrus_vga.c| 30 -b/hw/cs4231.c| 18b/hw/cs4231a.c| 30 -b/hw/debugcon.c| 26b/hw/dec_pci.c| 40 -b/hw/ds1225y.c| 16b/hw/ds1338.c| 11b/hw/e1000.c| 20b/hw/eccmemctl.c| 18b/hw/eepro100.c| 83 +--b/hw/empty_slot.c| 11b/hw/es1370.c| 16b/hw/escc.c| 18b/hw/esp.c| 18b/hw/etraxfs_eth.c | 14 b/hw/etraxfs_pic.c | 14 b/hw/etraxfs_ser.c | 16
b/hw/etraxfs_timer.c| 11b/hw/fdc.c| 76 +-b/hw/fw_cfg.c| 20b/hw/g364fb.c| 20b/hw/grackle_pci.c| 26b/hw/grlib_apbuart.c| 14b/hw/grlib_gptimer.c| 16b/hw/grlib_irqmp.c| 16b/hw/gt64xxx.c| 22b/hw/gus.c| 32 -b/hw/hda-audio.c| 36 -b/hw/highbank.c| 18b/hw/hpet.c| 20b/hw/i2c.c| 23b/hw/i2c.h| 3b/hw/i82374.c| 22b/hw/i82378.c| 22b/hw/i8254.c| 30 -b/hw/i8259.c| 11b/hw/i8259_common.c| 13b/hw/i8259_internal.h| 1b/hw/ide/ahci.c| 24b/hw/ide/cmd646.c| 14b/hw/ide/ich.c| 15b/hw/ide/isa.c| 30 -b/hw/ide/piix.c| 44 -b/hw/ide/qdev.c| 95 ++-b/hw/ide/via.c| 14b/hw/integratorcp.c| 25b/hw/intel-hda.c| 39 -b/hw/intel-hda.h| 1b/hw/ioapic.c| 14b/hw/ioapic_common.c| 10b/hw/ioapic_internal.h| 1b/hw/ioh3420.c| 20b/hw/isa-bus.c| 38 -b/hw/isa.h| 2b/hw/ivshmem.c| 16b/hw/kvm/apic.c| 5b/hw/kvm/clock.c| 16b/hw/kvm/i8259.c| 8b/hw/kvm/ioapic.c| 20b/hw/lan9118.c| 18b/hw/lance.c| 20b/hw/lm32_juart.c| 18b/hw/lm32_pic.c| 16b/hw/lm32_sys.c| 18b/hw/lm32_timer.c| 18b/hw/lm32_uart.c| 18b/hw/lm832x.c| 14b/hw/lsi53c895a.c| 17b/hw/m48t59.c| 46 -b/hw/macio.c| 11b/hw/marvell_88w8618_audio.c| 18b/hw/max111x.c| 22b/hw/max7310.c| 16b/hw/mc146818rtc.c| 34 -b/hw/milkymist-ac97.c| 16b/hw/milkymist-hpdmc.c| 16b/hw/milkymist-memcard.c| 16b/hw/milkymist-minimac2.c| 18b/hw/milkymist-pfpu.c| 16b/hw/milkymist-softusb.c| 18b/hw/milkymist-sysctl.c| 18b/hw/milkymist-tmu2.c| 16b/hw/milkymist-uart.c| 18b/hw/milkymist-vgafb.c| 18b/hw/mips_malta.c| 14b/hw/mipsnet.c| 20b/hw/mpc8544_guts.c| 11b/hw/mst_fpga.c| 16b/hw/musicpal.c| 117 ++--b/hw/nand.c| 18b/hw/ne2000-isa.c| 26b/hw/ne2000.c| 16b/hw/omap_gpio.c| 32 -b/hw/omap_intc.c| 32 -b/hw/onenand.c| 16b/hw/opencores_eth.c| 18b/hw/parallel.c| 28 -b/hw/pc.c| 18b/hw/pc_piix.c| 6b/hw/pci.c| 41 -b/hw/pci.h| 2b/hw/pckbd.c| 16b/hw/pcnet-pci.c| 18b/hw/piix4.c| 18b/hw/piix_pci.c| 74 +-b/hw/pl011.c | 24 b/hw/pl022.c | 11 b/hw/pl031.c | 16 b/hw/pl041.c | 20 b/hw/pl050.c | 28 - b/hw/pl061.c | 28 - b/hw/pl080.c | 32 - b/hw/pl110.c | 48 + b/hw/pl181.c | 18 b/hw/pl190.c | 18
b/hw/ppc4xx_pci.c| 28 -b/hw/ppc_prep.c| 2b/hw/ppce500_pci.c| 28 -b/hw/ppce500_spin.c| 11b/hw/prep_pci.c| 26b/hw/pxa2xx.c| 56 +-b/hw/pxa2xx_dma.c| 18b/hw/pxa2xx_gpio.c| 16b/hw/pxa2xx_pic.c| 16b/hw/pxa2xx_timer.c| 36 -b/hw/qdev-addr.c| 6b/hw/qdev-monitor.c| 590 ++++++++++++++++++++++b/hw/qdev-properties.c| 57 +-b/hw/qdev.c| 1144 +++----------------------------------------b/hw/qdev.h| 367 +------------b/hw/qxl.c| 40 -b/hw/realview.c| 11b/hw/realview_gic.c| 11b/hw/rtl8139.c| 18b/hw/s390-virtio-bus.c| 137 ++---b/hw/s390-virtio-bus.h| 19b/hw/sb16.c| 34 -b/hw/sbi.c| 16b/hw/scsi-bus.c| 21b/hw/scsi-disk.c| 116 ++--b/hw/scsi-generic.c| 28 -b/hw/scsi.h| 1b/hw/serial.c| 30 -b/hw/sga.c| 14b/hw/sh_pci.c| 22b/hw/slavio_intctl.c| 16b/hw/slavio_misc.c| 27 -b/hw/slavio_timer.c| 18b/hw/smbus.c| 6b/hw/smbus.h| 2b/hw/smbus_eeprom.c| 22b/hw/smc91c111.c| 18b/hw/spapr_llan.c| 14b/hw/spapr_pci.c | 22 b/hw/spapr_vio.c | 37 - b/hw/spapr_vio.h | 1
b/hw/spapr_vscsi.c| 14b/hw/spapr_vty.c| 14b/hw/sparc32_dma.c| 18b/hw/spitz.c| 60 +-b/hw/ssd0303.c| 14b/hw/ssd0323.c| 11b/hw/ssi-sd.c| 11b/hw/ssi.c| 26b/hw/ssi.h| 2b/hw/stellaris.c| 44 -b/hw/stellaris_enet.c| 14b/hw/strongarm.c| 98 ++-b/hw/sun4c_intctl.c| 16b/hw/sun4m.c| 50 +b/hw/sun4m_iommu.c| 18b/hw/sun4u.c| 39 -b/hw/sysbus.c| 24b/hw/sysbus.h| 4b/hw/tcx.c| 18b/hw/tmp105.c| 14b/hw/tosa.c| 24b/hw/tusb6010.c | 14 b/hw/twl92230.c | 14 b/hw/unin_pci.c | 74 +-
b/hw/usb-audio.c| 29 -b/hw/usb-bt.c| 14b/hw/usb-bus.c| 25b/hw/usb-ccid.c| 46 -b/hw/usb-ehci.c| 32 -b/hw/usb-hid.c | 72 +- b/hw/usb-hub.c | 18 b/hw/usb-msd.c | 31 - b/hw/usb-net.c | 27 -
b/hw/usb-ohci.c| 42 -b/hw/usb-serial.c| 50 +b/hw/usb-uhci.c| 96 ++-b/hw/usb-wacom.c| 21b/hw/usb-xhci.c| 25b/hw/usb.h| 5b/hw/versatile_pci.c| 33 -b/hw/versatilepb.c| 16b/hw/vga-isa.c| 16b/hw/vga-pci.c| 14b/hw/virtio-console.c| 28 -b/hw/virtio-pci.c| 68 +-b/hw/virtio-serial-bus.c| 21b/hw/virtio-serial.h| 6b/hw/vmmouse.c| 28 -b/hw/vmport.c| 14b/hw/vmware_vga.c| 16b/hw/vt82c686.c| 64 +-b/hw/wdt_i6300esb.c| 16b/hw/wdt_ib700.c| 16b/hw/wm8750.c| 14b/hw/xen_platform.c| 18b/hw/xgmac.c| 25b/hw/xilinx_axidma.c| 14b/hw/xilinx_axienet.c| 14b/hw/xilinx_ethlite.c| 14b/hw/xilinx_intc.c| 14b/hw/xilinx_timer.c| 14b/hw/xilinx_uartlite.c| 13b/hw/xio3130_downstream.c| 20b/hw/xio3130_upstream.c| 20b/hw/z2.c| 28 -b/hw/zaurus.c| 18b/include/qemu/object.h| 226 ++++++++b/qapi-schema.json| 55 +-b/qemu-char.c| 10b/qemu-char.h| 2b/qerror.c| 2
b/qmp-commands.hx | 5b/qmp.c| 61 +-
b/qom/Makefile | 2b/qom/container.c| 15b/qom/object.c| 500 ++++++++++++++++++b/usb-linux.c| 35 -hw/container.c| 27 -258 files changed, 4817 insertions(+), 4058 deletions(-)
Re: [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices
In reply to Anthony LiguoriQuoted 1 line · Anthony Liguori
Patch 8/23 is an automated touch everything patch.
It's kind of awkward having a patch series that is both long (number of patches) and wide (patches that require touching/conversion of every device in the tree), because the length means it needs a long review time on the list, and the width means it's going to conflict with lots of other changes (and especially newly arriving device models).
-- PMM
Re: [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices
Quoted 9 lines · Peter Maydell
Quoted 1 line · Anthony Liguori
Patch 8/23 is an automated touch everything patch.
It's kind of awkward having a patch series that is both long (number of patches) and wide (patches that require touching/conversion of every device in the tree), because the length means it needs a long review time on the list, and the width means it's going to conflict with lots of other changes (and especially newly arriving device models).
I could certainly split this into three parts.
But patches 0-8 aren't terribly meaningful outside of the context of patch 9.
And patch 9 by itself leaves the old infrastructure around which means that you would potentially need more patches like patch 9 in a future series.
So I don't think this series could really be trimmed by anything more than a couple patches and I don't see a huge advantage in doing that.
This sort of changes are the exception, not the common thing. Once this series is merged, things will go back to normal patch series wise.
Regards,
Anthony Liguori
Quoted 3 lines
-- PMM