QOM realize, revised
Subsystems (2)
cover QOM realize, revised
Hi Paolo,
I've modified the remainder of your static properties series, in particular:
"qdev: Push state up to Object":
* OBJECT_STATE_CREATED -> OBJECT_STATE_INITIALIZED, to align with QOM API
* Don't set early in object_instance_init() but in object_init_with_type() after all initfns have been run.
"qom: add get_id":
* _object_get_id() -> object_instance_get_id(), to avoid underscore
* Avoid GCC ?: expression, suggested by malc.
* Use newly introduced object_property_is_child() helper.
"qdev: Generalize properties to Objects":
* Fixed indentation.
"qdev: Move bulk of qdev-properties.c to qom/object-properties.c":
* Documentation fix: qdev_property_add_static -> object_property_add_static
* Move from hw/qdev-properties.c to a new qom/object-properties.c instead of qom/object.c.
"qom: Push static properties to Object":
* Build fix: Adapt arm_gic_properties in hw/arm_gic.c as well.
"qom: Add "realized" property":
* Adapted to OBJECT_STATE_INITIALIZED.
"qom: Add QERR_PROPERTY_SET_AFTER_REALIZE":
* Redid the hw/qdev-properties.c changes in qom/object-properties.c.
If you're okay with these, I'll append them to the qom-next queue and will send out the PULL. Otherwise I'll split qom-next into two batches.
Available at:
https://github.com/afaerber/qemu-cpu/commits/realize
Regards,
Andreas
Paolo Bonzini (6):
qdev: Push state up to Object
qom: Add get_id
qdev: Generalize properties to Objects
qdev: Move bulk of qdev-properties.c to qom/object-properties.c
qom: Push static properties to Object
qom: Add "realized" property
Peter Maydell (1):
qom: Add QERR_PROPERTY_SET_AFTER_REALIZE
hw/9pfs/virtio-9p-device.c | 2 +- hw/a15mpcore.c | 3 +- hw/a9mpcore.c | 2 +- hw/ac97.c | 2 +- hw/acpi_piix4.c | 2 +- hw/apic_common.c | 2 +- hw/applesmc.c | 2 +- hw/arm11mpcore.c | 6 +- hw/arm_gic.c | 2 +- hw/arm_l2x0.c | 2 +- hw/arm_mptimer.c | 2 +- hw/arm_sysctl.c | 2 +- hw/arm_timer.c | 3 +- hw/armv7m.c | 3 +- hw/armv7m_nvic.c | 2 +- hw/cadence_gem.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/cs4231.c | 2 +- hw/cs4231a.c | 2 +- hw/debugcon.c | 3 +- hw/ds1225y.c | 2 +- hw/e1000.c | 2 +- hw/eccmemctl.c | 2 +- hw/eepro100.c | 2 +- hw/escc.c | 2 +- hw/esp.c | 2 +- hw/etraxfs_eth.c | 3 +- hw/etraxfs_pic.c | 3 +- hw/exynos4210_combiner.c | 2 +- hw/exynos4210_gic.c | 3 +- hw/exynos4210_uart.c | 2 +- hw/fdc.c | 6 +- hw/fw_cfg.c | 2 +- hw/g364fb.c | 2 +- hw/grlib_apbuart.c | 3 +- hw/grlib_gptimer.c | 2 +- hw/grlib_irqmp.c | 2 +- hw/gus.c | 2 +- hw/hda-audio.c | 6 +- hw/hpet.c | 2 +- hw/i2c.c | 2 +- hw/i82374.c | 2 +- hw/i82378.c | 2 +- hw/i8254.c | 2 +- hw/i8259_common.c | 2 +- hw/ide/ahci.c | 2 +- hw/ide/cmd646.c | 3 +- hw/ide/isa.c | 2 +- hw/ide/qdev.c | 8 +- hw/integratorcp.c | 3 +- hw/intel-hda.c | 4 +- hw/ioh3420.c | 2 +- hw/ivshmem.c | 2 +- hw/kvm/i8254.c | 2 +- hw/kvm/ioapic.c | 2 +- hw/lan9118.c | 2 +- hw/lance.c | 2 +- hw/lm32_sys.c | 2 +- hw/lm32_timer.c | 2 +- hw/m48t59.c | 4 +- hw/marvell_88w8618_audio.c | 2 +- hw/mc146818rtc.c | 2 +- hw/milkymist-minimac2.c | 2 +- hw/milkymist-softusb.c | 2 +- hw/milkymist-sysctl.c | 2 +- hw/milkymist-vgafb.c | 2 +- hw/mipsnet.c | 2 +- hw/musicpal.c | 2 +- hw/nand.c | 2 +- hw/ne2000-isa.c | 3 +- hw/ne2000.c | 2 +- hw/omap_gpio.c | 4 +- hw/omap_i2c.c | 2 +- hw/omap_intc.c | 4 +- hw/onenand.c | 2 +- hw/opencores_eth.c | 2 +- hw/parallel.c | 3 +- hw/pc_sysfw.c | 2 +- hw/pci.c | 2 +- hw/pci_bridge_dev.c | 2 +- hw/pcnet-pci.c | 2 +- hw/pcspk.c | 2 +- hw/pl041.c | 2 +- hw/pxa2xx.c | 2 +- hw/pxa2xx_dma.c | 2 +- hw/pxa2xx_gpio.c | 2 +- hw/pxa2xx_timer.c | 4 +- hw/qdev-addr.c | 22 +- hw/qdev-monitor.c | 4 +- hw/qdev-properties.c | 602 +++++++---------------------------------- hw/qdev.c | 85 ++----- hw/qdev.h | 98 +------- hw/qxl.c | 4 +- hw/rtl8139.c | 2 +- hw/s390-virtio-bus.c | 12 +- hw/sb16.c | 2 +- hw/scsi-bus.c | 2 +- hw/scsi-disk.c | 8 +- hw/scsi-generic.c | 2 +- hw/serial.c | 2 +- hw/slavio_timer.c | 2 +- hw/smbus_eeprom.c | 3 +- hw/smc91c111.c | 2 +- hw/spapr_llan.c | 3 +- hw/spapr_pci.c | 3 +- hw/spapr_vio.c | 2 +- hw/spapr_vscsi.c | 3 +- hw/spapr_vty.c | 3 +- hw/sparc32_dma.c | 2 +- hw/spitz.c | 4 +- hw/stellaris_enet.c | 3 +- hw/strongarm.c | 2 +- hw/sun4m.c | 6 +- hw/sun4m_iommu.c | 2 +- hw/sun4u.c | 6 +- hw/tcx.c | 2 +- hw/usb/bus.c | 2 +- hw/usb/dev-audio.c | 2 +- hw/usb/dev-network.c | 2 +- hw/usb/dev-serial.c | 4 +- hw/usb/dev-smartcard-reader.c | 4 +- hw/usb/dev-storage.c | 2 +- hw/usb/hcd-ehci.c | 4 +- hw/usb/hcd-ohci.c | 4 +- hw/usb/hcd-uhci.c | 12 +- hw/usb/hcd-xhci.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio-console.c | 6 +- hw/virtio-pci.c | 10 +- hw/virtio-serial-bus.c | 2 +- hw/vmmouse.c | 2 +- hw/vt82c686.c | 2 +- hw/xgmac.c | 2 +- hw/xilinx_axidma.c | 3 +- hw/xilinx_axienet.c | 3 +- hw/xilinx_ethlite.c | 3 +- hw/xilinx_intc.c | 3 +- hw/xilinx_timer.c | 3 +- hw/xio3130_downstream.c | 2 +- hw/xio3130_upstream.c | 2 +- hw/zaurus.c | 2 +- include/qemu/object.h | 144 ++++++++++ qerror.c | 4 + qerror.h | 3 + qom/Makefile | 2 +- qom/object-properties.c | 469 ++++++++++++++++++++++++++++++++ qom/object.c | 148 ++++++++++- 149 files changed, 1067 insertions(+), 899 deletions(-) create mode 100644 qom/object-properties.c
Signature · 1 line
1.7.7
PATCH 1/7 qdev: Push state up to Object
From: Paolo Bonzini <[email protected]>
qdev properties use the state member (an embryo of the "realized" property) in order to disable setting them after a device has been initialized. So, in order to push qdev properties up to Object we need to push this bit there too.
--- hw/qdev-addr.c | 3 ++- hw/qdev-properties.c | 26 +++++++++++++------------- hw/qdev.c | 11 +++++------ hw/qdev.h | 6 ------ include/qemu/object.h | 14 ++++++++++++++ qom/object.c | 7 +++++++ 6 files changed, 41 insertions(+), 26 deletions(-)
hw/qdev-addr.c +2 -1
@@ -1,3 +1,4 @@ +#include "qemu/object.h" #include "qdev.h" #include "qdev-addr.h" #include "targphys.h"
@@ -39,7 +40,7 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;int64_t value; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
hw/qdev-properties.c +13 -13
@@ -53,7 +53,7 @@ static void set_bit(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;bool value; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -93,7 +93,7 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint8_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -160,7 +160,7 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint16_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -193,7 +193,7 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint32_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -218,7 +218,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;int32_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -291,7 +291,7 @@ static void set_uint64(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint64_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -379,7 +379,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;char *str; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -457,7 +457,7 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,char *str;int ret; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -626,7 +626,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,int64_t id;VLANState *vlan; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -696,7 +696,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,int i, pos;char *str, *p; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -766,7 +766,7 @@ static void set_enum(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;int *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -797,7 +797,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;char *str; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -867,7 +867,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,const int64_t min =512 ;const int64_t max =32768 ; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
hw/qdev.c +5 -6
@@ -155,7 +155,7 @@ int qdev_init(DeviceState *dev)DeviceClass *dc =DEVICE_GET_CLASS (dev);int rc; -assert (dev->state ==DEV_STATE_CREATED ); +assert (!object_is_realized (OBJECT (dev))); rc = dc->init (dev);if (rc <0 ) {
@@ -178,7 +178,7 @@ int qdev_init(DeviceState *dev) dev->instance_id_alias, dev->alias_required_for_version); } - dev->state =DEV_STATE_INITIALIZED ; +OBJECT (dev)->state =OBJECT_STATE_REALIZED ;if (dev->hotplugged) {device_reset (dev); }
@@ -188,7 +188,7 @@ int qdev_init(DeviceState *dev)void qdev_set_legacy_instance_id (DeviceState *dev,int alias_id,int required_for_version) { -assert (dev->state ==DEV_STATE_CREATED ); +assert (!object_is_realized (OBJECT (dev))); dev->instance_id_alias = alias_id; dev->alias_required_for_version = required_for_version; }
@@ -567,7 +567,7 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque,char *ptr =NULL ;int ret; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }
@@ -674,7 +674,6 @@ static void device_initfn(Object *obj) } dev->instance_id_alias =-1 ; - dev->state =DEV_STATE_CREATED ; class =object_get_class (OBJECT (dev)); do {
@@ -697,7 +696,7 @@ static void device_finalize(Object *obj)BusState *bus;DeviceClass *dc =DEVICE_GET_CLASS (dev); -if (dev->state ==DEV_STATE_INITIALIZED ) { +if (object_is_realized (obj)) {while (dev->num_child_bus) { bus =QLIST_FIRST (&dev->child_bus);qbus_free (bus);
hw/qdev.h +0 -6
@@ -19,11 +19,6 @@ typedef struct BusState BusState;typedef struct BusClass BusClass ; -enum DevState { -DEV_STATE_CREATED =1 , -DEV_STATE_INITIALIZED , -}; -enum {DEV_NVECTORS_UNSPECIFIED =-1 , };
@@ -64,7 +59,6 @@ struct DeviceState {Object parent_obj;const char *id; -enum DevState state;QemuOpts *opts;int hotplugged;BusState *parent_bus;
include/qemu/object.h +14 -0
@@ -241,6 +241,11 @@ struct ObjectClassType type; }; +typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ; +/** * Object: *
@@ -264,6 +269,7 @@ struct Object QTAILQ_HEAD(, ObjectProperty) properties;uint32_t ref;Object *parent; +ObjectState state; };/**
@@ -812,6 +818,14 @@ const char *object_property_get_type(Object *obj, const char *name,Object *object_get_root (void );/** +* object_is_realized: +* @obj: the object +* +* Returns whether @obj has been realized (i.e. completely constructed). +*/ +bool object_is_realized (Object *obj); + +/** * object_get_canonical_path: * * Returns: The canonical path for a object. This is the path within the
qom/object.c +7 -0
@@ -280,6 +280,8 @@ static void object_init_with_type(Object *obj, TypeImpl *ti)if (ti->instance_init) { ti->instance_init (obj); } + + obj->state =OBJECT_STATE_INITIALIZED ; }void object_initialize_with_type (void *data,TypeImpl *type)
@@ -1237,6 +1239,11 @@ static char *qdev_get_type(Object *obj, Error **errp)return g_strdup (object_get_typename (obj)); } +bool object_is_realized (Object *obj) +{ +return obj->state ==OBJECT_STATE_REALIZED ; +} +static void object_instance_init (Object *obj) {object_property_add_str (obj,"type" , qdev_get_type,NULL ,NULL );
Signature · 1 line
1.7.7
PATCH 2/7 qom: Add get_id
In reply to Andreas FärberFrom: Paolo Bonzini <[email protected]>
Some classes may present objects differently in errors, for example if they are not part of the composition tree or if they are not assigned an id by the user. Let them do this with a get_id method on Object, and use the method consistently where a %(device) appears in the error.
--- hw/qdev-properties.c | 6 +++--- hw/qdev.c | 15 ++++++++++++++- include/qemu/object.h | 11 +++++++++++ qom/object.c | 26 +++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 5 deletions(-)
hw/qdev-properties.c +3 -3
@@ -937,16 +937,16 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,switch (ret) {case -EEXIST :error_set (errp,QERR_PROPERTY_VALUE_IN_USE , -object_get_typename (OBJECT (dev)), prop->name, value); +object_get_id (OBJECT (dev)), prop->name, value);break ;default :case -EINVAL :error_set (errp,QERR_PROPERTY_VALUE_BAD , -object_get_typename (OBJECT (dev)), prop->name, value); +object_get_id (OBJECT (dev)), prop->name, value);break ;case -ENOENT :error_set (errp,QERR_PROPERTY_VALUE_NOT_FOUND , -object_get_typename (OBJECT (dev)), prop->name, value); +object_get_id (OBJECT (dev)), prop->name, value);break ;case 0 :break ;
hw/qdev.c +14 -1
@@ -259,7 +259,7 @@ void qdev_init_nofail(DeviceState *dev) {if (qdev_init (dev) <0 ) {error_report ("Initialization of device %s failed" , -object_get_typename (OBJECT (dev))); +object_get_id (OBJECT (dev)));exit (1 ); } }
@@ -716,6 +716,13 @@ static void device_finalize(Object *obj) } } +static const char *qdev_get_id (Object *obj) +{ +DeviceState *dev =DEVICE (obj); + +return dev->id !=NULL ? dev->id :object_get_typename (obj); +} +static void device_class_base_init (ObjectClass *class,void *data) {DeviceClass *klass =DEVICE_CLASS (class);
@@ -746,6 +753,11 @@ Object *qdev_get_machine(void)return dev; } +static void device_class_init (ObjectClass *class,void *data) +{ + class->get_id = qdev_get_id; +} +static TypeInfo device_type_info = { .name =TYPE_DEVICE , .parent =TYPE_OBJECT ,
@@ -753,6 +765,7 @@ static TypeInfo device_type_info = { .instance_init = device_initfn, .instance_finalize = device_finalize, .class_base_init = device_class_base_init, + .class_init = device_class_init, .abstract = true, .class_size = sizeof(DeviceClass), };
include/qemu/object.h +11 -0
@@ -239,6 +239,9 @@ struct ObjectClass {/*< private >*/ Type type; + +/*< public >*/ +const char *(*get_id)(Object *); }; typedef enum ObjectState {
@@ -507,6 +510,14 @@ Object *object_dynamic_cast(Object *obj, const char *typename);Object *object_dynamic_cast_assert (Object *obj,const char *typename);/** +* object_get_id: +* @obj: A derivative of #Object +* +* Returns: A string that can be used to refer to @obj. +*/ +const char *object_get_id (Object *obj); + +/** * object_get_class: * @obj: A derivative of #Object *
qom/object.c +25 -1
@@ -346,6 +346,24 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp) } } +static const char *object_instance_get_id (Object *obj) +{ +ObjectProperty *prop; + + QTAILQ_FOREACH(prop, &obj->properties, node) { +if (object_property_is_child (prop) && prop->opaque == obj) { +return prop->name; + } + } + +return "" ; +} + +const char *object_get_id (Object *obj) +{ +return obj->class->get_id (obj); +} +void object_unparent (Object *obj) {if (obj->parent) {
@@ -685,7 +703,7 @@ ObjectProperty *object_property_find(Object *obj, const char *name, } } -error_set (errp,QERR_PROPERTY_NOT_FOUND ,"" , name); +error_set (errp,QERR_PROPERTY_NOT_FOUND ,object_get_id (obj), name);return NULL ; }
@@ -1249,6 +1267,11 @@ static void object_instance_init(Object *obj)object_property_add_str (obj,"type" , qdev_get_type,NULL ,NULL ); } +static void object_class_init (ObjectClass *klass,void *class_data) +{ + klass->get_id = object_instance_get_id; +} +static void register_types (void ) {static TypeInfo interface_info = {
@@ -1261,6 +1284,7 @@ static void register_types(void) .name = TYPE_OBJECT, .instance_size = sizeof(Object), .instance_init = object_instance_init, + .class_init = object_class_init, .abstract = true, };
Signature · 1 line
1.7.7
PATCH 3/7 qdev: Generalize properties to Objects
In reply to Andreas FärberFrom: Paolo Bonzini <[email protected]>
The property machinery uses DeviceState arguments in a few places. Replace this with Object so that we can push properties up.
--- hw/qdev-addr.c | 19 ++--- hw/qdev-properties.c | 180 +++++++++++++++++++++---------------------------- hw/qdev.c | 8 +-- hw/qdev.h | 10 ++-- 4 files changed, 93 insertions(+), 124 deletions(-)
hw/qdev-addr.c +8 -11
@@ -5,26 +5,25 @@/* --- target physical address --- */ -static int parse_taddr (DeviceState *dev,Property *prop,const char *str) +static int parse_taddr (Object *obj,Property *prop,const char *str) { -target_phys_addr_t *ptr =qdev_get_prop_ptr (dev, prop); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop); *ptr =strtoull (str,NULL ,16 );return 0 ; } -static int print_taddr (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_taddr (Object *obj,Property *prop,char *dest,size_t len) { -target_phys_addr_t *ptr =qdev_get_prop_ptr (dev, prop); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop);return snprintf (dest, len,"0x" TARGET_FMT_plx, *ptr); }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); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop);int64_t value; value = *ptr;
@@ -34,9 +33,8 @@ static void get_taddr(Object *obj, 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); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop);Error *local_err =NULL ;int64_t value;
@@ -53,9 +51,8 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,if ((uint64_t )value <= (uint64_t ) ~(target_phys_addr_t )0 ) { *ptr = value; }else { -error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE , - dev->id?:"" , name, value, (uint64_t )0 , - (uint64_t ) ~(target_phys_addr_t )0 ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE , + name,"target_phys_addr_t" ); } }
hw/qdev-properties.c +77 -103
550 lines not on this page · raw message
hw/qdev.c +3 -5
@@ -548,20 +548,18 @@ char *qdev_get_dev_path(DeviceState *dev)static void qdev_get_legacy_property (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;char buffer[1024 ];char *ptr = buffer; - prop->info->sizeof (buffer)); + prop->info->sizeof (buffer));visit_type_str (v, &ptr, name, errp); }static void qdev_set_legacy_property (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;Error *local_err =NULL ;char *ptr =NULL ;
@@ -578,8 +576,8 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque,return ; } - ret = prop->info->parse (dev, prop, ptr); -error_set_from_qdev_prop_error (errp, ret, dev, prop, ptr); + ret = prop->info->parse (obj, prop, ptr); +error_set_from_prop_error (errp, ret, obj, prop, ptr);g_free (ptr); }
hw/qdev.h +5 -5
@@ -130,8 +130,8 @@ struct PropertyInfo {const char *name;const char *legacy_name;const char **enum_table; -int (*parse)(DeviceState *dev,Property *prop,const char *str); -int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len); +int (*parse)(Object *obj,Property *prop,const char *str); +int (*print)(Object *obj,Property *prop,char *dest,size_t len);ObjectPropertyAccessor *get;ObjectPropertyAccessor *set;ObjectPropertyRelease *release;
@@ -299,7 +299,7 @@ extern PropertyInfo qdev_prop_blocksize; {}/* Set properties between creation and init. */ -void *qdev_get_prop_ptr (DeviceState *dev,Property *prop); +void *object_get_prop_ptr (Object *obj,Property *prop);int qdev_prop_parse (DeviceState *dev,const char *name,const char *value);void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value);void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);
@@ -320,8 +320,8 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);void qdev_prop_register_global_list (GlobalProperty *props);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); +void error_set_from_prop_error (Error **errp,int ret,Object *obj, +Property *prop,const char *value);char *qdev_get_fw_dev_path (DeviceState *dev);
Signature · 1 line
1.7.7
PATCH 4/7 qdev: Move bulk of qdev-properties.c to qom/object-properties.c
In reply to Andreas FärberFrom: Paolo Bonzini <[email protected]>
--- hw/qdev-properties.c | 487 +++++------------------------------------------ hw/qdev.c | 47 +----- hw/qdev.h | 87 --------- include/qemu/object.h | 98 ++++++++++ qom/Makefile | 2 +- qom/object-properties.c | 461 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 607 insertions(+), 575 deletions(-) create mode 100644 qom/object-properties.c
hw/qdev-properties.c +46 -441
@@ -3,392 +3,27 @@#include "qerror.h" #include "blockdev.h" -void *object_get_prop_ptr (Object *obj,Property *prop) -{ -void *ptr = obj; - ptr += prop->offset; -return ptr; -} - -static uint32_t get_prop_mask (Property *prop) -{ -assert (prop->info == &qdev_prop_bit); -return 0x1 << prop->bitnr; -} - -static void bit_prop_set (Object *obj,Property *props,bool val) -{ -uint32_t *p =object_get_prop_ptr (obj, props); -uint32_t mask =get_prop_mask (props); -if (val) - *p |= mask; -else - *p &= ~mask; -} - -/* Bit */ - -static int print_bit (Object *obj,Property *prop,char *dest,size_t len) -{ -uint32_t *p =object_get_prop_ptr (obj, prop); -return snprintf (dest, len, (*p &get_prop_mask (prop)) ?"on" :"off" ); -} - -static void get_bit (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint32_t *p =object_get_prop_ptr (obj, prop); -bool value = (*p &get_prop_mask (prop)) !=0 ; - -visit_type_bool (v, &value, name, errp); -} - -static void set_bit (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -Error *local_err =NULL ; -bool value; - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_bool (v, &value, name, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } -bit_prop_set (obj, prop, value); -} - -PropertyInfo qdev_prop_bit = { - .name ="boolean" , - .legacy_name ="on/off" , - .print = print_bit, - .get = get_bit, - .set = set_bit, -}; - -/* --- 8bit integer --- */ - -static void get_uint8 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint8_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint8 (v, ptr, name, errp); -} - -static void set_uint8 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint8_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint8 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint8 = { - .name ="uint8" , - .get = get_uint8, - .set = set_uint8, -}; - -/* --- 8bit hex value --- */ - -static int parse_hex8 (Object *obj,Property *prop,const char *str) -{ -uint8_t *ptr =object_get_prop_ptr (obj, prop); -char *end; - -if (str[0 ] !='0' || str[1 ] !='x' ) { -return -EINVAL ; - } - - *ptr =strtoul (str, &end,16 ); -if ((*end !='\0' ) || (end == str)) { -return -EINVAL ; - } - -return 0 ; -} - -static int print_hex8 (Object *obj,Property *prop,char *dest,size_t len) -{ -uint8_t *ptr =object_get_prop_ptr (obj, prop); -return snprintf (dest, len,"0x%" PRIx8, *ptr); -} - -PropertyInfo qdev_prop_hex8 = { - .name ="uint8" , - .legacy_name ="hex8" , - .parse = parse_hex8, - .print = print_hex8, - .get = get_uint8, - .set = set_uint8, -}; - -/* --- 16bit integer --- */ - -static void get_uint16 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint16_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint16 (v, ptr, name, errp); -} - -static void set_uint16 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint16_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint16 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint16 = { - .name ="uint16" , - .get = get_uint16, - .set = set_uint16, -}; - -/* --- 32bit integer --- */ - -static void get_uint32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint32_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint32 (v, ptr, name, errp); -} - -static void set_uint32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint32_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint32 (v, ptr, name, errp); -} - -static void get_int32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int32_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_int32 (v, ptr, name, errp); -} - -static void set_int32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int32_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_int32 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint32 = { - .name ="uint32" , - .get = get_uint32, - .set = set_uint32, -}; - -PropertyInfo qdev_prop_int32 = { - .name ="int32" , - .get = get_int32, - .set = set_int32, -}; - -/* --- 32bit hex value --- */ - -static int parse_hex32 (Object *obj,Property *prop,const char *str) -{ -uint32_t *ptr =object_get_prop_ptr (obj, prop); -char *end; - -if (str[0 ] !='0' || str[1 ] !='x' ) { -return -EINVAL ; - } - - *ptr =strtoul (str, &end,16 ); -if ((*end !='\0' ) || (end == str)) { -return -EINVAL ; - } - -return 0 ; -} - -static int print_hex32 (Object *obj,Property *prop,char *dest,size_t len) -{ -uint32_t *ptr =object_get_prop_ptr (obj, prop); -return snprintf (dest, len,"0x%" PRIx32, *ptr); -} - -PropertyInfo qdev_prop_hex32 = { - .name ="uint32" , - .legacy_name ="hex32" , - .parse = parse_hex32, - .print = print_hex32, - .get = get_uint32, - .set = set_uint32, -}; - -/* --- 64bit integer --- */ - -static void get_uint64 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint64_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint64 (v, ptr, name, errp); -} - -static void set_uint64 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint64_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint64 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint64 = { - .name ="uint64" , - .get = get_uint64, - .set = set_uint64, -}; - -/* --- 64bit hex value --- */ - -static int parse_hex64 (Object *obj,Property *prop,const char *str) -{ -uint64_t *ptr =object_get_prop_ptr (obj, prop); -char *end; - -if (str[0 ] !='0' || str[1 ] !='x' ) { -return -EINVAL ; - } - - *ptr =strtoull (str, &end,16 ); -if ((*end !='\0' ) || (end == str)) { -return -EINVAL ; - } - -return 0 ; -} - -static int print_hex64 (Object *obj,Property *prop,char *dest,size_t len) -{ -uint64_t *ptr =object_get_prop_ptr (obj, prop); -return snprintf (dest, len,"0x%" PRIx64, *ptr); -} - -PropertyInfo qdev_prop_hex64 = { - .name ="uint64" , - .legacy_name ="hex64" , - .parse = parse_hex64, - .print = print_hex64, - .get = get_uint64, - .set = set_uint64, -}; - -/* --- string --- */ - -static void release_string (Object *obj,const char *name,void *opaque) -{ -Property *prop = opaque; -g_free (*(char **)object_get_prop_ptr (obj, prop)); -} - -static int print_string (Object *obj,Property *prop,char *dest,size_t len) -{ -char **ptr =object_get_prop_ptr (obj, prop); -if (!*ptr) -return snprintf (dest, len,"<null>" ); -return snprintf (dest, len,"\"%s\"" , *ptr); -} - -static void get_string (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -char **ptr =object_get_prop_ptr (obj, prop); - -if (!*ptr) { -char *str = (char *)"" ; -visit_type_str (v, &str, name, errp); - }else { -visit_type_str (v, ptr, name, errp); - } -} - -static void set_string (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) +void error_set_from_prop_error (Error **errp,int ret,Object *obj, +Property *prop,const char *value) { -Property *prop = opaque; -char **ptr =object_get_prop_ptr (obj, prop); -Error *local_err =NULL ; -char *str; - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_str (v, &str, name, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } -if (*ptr) { -g_free (*ptr); +switch (ret) { +case -EEXIST : +error_set (errp,QERR_PROPERTY_VALUE_IN_USE , +object_get_id (obj), prop->name, value); +break ; +default : +case -EINVAL : +error_set (errp,QERR_PROPERTY_VALUE_BAD , +object_get_id (obj), prop->name, value); +break ; +case -ENOENT : +error_set (errp,QERR_PROPERTY_VALUE_NOT_FOUND , +object_get_id (obj), prop->name, value); +break ; +case 0 : +break ; } - *ptr = str; } - -PropertyInfo qdev_prop_string = { - .name ="string" , - .print = print_string, - .release = release_string, - .get = get_string, - .set = set_string, -}; -/* --- drive --- */ static int parse_drive (Object *obj,const char *str,void **ptr)
@@ -636,13 +271,6 @@ PropertyInfo qdev_prop_vlan = { .set = set_vlan, }; -/* --- pointer --- */ - -/* Not a proper property, just for dirty hacks. TODO Remove it! */ -PropertyInfo qdev_prop_ptr = { - .name ="ptr" , -}; -/* --- mac address --- */ /*
@@ -713,6 +341,12 @@ PropertyInfo qdev_prop_macaddr = { .set = set_mac, }; +/* --- pointer --- */ + +/* Not a proper property, just for dirty hacks. TODO Remove it! */ +PropertyInfo qdev_prop_ptr = { + .name ="ptr" , +};/* --- lost tick policy --- */
@@ -726,40 +360,24 @@ static const char *lost_tick_policy_table[LOST_TICK_MAX+1] = {QEMU_BUILD_BUG_ON (sizeof (LostTickPolicy) !=sizeof (int )); -static void get_enum (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int *ptr =object_get_prop_ptr (obj, prop); - -visit_type_enum (v, ptr, prop->info->enum_table, - prop->info->name, prop->name, errp); -} - -static void set_enum (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_enum (v, ptr, prop->info->enum_table, - prop->info->name, prop->name, errp); -} -PropertyInfo qdev_prop_losttickpolicy = { .name ="LostTickPolicy" , .enum_table = lost_tick_policy_table, - .get = get_enum, - .set = set_enum, + .get = property_get_enum, + .set = property_set_enum, };/* --- pci address --- */ +static void get_pci_devfn (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +int32_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_int32 (v, ptr, name, errp); +} +/* * bus-local address, i.e. "$slot" or "$slot.$fn" */
@@ -826,12 +444,21 @@ PropertyInfo qdev_prop_pci_devfn = { .name = "int32", .legacy_name = "pci-devfn", .print = print_pci_devfn, - .get = get_int32, + .get = get_pci_devfn, .set = set_pci_devfn, };/* --- blocksize --- */ +static void get_blocksize (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint16_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_uint16 (v, ptr, name, errp); +} +static void set_blocksize (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {
@@ -869,7 +496,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_blocksize = { .name ="blocksize" , - .get = get_uint16, + .get = get_blocksize, .set = set_blocksize, };
@@ -905,28 +532,6 @@ static Property *qdev_prop_find(Object *obj, const char *name)return NULL ; } -void error_set_from_prop_error (Error **errp,int ret,Object *obj, -Property *prop,const char *value) -{ -switch (ret) { -case -EEXIST : -error_set (errp,QERR_PROPERTY_VALUE_IN_USE , -object_get_id (obj), prop->name, value); -break ; -default : -case -EINVAL : -error_set (errp,QERR_PROPERTY_VALUE_BAD , -object_get_id (obj), prop->name, value); -break ; -case -ENOENT : -error_set (errp,QERR_PROPERTY_VALUE_NOT_FOUND , -object_get_id (obj), prop->name, value); -break ; -case 0 : -break ; - } -} -int qdev_prop_parse (DeviceState *dev,const char *name,const char *value) {char *legacy_name;
hw/qdev.c +1 -46
59 lines not on this page · raw message
hw/qdev.h +0 -87
130 lines not on this page · raw message
include/qemu/object.h +98 -0
103 lines not on this page · raw message
qom/Makefile +1 -1
@@ -1,2 +1,2 @@ -qom-y = object.o container.o qom-qobject.o +qom-y = object.o object-properties.o container.o qom-qobject.o qom-twice-y = cpu.o
qom/object-properties.c new file +461 -0
461 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH 6/7 qom: Add "realized" property
In reply to Andreas FärberFrom: Paolo Bonzini <[email protected]>
Since we had to move the state field from DeviceState to Object, we cannot delay the implementation of the "realized" property. The property is a trigger for two actions that propagate through the composition tree. "Realize" is called when the property becomes true, and propagates in pre-order; realize can fail if the values of the properties are not valid. "Unrealize" is called when the property becomes false, and propagates in post-order; unrealize cannot fail.
Realize/unrealize is separate from reset. Reset propagation is a thorny issue of its own. We expect classes that care to implement a reset method and call it from realize or realize_children, depending on whether pre-order or post-order is more appropriate.
This patch adds four methods (realize, realize_children, unrealize, unrealize_children) to ObjectClass, together with a default implementation of realize_children and unrealize_children.
--- include/qemu/object.h | 20 +++++++++++ qom/object.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 0 deletions(-)
include/qemu/object.h +20 -0
@@ -246,6 +246,10 @@ struct ObjectClass/*< public >*/ Property *props;const char *(*get_id)(Object *); +void (*realize)(Object *obj,struct Error **errp); +void (*realize_children)(Object *obj,struct Error **errp); +void (*unrealize)(Object *obj); +void (*unrealize_children)(Object *obj); }; typedef enum ObjectState {
@@ -464,6 +468,22 @@ Object *object_new_with_type(Type type);void object_delete (Object *obj);/** +* object_realize_children: +* @obj: The object whose children should be realized. +* +* The default implementation of realize_children. +*/ +void object_realize_children (Object *obj,struct Error **errp); + +/** +* object_unrealize_children: +* @obj: The object whose children should be unrealize. +* +* The default implementation of unrealize_children. +*/ +void object_unrealize_children (Object *obj); + +/** * object_initialize_with_type: * @obj: A pointer to the memory to be used for the object. * @type: The type of the object to instantiate.
qom/object.c +89 -0
119 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH 7/7 qom: Add QERR_PROPERTY_SET_AFTER_REALIZE
In reply to Andreas FärberFrom: Peter Maydell <[email protected]>
Add a new QError QERR_PROPERTY_SET_AFTER_REALIZE for attempts to set a QOM or qdev property after the object/device has been realized. This allows a slightly more informative diagnostic than the previous "Insufficient permission" message.
--- hw/qdev-properties.c | 15 ++++++++++----- qerror.c | 4 ++++ qerror.h | 3 +++ qom/object-properties.c | 24 ++++++++++++++++-------- qom/object.c | 6 ++++-- 5 files changed, 37 insertions(+), 15 deletions(-)
hw/qdev-properties.c +10 -5
@@ -76,7 +76,8 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,int ret;if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -242,7 +243,8 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,VLANState *vlan;if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -303,7 +305,8 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,char *str, *p;if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -391,7 +394,8 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,char *str;if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -469,7 +473,8 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,const int64_t max =32768 ;if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
qerror.c +4 -0
@@ -233,6 +233,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Property '%(device).%(property)' not found", }, { + .error_fmt = QERR_PROPERTY_SET_AFTER_REALIZE, + .desc = "Property '%(device).%(property)' cannot be set after realize", + }, + { .error_fmt = QERR_PROPERTY_VALUE_BAD, .desc = "Property '%(device).%(property)' doesn't take value '%(value)'", },
qerror.h +3 -0
@@ -196,6 +196,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_PROPERTY_NOT_FOUND \ "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }" +#define QERR_PROPERTY_SET_AFTER_REALIZE \ + "{ 'class': 'PropertySetAfterRealize', 'data': { 'device': %s, 'property': %s } }" +#define QERR_PROPERTY_VALUE_BAD \ "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
qom/object-properties.c +16 -8
@@ -50,7 +50,8 @@ static void set_bit(Object *obj, Visitor *v, void *opaque,bool value;if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -88,7 +89,8 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,uint8_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -153,7 +155,8 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,uint16_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -184,7 +187,8 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,uint32_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -207,7 +211,8 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,int32_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -278,7 +283,8 @@ static void set_uint64(Object *obj, Visitor *v, void *opaque,uint64_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -364,7 +370,8 @@ static void set_string(Object *obj, Visitor *v, void *opaque,char *str;if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
@@ -407,7 +414,8 @@ void property_set_enum(Object *obj, Visitor *v, void *opaque,int *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name);return ; }
qom/object.c +4 -2
@@ -817,7 +817,8 @@ void object_property_get(Object *obj, Visitor *v, const char *name, }if (!prop->get) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name); }else { prop->get (obj, v, prop->opaque, name, errp); }
@@ -832,7 +833,8 @@ void object_property_set(Object *obj, Visitor *v, const char *name, }if (!prop->set) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name); }else { prop->set (obj, v, prop->opaque, name, errp); }
Signature · 1 line
1.7.7
PATCH 5/7 qom: Push static properties to Object
In reply to Andreas FärberFrom: Paolo Bonzini <[email protected]>
This patch is made much larger by the need to touch all assignments of props. The interesting changes are in hw/qdev-monitor.c, hw/qdev-properties.c, hw/qdev.c, hw/qdev.h, include/qemu/object.h, qom/object.c.
--- hw/9pfs/virtio-9p-device.c | 2 +- hw/a15mpcore.c | 3 +-- hw/a9mpcore.c | 2 +- hw/ac97.c | 2 +- hw/acpi_piix4.c | 2 +- hw/apic_common.c | 2 +- hw/applesmc.c | 2 +- hw/arm11mpcore.c | 6 ++---- hw/arm_gic.c | 2 +- hw/arm_l2x0.c | 2 +- hw/arm_mptimer.c | 2 +- hw/arm_sysctl.c | 2 +- hw/arm_timer.c | 3 +-- hw/armv7m.c | 3 +-- hw/armv7m_nvic.c | 2 +- hw/cadence_gem.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/cs4231.c | 2 +- hw/cs4231a.c | 2 +- hw/debugcon.c | 3 +-- hw/ds1225y.c | 2 +- hw/e1000.c | 2 +- hw/eccmemctl.c | 2 +- hw/eepro100.c | 2 +- hw/escc.c | 2 +- hw/esp.c | 2 +- hw/etraxfs_eth.c | 3 +-- hw/etraxfs_pic.c | 3 +-- hw/exynos4210_combiner.c | 2 +- hw/exynos4210_gic.c | 3 +-- hw/exynos4210_uart.c | 2 +- hw/fdc.c | 6 +++--- hw/fw_cfg.c | 2 +- hw/g364fb.c | 2 +- hw/grlib_apbuart.c | 3 +-- hw/grlib_gptimer.c | 2 +- hw/grlib_irqmp.c | 2 +- hw/gus.c | 2 +- hw/hda-audio.c | 6 +++--- hw/hpet.c | 2 +- hw/i2c.c | 2 +- hw/i82374.c | 2 +- hw/i82378.c | 2 +- hw/i8254.c | 2 +- hw/i8259_common.c | 2 +- hw/ide/ahci.c | 2 +- hw/ide/cmd646.c | 3 +-- hw/ide/isa.c | 2 +- hw/ide/qdev.c | 8 ++++---- hw/integratorcp.c | 3 +-- hw/intel-hda.c | 4 ++-- hw/ioh3420.c | 2 +- hw/ivshmem.c | 2 +- hw/kvm/i8254.c | 2 +- hw/kvm/ioapic.c | 2 +- hw/lan9118.c | 2 +- hw/lance.c | 2 +- hw/lm32_sys.c | 2 +- hw/lm32_timer.c | 2 +- hw/m48t59.c | 4 ++-- hw/marvell_88w8618_audio.c | 2 +- hw/mc146818rtc.c | 2 +- hw/milkymist-minimac2.c | 2 +- hw/milkymist-softusb.c | 2 +- hw/milkymist-sysctl.c | 2 +- hw/milkymist-vgafb.c | 2 +- hw/mipsnet.c | 2 +- hw/musicpal.c | 2 +- hw/nand.c | 2 +- hw/ne2000-isa.c | 3 +-- hw/ne2000.c | 2 +- hw/omap_gpio.c | 4 ++-- hw/omap_i2c.c | 2 +- hw/omap_intc.c | 4 ++-- hw/onenand.c | 2 +- hw/opencores_eth.c | 2 +- hw/parallel.c | 3 +-- hw/pc_sysfw.c | 2 +- hw/pci.c | 2 +- hw/pci_bridge_dev.c | 2 +- hw/pcnet-pci.c | 2 +- hw/pcspk.c | 2 +- hw/pl041.c | 2 +- hw/pxa2xx.c | 2 +- hw/pxa2xx_dma.c | 2 +- hw/pxa2xx_gpio.c | 2 +- hw/pxa2xx_timer.c | 4 ++-- hw/qdev-monitor.c | 4 ++-- hw/qdev-properties.c | 2 +- hw/qdev.c | 14 +------------- hw/qdev.h | 1 - hw/qxl.c | 4 ++-- hw/rtl8139.c | 2 +- hw/s390-virtio-bus.c | 12 ++++-------- hw/sb16.c | 2 +- hw/scsi-bus.c | 2 +- hw/scsi-disk.c | 8 ++++---- hw/scsi-generic.c | 2 +- hw/serial.c | 2 +- hw/slavio_timer.c | 2 +- hw/smbus_eeprom.c | 3 +-- hw/smc91c111.c | 2 +- hw/spapr_llan.c | 3 +-- hw/spapr_pci.c | 3 +-- hw/spapr_vio.c | 2 +- hw/spapr_vscsi.c | 3 +-- hw/spapr_vty.c | 3 +-- hw/sparc32_dma.c | 2 +- hw/spitz.c | 4 ++-- hw/stellaris_enet.c | 3 +-- hw/strongarm.c | 2 +- hw/sun4m.c | 6 ++---- hw/sun4m_iommu.c | 2 +- hw/sun4u.c | 6 ++---- hw/tcx.c | 2 +- hw/usb/bus.c | 2 +- hw/usb/dev-audio.c | 2 +- hw/usb/dev-network.c | 2 +- hw/usb/dev-serial.c | 4 ++-- hw/usb/dev-smartcard-reader.c | 4 ++-- hw/usb/dev-storage.c | 2 +- hw/usb/hcd-ehci.c | 4 ++-- hw/usb/hcd-ohci.c | 4 ++-- hw/usb/hcd-uhci.c | 12 ++++++------ hw/usb/hcd-xhci.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio-console.c | 6 ++---- hw/virtio-pci.c | 10 +++++----- hw/virtio-serial-bus.c | 2 +- hw/vmmouse.c | 2 +- hw/vt82c686.c | 2 +- hw/xgmac.c | 2 +- hw/xilinx_axidma.c | 3 +-- hw/xilinx_axienet.c | 3 +-- hw/xilinx_ethlite.c | 3 +-- hw/xilinx_intc.c | 3 +-- hw/xilinx_timer.c | 3 +-- hw/xio3130_downstream.c | 2 +- hw/xio3130_upstream.c | 2 +- hw/zaurus.c | 2 +- include/qemu/object.h | 7 ++++--- qom/object.c | 20 ++++++++++++++++++++ 144 files changed, 203 insertions(+), 230 deletions(-)
hw/9pfs/virtio-9p-device.c +1 -1
@@ -173,7 +173,7 @@ 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; + klass->props = virtio_9p_properties; dc->reset = virtio_pci_reset; }
hw/a15mpcore.c +1 -2
@@ -85,10 +85,9 @@ static Property a15mp_priv_properties[] = {static void a15mp_priv_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = a15mp_priv_init; - dc->props = a15mp_priv_properties; + klass->props = a15mp_priv_properties;/* We currently have no savable state */ }
hw/a9mpcore.c +1 -1
@@ -222,7 +222,7 @@ static void a9mp_priv_class_init(ObjectClass *klass, void *data)SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = a9mp_priv_init; - dc->props = a9mp_priv_properties; + klass->props = a9mp_priv_properties; dc->vmsd = &vmstate_a9mp_priv; dc->reset = a9mp_priv_reset; }
hw/ac97.c +1 -1
@@ -1352,7 +1352,7 @@ static void ac97_class_init (ObjectClass *klass, void *data) k->class_id =PCI_CLASS_MULTIMEDIA_AUDIO ; dc->desc ="Intel 82801AA AC97 Audio" ; dc->vmsd = &vmstate_ac97; - dc->props = ac97_properties; + klass->props = ac97_properties; }static TypeInfo ac97_info = {
hw/acpi_piix4.c +1 -1
@@ -463,7 +463,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) dc->desc ="PM" ; dc->no_user =1 ; dc->vmsd = &vmstate_acpi; - dc->props = piix4_pm_properties; + klass->props = piix4_pm_properties; }static TypeInfo piix4_pm_info = {
hw/apic_common.c +1 -1
@@ -370,7 +370,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_apic_common; dc->reset = apic_reset_common; dc->no_user =1 ; - dc->props = apic_properties_common; + klass->props = apic_properties_common; sc->init = apic_init_common; }
hw/applesmc.c +1 -1
@@ -233,7 +233,7 @@ static void qdev_applesmc_class_init(ObjectClass *klass, void *data)ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = applesmc_isa_init; dc->reset = qdev_applesmc_isa_reset; - dc->props = applesmc_isa_properties; + klass->props = applesmc_isa_properties; }static TypeInfo applesmc_isa_info = {
hw/arm11mpcore.c +2 -4
@@ -210,11 +210,10 @@ 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; + klass->props = mpcore_rirq_properties; }static TypeInfo mpcore_rirq_info = {
@@ -240,11 +239,10 @@ 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; + klass->props = mpcore_priv_properties; }static TypeInfo mpcore_priv_info = {
hw/arm_gic.c +1 -1
@@ -945,7 +945,7 @@ static void arm_gic_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *sbc =SYS_BUS_DEVICE_CLASS (klass); sbc->init = arm_gic_init; - dc->props = arm_gic_properties; + klass->props = arm_gic_properties; dc->reset = gic_reset; dc->no_user =1 ; }
hw/arm_l2x0.c +1 -1
@@ -173,7 +173,7 @@ static void l2x0_class_init(ObjectClass *klass, void *data) k->init = l2x0_priv_init; dc->vmsd = &vmstate_l2x0; dc->no_user =1 ; - dc->props = l2x0_properties; + klass->props = l2x0_properties; dc->reset = l2x0_priv_reset; }
hw/arm_mptimer.c +1 -1
@@ -326,7 +326,7 @@ static void arm_mptimer_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_arm_mptimer; dc->reset = arm_mptimer_reset; dc->no_user =1 ; - dc->props = arm_mptimer_properties; + klass->props = arm_mptimer_properties; }static TypeInfo arm_mptimer_info = {
hw/arm_sysctl.c +1 -1
@@ -403,7 +403,7 @@ static void arm_sysctl_class_init(ObjectClass *klass, void *data) k->init = arm_sysctl_init; dc->reset = arm_sysctl_reset; dc->vmsd = &vmstate_arm_sysctl; - dc->props = arm_sysctl_properties; + klass->props = arm_sysctl_properties; }static TypeInfo arm_sysctl_info = {
hw/arm_timer.c +1 -2
@@ -370,10 +370,9 @@ static Property sp804_properties[] = {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; + klass->props = sp804_properties; }static TypeInfo sp804_info = {
hw/armv7m.c +1 -2
@@ -257,11 +257,10 @@ 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; + klass->props = bitband_properties; }static TypeInfo bitband_info = {
hw/armv7m_nvic.c +1 -1
@@ -415,7 +415,7 @@ static void armv7m_nvic_class_init(ObjectClass *klass, void *data) sdc->init = armv7m_nvic_init; dc->vmsd = &vmstate_nvic; dc->reset = armv7m_nvic_reset; - dc->props = armv7m_nvic_properties; + klass->props = armv7m_nvic_properties; }static TypeInfo armv7m_nvic_info = {
hw/cadence_gem.c +1 -1
@@ -1213,7 +1213,7 @@ static void gem_class_init(ObjectClass *klass, void *data)SysBusDeviceClass *sdc =SYS_BUS_DEVICE_CLASS (klass); sdc->init = gem_init; - dc->props = gem_properties; + klass->props = gem_properties; dc->vmsd = &vmstate_cadence_gem; dc->reset = gem_reset; }
hw/ccid-card-emulated.c +1 -1
@@ -584,7 +584,7 @@ static void emulated_class_initfn(ObjectClass *klass, void *data) cc->get_atr = emulated_get_atr; cc->apdu_from_guest = emulated_apdu_from_guest; dc->desc ="emulated smartcard" ; - dc->props = emulated_card_properties; + klass->props = emulated_card_properties; }static TypeInfo emulated_card_info = {
hw/ccid-card-passthru.c +1 -1
@@ -333,7 +333,7 @@ static void passthru_class_initfn(ObjectClass *klass, void *data) cc->apdu_from_guest = passthru_apdu_from_guest; dc->desc ="passthrough smartcard" ; dc->vmsd = &passthru_vmstate; - dc->props = passthru_card_properties; + klass->props = passthru_card_properties; }static TypeInfo passthru_card_info = {
hw/cs4231.c +1 -1
@@ -163,7 +163,7 @@ static void cs4231_class_init(ObjectClass *klass, void *data) k->init = cs4231_init1; dc->reset = cs_reset; dc->vmsd = &vmstate_cs4231; - dc->props = cs4231_properties; + klass->props = cs4231_properties; }static TypeInfo cs4231_info = {
hw/cs4231a.c +1 -1
@@ -679,7 +679,7 @@ static void cs4231a_class_initfn (ObjectClass *klass, void *data) ic->init = cs4231a_initfn; dc->desc ="Crystal Semiconductor CS4231A" ; dc->vmsd = &vmstate_cs4231a; - dc->props = cs4231a_properties; + klass->props = cs4231a_properties; }static TypeInfo cs4231a_info = {
hw/debugcon.c +1 -2
@@ -96,10 +96,9 @@ static Property debugcon_isa_properties[] = {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; + klass->props = debugcon_isa_properties; }static TypeInfo debugcon_isa_info = {
hw/ds1225y.c +1 -1
@@ -147,7 +147,7 @@ static void nvram_sysbus_class_init(ObjectClass *klass, void *data) k->init = nvram_sysbus_initfn; dc->vmsd = &vmstate_nvram; - dc->props = nvram_sysbus_properties; + klass->props = nvram_sysbus_properties; }static TypeInfo nvram_sysbus_info = {
hw/e1000.c +1 -1
@@ -1284,7 +1284,7 @@ static void e1000_class_init(ObjectClass *klass, void *data) dc->desc ="Intel Gigabit Ethernet" ; dc->reset = qdev_e1000_reset; dc->vmsd = &vmstate_e1000; - dc->props = e1000_properties; + klass->props = e1000_properties; }static TypeInfo e1000_info = {
hw/eccmemctl.c +1 -1
@@ -321,7 +321,7 @@ static void ecc_class_init(ObjectClass *klass, void *data) k->init = ecc_init1; dc->reset = ecc_reset; dc->vmsd = &vmstate_ecc; - dc->props = ecc_properties; + klass->props = ecc_properties; }static TypeInfo ecc_info = {
hw/eepro100.c +1 -1
@@ -2075,7 +2075,7 @@ static void eepro100_class_init(ObjectClass *klass, void *data) info =eepro100_get_class_by_name (object_class_get_name (klass)); - dc->props = e100_properties; + klass->props = e100_properties; dc->desc = info->desc; k->vendor_id =PCI_VENDOR_ID_INTEL ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ;
hw/escc.c +1 -1
@@ -921,7 +921,7 @@ static void escc_class_init(ObjectClass *klass, void *data) k->init = escc_init1; dc->reset = escc_reset; dc->vmsd = &vmstate_escc; - dc->props = escc_properties; + klass->props = escc_properties; }static TypeInfo escc_info = {
hw/esp.c +1 -1
@@ -766,7 +766,7 @@ static void esp_class_init(ObjectClass *klass, void *data) k->init = esp_init1; dc->reset = esp_hard_reset; dc->vmsd = &vmstate_esp; - dc->props = esp_properties; + klass->props = esp_properties; }static TypeInfo esp_info = {
hw/etraxfs_eth.c +1 -2
@@ -623,11 +623,10 @@ 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; + klass->props = etraxfs_eth_properties; }static TypeInfo etraxfs_eth_info = {
hw/etraxfs_pic.c +1 -2
@@ -158,11 +158,10 @@ 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; + klass->props = etraxfs_pic_properties; }static TypeInfo etraxfs_pic_info = {
hw/exynos4210_combiner.c +1 -1
@@ -440,7 +440,7 @@ static void exynos4210_combiner_class_init(ObjectClass *klass, void *data) k->init = exynos4210_combiner_init; dc->reset = exynos4210_combiner_reset; - dc->props = exynos4210_combiner_properties; + klass->props = exynos4210_combiner_properties; dc->vmsd = &vmstate_exynos4210_combiner; }
hw/exynos4210_gic.c +1 -2
@@ -341,11 +341,10 @@ static Property exynos4210_gic_properties[] = {static void exynos4210_gic_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = exynos4210_gic_init; - dc->props = exynos4210_gic_properties; + klass->props = exynos4210_gic_properties; }static TypeInfo exynos4210_gic_info = {
hw/exynos4210_uart.c +1 -1
@@ -657,7 +657,7 @@ static void exynos4210_uart_class_init(ObjectClass *klass, void *data) k->init = exynos4210_uart_init; dc->reset = exynos4210_uart_reset; - dc->props = exynos4210_uart_properties; + klass->props = exynos4210_uart_properties; dc->vmsd = &vmstate_exynos4210_uart; }
hw/fdc.c +3 -3
@@ -2062,7 +2062,7 @@ static void isabus_fdc_class_init1(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = fdctrl_external_reset_isa; dc->vmsd = &vmstate_isa_fdc; - dc->props = isa_fdc_properties; + klass->props = isa_fdc_properties; }static TypeInfo isa_fdc_info = {
@@ -2096,7 +2096,7 @@ static void sysbus_fdc_class_init(ObjectClass *klass, void *data) k->init = sysbus_fdc_init1; dc->reset = fdctrl_external_reset_sysbus; dc->vmsd = &vmstate_sysbus_fdc; - dc->props = sysbus_fdc_properties; + klass->props = sysbus_fdc_properties; }static TypeInfo sysbus_fdc_info = {
@@ -2119,7 +2119,7 @@ static void sun4m_fdc_class_init(ObjectClass *klass, void *data) k->init = sun4m_fdc_init1; dc->reset = fdctrl_external_reset_sysbus; dc->vmsd = &vmstate_sysbus_fdc; - dc->props = sun4m_fdc_properties; + klass->props = sun4m_fdc_properties; }static TypeInfo sun4m_fdc_info = {
hw/fw_cfg.c +1 -1
@@ -546,7 +546,7 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = fw_cfg_reset; dc->vmsd = &vmstate_fw_cfg; - dc->props = fw_cfg_properties; + klass->props = fw_cfg_properties; }static TypeInfo fw_cfg_info = {
hw/g364fb.c +1 -1
@@ -564,7 +564,7 @@ static void g364fb_sysbus_class_init(ObjectClass *klass, void *data) dc->desc ="G364 framebuffer" ; dc->reset = g364fb_sysbus_reset; dc->vmsd = &vmstate_g364fb; - dc->props = g364fb_sysbus_properties; + klass->props = g364fb_sysbus_properties; }static TypeInfo g364fb_sysbus_info = {
hw/grlib_apbuart.c +1 -2
@@ -249,11 +249,10 @@ 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; + klass->props = grlib_gptimer_properties; }static TypeInfo grlib_gptimer_info = {
hw/grlib_gptimer.c +1 -1
@@ -386,7 +386,7 @@ static void grlib_gptimer_class_init(ObjectClass *klass, void *data) k->init = grlib_gptimer_init; dc->reset = grlib_gptimer_reset; - dc->props = grlib_gptimer_properties; + klass->props = grlib_gptimer_properties; }static TypeInfo grlib_gptimer_info = {
hw/grlib_irqmp.c +1 -1
@@ -367,7 +367,7 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data) k->init = grlib_irqmp_init; dc->reset = grlib_irqmp_reset; - dc->props = grlib_irqmp_properties; + klass->props = grlib_irqmp_properties; }static TypeInfo grlib_irqmp_info = {
hw/gus.c +1 -1
@@ -314,7 +314,7 @@ static void gus_class_initfn (ObjectClass *klass, void *data) ic->init = gus_initfn; dc->desc ="Gravis Ultrasound GF1" ; dc->vmsd = &vmstate_gus; - dc->props = gus_properties; + klass->props = gus_properties; }static TypeInfo gus_info = {
hw/hda-audio.c +3 -3
@@ -1036,7 +1036,7 @@ static void hda_audio_output_class_init(ObjectClass *klass, void *data) k->stream = hda_audio_stream; dc->desc ="HDA Audio Codec, output-only (line-out)" ; dc->vmsd = &vmstate_hda_audio; - dc->props = hda_audio_properties; + klass->props = hda_audio_properties; }static TypeInfo hda_audio_output_info = {
@@ -1057,7 +1057,7 @@ static void hda_audio_duplex_class_init(ObjectClass *klass, void *data) k->stream = hda_audio_stream; dc->desc ="HDA Audio Codec, duplex (line-out, line-in)" ; dc->vmsd = &vmstate_hda_audio; - dc->props = hda_audio_properties; + klass->props = hda_audio_properties; }static TypeInfo hda_audio_duplex_info = {
@@ -1078,7 +1078,7 @@ static void hda_audio_micro_class_init(ObjectClass *klass, void *data) k->stream = hda_audio_stream; dc->desc ="HDA Audio Codec, duplex (speaker, microphone)" ; dc->vmsd = &vmstate_hda_audio; - dc->props = hda_audio_properties; + klass->props = hda_audio_properties; }static TypeInfo hda_audio_micro_info = {
hw/hpet.c +1 -1
@@ -742,7 +742,7 @@ static void hpet_device_class_init(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = hpet_reset; dc->vmsd = &vmstate_hpet; - dc->props = hpet_device_properties; + klass->props = hpet_device_properties; }static TypeInfo hpet_device_info = {
hw/i2c.c +1 -1
@@ -225,7 +225,7 @@ static void i2c_slave_class_init(ObjectClass *klass, void *data)DeviceClass *k =DEVICE_CLASS (klass); k->init = i2c_slave_qdev_init; k->bus_type =TYPE_I2C_BUS ; - k->props = i2c_props; + klass->props = i2c_props; }static TypeInfo i2c_slave_type_info = {
hw/i82374.c +1 -1
@@ -150,7 +150,7 @@ static void i82374_class_init(ObjectClass *klass, void *data) k->init = i82374_isa_init; dc->vmsd = &vmstate_isa_i82374; - dc->props = i82374_properties; + klass->props = i82374_properties; }static TypeInfo i82374_isa_info = {
hw/i82378.c +1 -1
@@ -260,7 +260,7 @@ static void pci_i82378_class_init(ObjectClass *klass, void *data) k->subsystem_vendor_id =0x0 ; k->subsystem_id =0x0 ; dc->vmsd = &vmstate_pci_i82378; - dc->props = i82378_properties; + klass->props = i82378_properties; }static TypeInfo pci_i82378_info = {
hw/i8254.c +1 -1
@@ -342,7 +342,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data) k->get_channel_info = pit_get_channel_info_common; k->post_load = pit_post_load; dc->reset = pit_reset; - dc->props = pit_properties; + klass->props = pit_properties; }static TypeInfo pit_info = {
hw/i8259_common.c +1 -1
@@ -140,7 +140,7 @@ static void pic_common_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_pic_common; dc->no_user =1 ; - dc->props = pic_properties_common; + klass->props = pic_properties_common; ic->init = pic_init_common; }
hw/ide/ahci.c +1 -1
@@ -1202,7 +1202,7 @@ static void sysbus_ahci_class_init(ObjectClass *klass, void *data) sbc->init = sysbus_ahci_init; dc->vmsd = &vmstate_sysbus_ahci; - dc->props = sysbus_ahci_properties; + klass->props = sysbus_ahci_properties; }static TypeInfo sysbus_ahci_info = {
hw/ide/cmd646.c +1 -2
@@ -332,7 +332,6 @@ 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;
@@ -341,7 +340,7 @@ 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; + klass->props = cmd646_ide_properties; }static TypeInfo cmd646_ide_info = {
hw/ide/isa.c +1 -1
@@ -108,7 +108,7 @@ static void isa_ide_class_initfn(ObjectClass *klass, void *data) ic->init = isa_ide_initfn; dc->fw_name ="ide" ; dc->reset = isa_ide_reset; - dc->props = isa_ide_properties; + klass->props = isa_ide_properties; }static TypeInfo isa_ide_info = {
hw/ide/qdev.c +4 -4
@@ -199,7 +199,7 @@ static void ide_hd_class_init(ObjectClass *klass, void *data) k->init = ide_hd_initfn; dc->fw_name ="drive" ; dc->desc ="virtual IDE disk" ; - dc->props = ide_hd_properties; + klass->props = ide_hd_properties; }static TypeInfo ide_hd_info = {
@@ -221,7 +221,7 @@ static void ide_cd_class_init(ObjectClass *klass, void *data) k->init = ide_cd_initfn; dc->fw_name ="drive" ; dc->desc ="virtual IDE CD-ROM" ; - dc->props = ide_cd_properties; + klass->props = ide_cd_properties; }static TypeInfo ide_cd_info = {
@@ -243,7 +243,7 @@ static void ide_drive_class_init(ObjectClass *klass, void *data) k->init = ide_drive_initfn; dc->fw_name ="drive" ; dc->desc ="virtual IDE disk or CD-ROM (legacy)" ; - dc->props = ide_drive_properties; + klass->props = ide_drive_properties; }static TypeInfo ide_drive_info = {
@@ -258,7 +258,7 @@ static void ide_device_class_init(ObjectClass *klass, void *data)DeviceClass *k =DEVICE_CLASS (klass); k->init = ide_qdev_init; k->bus_type =TYPE_IDE_BUS ; - k->props = ide_props; + klass->props = ide_props; }static TypeInfo ide_device_type_info = {
hw/integratorcp.c +1 -2
@@ -526,11 +526,10 @@ 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; + klass->props = core_properties; }static TypeInfo core_info = {
hw/intel-hda.c +2 -2
@@ -1265,7 +1265,7 @@ static void intel_hda_class_init(ObjectClass *klass, void *data) dc->desc ="Intel HD Audio Controller" ; dc->reset = intel_hda_reset; dc->vmsd = &vmstate_intel_hda; - dc->props = intel_hda_properties; + klass->props = intel_hda_properties; }static TypeInfo intel_hda_info = {
@@ -1281,7 +1281,7 @@ static void hda_codec_device_class_init(ObjectClass *klass, void *data) k->init = hda_codec_dev_init; k->exit = hda_codec_dev_exit; k->bus_type =TYPE_HDA_BUS ; - k->props = hda_props; + klass->props = hda_props; }static TypeInfo hda_codec_device_type_info = {
hw/ioh3420.c +1 -1
@@ -227,7 +227,7 @@ static void ioh3420_class_init(ObjectClass *klass, void *data) dc->desc ="Intel IOH device id 3420 PCIE Root Port" ; dc->reset = ioh3420_reset; dc->vmsd = &vmstate_ioh3420; - dc->props = ioh3420_properties; + klass->props = ioh3420_properties; }static TypeInfo ioh3420_info = {
hw/ivshmem.c +1 -1
@@ -806,7 +806,7 @@ static void ivshmem_class_init(ObjectClass *klass, void *data) k->device_id =0x1110 ; k->class_id =PCI_CLASS_MEMORY_RAM ; dc->reset = ivshmem_reset; - dc->props = ivshmem_properties; + klass->props = ivshmem_properties; }static TypeInfo ivshmem_info = {
hw/kvm/i8254.c +1 -1
@@ -236,7 +236,7 @@ static void kvm_pit_class_init(ObjectClass *klass, void *data) k->pre_save = kvm_pit_get; k->post_load = kvm_pit_put; dc->reset = kvm_pit_reset; - dc->props = kvm_pit_properties; + klass->props = kvm_pit_properties; }static TypeInfo kvm_pit_info = {
hw/kvm/ioapic.c +1 -1
@@ -107,7 +107,7 @@ static void kvm_ioapic_class_init(ObjectClass *klass, void *data) k->pre_save = kvm_ioapic_get; k->post_load = kvm_ioapic_put; dc->reset = kvm_ioapic_reset; - dc->props = kvm_ioapic_properties; + klass->props = kvm_ioapic_properties; }static TypeInfo kvm_ioapic_info = {
hw/lan9118.c +1 -1
@@ -1362,7 +1362,7 @@ static void lan9118_class_init(ObjectClass *klass, void *data) k->init = lan9118_init1; dc->reset = lan9118_reset; - dc->props = lan9118_properties; + klass->props = lan9118_properties; dc->vmsd = &vmstate_lan9118; }
hw/lance.c +1 -1
@@ -152,7 +152,7 @@ static void lance_class_init(ObjectClass *klass, void *data) dc->fw_name ="ethernet" ; dc->reset = lance_reset; dc->vmsd = &vmstate_lance; - dc->props = lance_properties; + klass->props = lance_properties; }static TypeInfo lance_info = {
hw/lm32_sys.c +1 -1
@@ -154,7 +154,7 @@ static void lm32_sys_class_init(ObjectClass *klass, void *data) k->init = lm32_sys_init; dc->reset = sys_reset; dc->vmsd = &vmstate_lm32_sys; - dc->props = lm32_sys_properties; + klass->props = lm32_sys_properties; }static TypeInfo lm32_sys_info = {
hw/lm32_timer.c +1 -1
@@ -212,7 +212,7 @@ static void lm32_timer_class_init(ObjectClass *klass, void *data) k->init = lm32_timer_init; dc->reset = timer_reset; dc->vmsd = &vmstate_lm32_timer; - dc->props = lm32_timer_properties; + klass->props = lm32_timer_properties; }static TypeInfo lm32_timer_info = {
hw/m48t59.c +2 -2
@@ -738,7 +738,7 @@ static void m48t59_init_class_isa1(ObjectClass *klass, void *data) ic->init = m48t59_init_isa1; dc->no_user =1 ; dc->reset = m48t59_reset_isa; - dc->props = m48t59_isa_properties; + klass->props = m48t59_isa_properties; }static TypeInfo m48t59_isa_info = {
@@ -762,7 +762,7 @@ static void m48t59_class_init(ObjectClass *klass, void *data) k->init = m48t59_init1; dc->reset = m48t59_reset_sysbus; - dc->props = m48t59_properties; + klass->props = m48t59_properties; }static TypeInfo m48t59_info = {
hw/marvell_88w8618_audio.c +1 -1
@@ -285,7 +285,7 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data) k->init = mv88w8618_audio_init; dc->reset = mv88w8618_audio_reset; dc->vmsd = &mv88w8618_audio_vmsd; - dc->props = mv88w8618_audio_properties; + klass->props = mv88w8618_audio_properties; }static TypeInfo mv88w8618_audio_info = {
hw/mc146818rtc.c +1 -1
@@ -697,7 +697,7 @@ static void rtc_class_initfn(ObjectClass *klass, void *data) ic->init = rtc_initfn; dc->no_user =1 ; dc->vmsd = &vmstate_rtc; - dc->props = mc146818rtc_properties; + klass->props = mc146818rtc_properties; }static TypeInfo mc146818rtc_info = {
hw/milkymist-minimac2.c +1 -1
@@ -532,7 +532,7 @@ static void milkymist_minimac2_class_init(ObjectClass *klass, void *data) k->init = milkymist_minimac2_init; dc->reset = milkymist_minimac2_reset; dc->vmsd = &vmstate_milkymist_minimac2; - dc->props = milkymist_minimac2_properties; + klass->props = milkymist_minimac2_properties; }static TypeInfo milkymist_minimac2_info = {
hw/milkymist-softusb.c +1 -1
@@ -313,7 +313,7 @@ static void milkymist_softusb_class_init(ObjectClass *klass, void *data) k->init = milkymist_softusb_init; dc->reset = milkymist_softusb_reset; dc->vmsd = &vmstate_milkymist_softusb; - dc->props = milkymist_softusb_properties; + klass->props = milkymist_softusb_properties; }static TypeInfo milkymist_softusb_info = {
hw/milkymist-sysctl.c +1 -1
@@ -320,7 +320,7 @@ static void milkymist_sysctl_class_init(ObjectClass *klass, void *data) k->init = milkymist_sysctl_init; dc->reset = milkymist_sysctl_reset; dc->vmsd = &vmstate_milkymist_sysctl; - dc->props = milkymist_sysctl_properties; + klass->props = milkymist_sysctl_properties; }static TypeInfo milkymist_sysctl_info = {
hw/milkymist-vgafb.c +1 -1
@@ -316,7 +316,7 @@ static void milkymist_vgafb_class_init(ObjectClass *klass, void *data) k->init = milkymist_vgafb_init; dc->reset = milkymist_vgafb_reset; dc->vmsd = &vmstate_milkymist_vgafb; - dc->props = milkymist_vgafb_properties; + klass->props = milkymist_vgafb_properties; }static TypeInfo milkymist_vgafb_info = {
hw/mipsnet.c +1 -1
@@ -266,7 +266,7 @@ static void mipsnet_class_init(ObjectClass *klass, void *data) dc->desc ="MIPS Simulator network device" ; dc->reset = mipsnet_sysbus_reset; dc->vmsd = &vmstate_mipsnet; - dc->props = mipsnet_properties; + klass->props = mipsnet_properties; }static TypeInfo mipsnet_info = {
hw/musicpal.c +1 -1
@@ -424,7 +424,7 @@ static void mv88w8618_eth_class_init(ObjectClass *klass, void *data) k->init = mv88w8618_eth_init; dc->vmsd = &mv88w8618_eth_vmsd; - dc->props = mv88w8618_eth_properties; + klass->props = mv88w8618_eth_properties; }static TypeInfo mv88w8618_eth_info = {
hw/nand.c +1 -1
@@ -432,7 +432,7 @@ static void nand_class_init(ObjectClass *klass, void *data) k->init = nand_device_init; dc->reset = nand_reset; dc->vmsd = &vmstate_nand; - dc->props = nand_properties; + klass->props = nand_properties; }static TypeInfo nand_info = {
hw/ne2000-isa.c +1 -2
@@ -91,10 +91,9 @@ static Property ne2000_isa_properties[] = {static void isa_ne2000_class_initfn (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = isa_ne2000_initfn; - dc->props = ne2000_isa_properties; + klass->props = ne2000_isa_properties; }static TypeInfo ne2000_isa_info = {
hw/ne2000.c +1 -1
@@ -771,7 +771,7 @@ static void ne2000_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_REALTEK_8029 ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->vmsd = &vmstate_pci_ne2000; - dc->props = ne2000_properties; + klass->props = ne2000_properties; }static TypeInfo ne2000_info = {
hw/omap_gpio.c +2 -2
@@ -744,7 +744,7 @@ static void omap_gpio_class_init(ObjectClass *klass, void *data) k->init = omap_gpio_init; dc->reset = omap_gpif_reset; - dc->props = omap_gpio_properties; + klass->props = omap_gpio_properties; }static TypeInfo omap_gpio_info = {
@@ -773,7 +773,7 @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data) k->init = omap2_gpio_init; dc->reset = omap2_gpif_reset; - dc->props = omap2_gpio_properties; + klass->props = omap2_gpio_properties; }static TypeInfo omap2_gpio_info = {
hw/omap_i2c.c +1 -1
@@ -467,7 +467,7 @@ static void omap_i2c_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = omap_i2c_init; - dc->props = omap_i2c_properties; + klass->props = omap_i2c_properties; dc->reset = omap_i2c_reset; }
hw/omap_intc.c +2 -2
@@ -386,7 +386,7 @@ static void omap_intc_class_init(ObjectClass *klass, void *data) k->init = omap_intc_init; dc->reset = omap_inth_reset; - dc->props = omap_intc_properties; + klass->props = omap_intc_properties; }static TypeInfo omap_intc_info = {
@@ -630,7 +630,7 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data) k->init = omap2_intc_init; dc->reset = omap_inth_reset; - dc->props = omap2_intc_properties; + klass->props = omap2_intc_properties; }static TypeInfo omap2_intc_info = {
hw/onenand.c +1 -1
@@ -818,7 +818,7 @@ static void onenand_class_init(ObjectClass *klass, void *data) k->init = onenand_initfn; dc->reset = onenand_system_reset; - dc->props = onenand_properties; + klass->props = onenand_properties; }static TypeInfo onenand_info = {
hw/opencores_eth.c +1 -1
@@ -715,7 +715,7 @@ static void open_eth_class_init(ObjectClass *klass, void *data) k->init = sysbus_open_eth_init; dc->desc ="Opencores 10/100 Mbit Ethernet" ; dc->reset = qdev_open_eth_reset; - dc->props = open_eth_properties; + klass->props = open_eth_properties; }static TypeInfo open_eth_info = {
hw/parallel.c +1 -2
@@ -593,10 +593,9 @@ static Property parallel_isa_properties[] = {static void parallel_isa_class_initfn (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = parallel_isa_initfn; - dc->props = parallel_isa_properties; + klass->props = parallel_isa_properties; }static TypeInfo parallel_isa_info = {
hw/pc_sysfw.c +1 -1
@@ -246,7 +246,7 @@ static void pcsysfw_class_init (ObjectClass *klass, void *data) dc->desc ="PC System Firmware" ; dc->init = pcsysfw_init; - dc->props = pcsysfw_properties; + klass->props = pcsysfw_properties; }static TypeInfo pcsysfw_info = {
hw/pci.c +1 -1
@@ -2010,7 +2010,7 @@ static void pci_device_class_init(ObjectClass *klass, void *data) k->unplug = pci_unplug_device; k->exit = pci_unregister_device; k->bus_type =TYPE_PCI_BUS ; - k->props = pci_props; + klass->props = pci_props; }static TypeInfo pci_device_type_info = {
hw/pci_bridge_dev.c +1 -1
@@ -155,8 +155,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) k->is_bridge =1 , dc->desc ="Standard PCI Bridge" ; dc->reset = qdev_pci_bridge_dev_reset; - dc->props = pci_bridge_dev_properties; dc->vmsd = &pci_bridge_dev_vmstate; + klass->props = pci_bridge_dev_properties; }static TypeInfo pci_bridge_dev_info = {
hw/pcnet-pci.c +1 -1
@@ -359,7 +359,7 @@ static void pcnet_class_init(ObjectClass *klass, void *data) k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->reset = pci_reset; dc->vmsd = &vmstate_pci_pcnet; - dc->props = pcnet_properties; + klass->props = pcnet_properties; }static TypeInfo pcnet_info = {
hw/pcspk.c +1 -1
@@ -184,7 +184,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data) ic->init = pcspk_initfn; dc->no_user =1 ; - dc->props = pcspk_properties; + klass->props = pcspk_properties; }static TypeInfo pcspk_info = {
hw/pl041.c +1 -1
@@ -628,7 +628,7 @@ static void pl041_device_class_init(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = pl041_device_reset; dc->vmsd = &vmstate_pl041; - dc->props = pl041_device_properties; + klass->props = pl041_device_properties; }static TypeInfo pl041_device_info = {
hw/pxa2xx.c +1 -1
@@ -1556,7 +1556,7 @@ static void pxa2xx_i2c_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_i2c_initfn; dc->desc ="PXA2xx I2C Bus Controller" ; dc->vmsd = &vmstate_pxa2xx_i2c; - dc->props = pxa2xx_i2c_properties; + klass->props = pxa2xx_i2c_properties; }static TypeInfo pxa2xx_i2c_info = {
hw/pxa2xx_dma.c +1 -1
@@ -556,7 +556,7 @@ static void pxa2xx_dma_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_dma_init; dc->desc ="PXA2xx DMA controller" ; dc->vmsd = &vmstate_pxa2xx_dma; - dc->props = pxa2xx_dma_properties; + klass->props = pxa2xx_dma_properties; }static TypeInfo pxa2xx_dma_info = {
hw/pxa2xx_gpio.c +1 -1
@@ -331,7 +331,7 @@ static void pxa2xx_gpio_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_gpio_initfn; dc->desc ="PXA2xx GPIO controller" ; - dc->props = pxa2xx_gpio_properties; + klass->props = pxa2xx_gpio_properties; }static TypeInfo pxa2xx_gpio_info = {
hw/pxa2xx_timer.c +2 -2
@@ -492,7 +492,7 @@ static void pxa25x_timer_dev_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_timer_init; dc->desc ="PXA25x timer" ; dc->vmsd = &vmstate_pxa2xx_timer_regs; - dc->props = pxa25x_timer_dev_properties; + klass->props = pxa25x_timer_dev_properties; }static TypeInfo pxa25x_timer_dev_info = {
@@ -517,7 +517,7 @@ static void pxa27x_timer_dev_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_timer_init; dc->desc ="PXA27x timer" ; dc->vmsd = &vmstate_pxa2xx_timer_regs; - dc->props = pxa27x_timer_dev_properties; + klass->props = pxa27x_timer_dev_properties; }static TypeInfo pxa27x_timer_dev_info = {
hw/qdev-monitor.c +2 -2
@@ -149,7 +149,7 @@ int qdev_device_help(QemuOpts *opts)return 0 ; } do { - for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) { + for (prop = OBJECT_CLASS(klass)->props; prop && prop->name; prop++) { /* * TODO Properties without a parser are just for dirty hacks. * qdev_prop_ptr is the only such PropertyInfo. It's marked
@@ -527,7 +527,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent) } class =object_get_class (OBJECT (dev));do { -qdev_print_props (mon, dev,DEVICE_CLASS (class)->props, indent); +qdev_print_props (mon, dev,OBJECT_CLASS (class)->props, indent); class =object_class_get_parent (class); }while (class !=object_class_by_name (TYPE_DEVICE ));bus_print_dev (dev->parent_bus, mon, dev, indent +2 );
hw/qdev-properties.c +1 -1
@@ -522,7 +522,7 @@ static Property *qdev_prop_find(Object *obj, const char *name)/* device properties */ class =object_get_class (obj); do { - prop = qdev_prop_walk(DEVICE_CLASS(class)->props, name); + prop = qdev_prop_walk(OBJECT_CLASS(class)->props, name); if (prop) { return prop; }
hw/qdev.c +1 -13
@@ -630,9 +630,8 @@ static void device_initfn(Object *obj) class =object_get_class (OBJECT (dev));do { -for (prop =DEVICE_CLASS (class)->props; prop && prop->name; prop++) { +for (prop =OBJECT_CLASS (class)->props; prop && prop->name; prop++) {qdev_property_add_legacy (dev, prop,NULL ); -object_property_add_static (OBJECT (dev), prop,NULL ); } class =object_class_get_parent (class); }while (class !=object_class_by_name (TYPE_DEVICE ));
@@ -676,16 +675,6 @@ static const char *qdev_get_id(Object *obj)return dev->id !=NULL ? dev->id :object_get_typename (obj); } -static void device_class_base_init (ObjectClass *class,void *data) -{ -DeviceClass *klass =DEVICE_CLASS (class); - -/* We explicitly look up properties in the superclasses, -* so do not propagate them to the subclasses. -*/ - klass->props =NULL ; -} -void device_reset (DeviceState *dev) {DeviceClass *klass =DEVICE_GET_CLASS (dev);
@@ -717,7 +706,6 @@ static TypeInfo device_type_info = { .instance_size = sizeof(DeviceState), .instance_init = device_initfn, .instance_finalize = device_finalize, - .class_base_init = device_class_base_init, .class_init = device_class_init, .abstract = true, .class_size = sizeof(DeviceClass),
hw/qdev.h +0 -1
@@ -33,7 +33,6 @@ typedef struct DeviceClass {const char *fw_name;const char *desc; -Property *props;int no_user;/* callbacks */
hw/qxl.c +2 -2
@@ -2051,7 +2051,7 @@ static void qxl_primary_class_init(ObjectClass *klass, void *data) dc->desc ="Spice QXL GPU (primary, vga compatible)" ; dc->reset = qxl_reset_handler; dc->vmsd = &qxl_vmstate; - dc->props = qxl_properties; + klass->props = qxl_properties; }static TypeInfo qxl_primary_info = {
@@ -2073,7 +2073,7 @@ static void qxl_secondary_class_init(ObjectClass *klass, void *data) dc->desc ="Spice QXL GPU (secondary)" ; dc->reset = qxl_reset_handler; dc->vmsd = &qxl_vmstate; - dc->props = qxl_properties; + klass->props = qxl_properties; }static TypeInfo qxl_secondary_info = {
hw/rtl8139.c +1 -1
@@ -3525,7 +3525,7 @@ static void rtl8139_class_init(ObjectClass *klass, void *data) k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->reset = rtl8139_reset; dc->vmsd = &vmstate_rtl8139; - dc->props = rtl8139_properties; + klass->props = rtl8139_properties; }static TypeInfo rtl8139_info = {
hw/s390-virtio-bus.c +4 -8
@@ -384,11 +384,10 @@ static Property s390_virtio_net_properties[] = {static void s390_virtio_net_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_net_init; - dc->props = s390_virtio_net_properties; + klass->props = s390_virtio_net_properties; }static TypeInfo s390_virtio_net = {
@@ -409,11 +408,10 @@ static Property s390_virtio_blk_properties[] = {static void s390_virtio_blk_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_blk_init; - dc->props = s390_virtio_blk_properties; + klass->props = s390_virtio_blk_properties; }static TypeInfo s390_virtio_blk = {
@@ -431,11 +429,10 @@ static Property s390_virtio_serial_properties[] = {static void s390_virtio_serial_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_serial_init; - dc->props = s390_virtio_serial_properties; + klass->props = s390_virtio_serial_properties; }static TypeInfo s390_virtio_serial = {
@@ -478,11 +475,10 @@ static Property s390_virtio_scsi_properties[] = {static void s390_virtio_scsi_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_scsi_init; - dc->props = s390_virtio_scsi_properties; + klass->props = s390_virtio_scsi_properties; }static TypeInfo s390_virtio_scsi = {
hw/sb16.c +1 -1
@@ -1407,7 +1407,7 @@ static void sb16_class_initfn (ObjectClass *klass, void *data) ic->init = sb16_initfn; dc->desc ="Creative Sound Blaster 16" ; dc->vmsd = &vmstate_sb16; - dc->props = sb16_properties; + klass->props = sb16_properties; }static TypeInfo sb16_info = {
hw/scsi-bus.c +1 -1
@@ -1609,7 +1609,7 @@ static void scsi_device_class_init(ObjectClass *klass, void *data) k->init = scsi_qdev_init; k->unplug = qdev_simple_unplug_cb; k->exit = scsi_qdev_exit; - k->props = scsi_props; + klass->props = scsi_props; }static TypeInfo scsi_device_type_info = {
hw/scsi-disk.c +4 -4
@@ -1945,7 +1945,7 @@ static void scsi_hd_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="virtual SCSI disk" ; dc->reset = scsi_disk_reset; - dc->props = scsi_hd_properties; + klass->props = scsi_hd_properties; dc->vmsd = &vmstate_scsi_disk_state; }
@@ -1973,7 +1973,7 @@ static void scsi_cd_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="virtual SCSI CD-ROM" ; dc->reset = scsi_disk_reset; - dc->props = scsi_cd_properties; + klass->props = scsi_cd_properties; dc->vmsd = &vmstate_scsi_disk_state; }
@@ -2001,7 +2001,7 @@ static void scsi_block_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="SCSI block device passthrough" ; dc->reset = scsi_disk_reset; - dc->props = scsi_block_properties; + klass->props = scsi_block_properties; dc->vmsd = &vmstate_scsi_disk_state; }
@@ -2034,7 +2034,7 @@ static void scsi_disk_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="virtual SCSI disk or CD-ROM (legacy)" ; dc->reset = scsi_disk_reset; - dc->props = scsi_disk_properties; + klass->props = scsi_disk_properties; dc->vmsd = &vmstate_scsi_disk_state; }
hw/scsi-generic.c +1 -1
@@ -497,7 +497,7 @@ static void scsi_generic_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="pass through generic scsi device (/dev/sg*)" ; dc->reset = scsi_generic_reset; - dc->props = scsi_generic_properties; + klass->props = scsi_generic_properties; dc->vmsd = &vmstate_scsi_device; }
hw/serial.c +1 -1
@@ -902,7 +902,7 @@ static void serial_isa_class_initfn(ObjectClass *klass, void *data)ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = serial_isa_initfn; dc->vmsd = &vmstate_isa_serial; - dc->props = serial_isa_properties; + klass->props = serial_isa_properties; }static TypeInfo serial_isa_info = {
hw/slavio_timer.c +1 -1
@@ -417,7 +417,7 @@ static void slavio_timer_class_init(ObjectClass *klass, void *data) k->init = slavio_timer_init1; dc->reset = slavio_timer_reset; dc->vmsd = &vmstate_slavio_timer; - dc->props = slavio_timer_properties; + klass->props = slavio_timer_properties; }static TypeInfo slavio_timer_info = {
hw/smbus_eeprom.c +1 -2
@@ -111,7 +111,6 @@ static Property smbus_eeprom_properties[] = {static void smbus_eeprom_class_initfn (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SMBusDeviceClass *sc =SMBUS_DEVICE_CLASS (klass); sc->init = smbus_eeprom_initfn;
@@ -120,7 +119,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data) sc->receive_byte = eeprom_receive_byte; sc->write_data = eeprom_write_data; sc->read_data = eeprom_read_data; - dc->props = smbus_eeprom_properties; + klass->props = smbus_eeprom_properties; }static TypeInfo smbus_eeprom_info = {
hw/smc91c111.c +1 -1
@@ -771,7 +771,7 @@ static void smc91c111_class_init(ObjectClass *klass, void *data) k->init = smc91c111_init1; dc->reset = smc91c111_reset; dc->vmsd = &vmstate_smc91c111; - dc->props = smc91c111_properties; + klass->props = smc91c111_properties; }static TypeInfo smc91c111_info = {
hw/spapr_llan.c +1 -2
@@ -486,7 +486,6 @@ static Property spapr_vlan_properties[] = {static void spapr_vlan_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VIOsPAPRDeviceClass *k =VIO_SPAPR_DEVICE_CLASS (klass); k->init = spapr_vlan_init;
@@ -496,7 +495,7 @@ static void spapr_vlan_class_init(ObjectClass *klass, void *data) k->dt_type ="network" ; k->dt_compatible ="IBM,l-lan" ; k->signal_mask =0x1 ; - dc->props = spapr_vlan_properties; + klass->props = spapr_vlan_properties; }static TypeInfo spapr_vlan_info = {
hw/spapr_pci.c +1 -2
@@ -344,10 +344,9 @@ static Property spapr_phb_properties[] = {static void spapr_phb_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *sdc =SYS_BUS_DEVICE_CLASS (klass); -DeviceClass *dc =DEVICE_CLASS (klass); sdc->init = spapr_phb_init; - dc->props = spapr_phb_properties; + klass->props = spapr_phb_properties;spapr_rtas_register ("read-pci-config" , rtas_read_pci_config);spapr_rtas_register ("write-pci-config" , rtas_write_pci_config);
hw/spapr_vio.c +1 -1
@@ -797,7 +797,7 @@ static void vio_spapr_device_class_init(ObjectClass *klass, void *data) k->init = spapr_vio_busdev_init; k->reset = spapr_vio_busdev_reset; k->bus_type =TYPE_SPAPR_VIO_BUS ; - k->props = spapr_vio_props; + klass->props = spapr_vio_props; }static TypeInfo spapr_vio_type_info = {
hw/spapr_vscsi.c +1 -2
@@ -951,7 +951,6 @@ static Property spapr_vscsi_properties[] = {static void spapr_vscsi_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VIOsPAPRDeviceClass *k =VIO_SPAPR_DEVICE_CLASS (klass); k->init = spapr_vscsi_init;
@@ -961,7 +960,7 @@ static void spapr_vscsi_class_init(ObjectClass *klass, void *data) k->dt_type ="vscsi" ; k->dt_compatible ="IBM,v-scsi" ; k->signal_mask =0x00000001 ; - dc->props = spapr_vscsi_properties; + klass->props = spapr_vscsi_properties; }static TypeInfo spapr_vscsi_info = {
hw/spapr_vty.c +1 -2
@@ -140,14 +140,13 @@ static Property spapr_vty_properties[] = {static void spapr_vty_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VIOsPAPRDeviceClass *k =VIO_SPAPR_DEVICE_CLASS (klass); k->init = spapr_vty_init; k->dt_name ="vty" ; k->dt_type ="serial" ; k->dt_compatible ="hvterm1" ; - dc->props = spapr_vty_properties; + klass->props = spapr_vty_properties; }static TypeInfo spapr_vty_info = {
hw/sparc32_dma.c +1 -1
@@ -297,7 +297,7 @@ static void sparc32_dma_class_init(ObjectClass *klass, void *data) k->init = sparc32_dma_init1; dc->reset = dma_reset; dc->vmsd = &vmstate_dma; - dc->props = sparc32_dma_properties; + klass->props = sparc32_dma_properties; }static TypeInfo sparc32_dma_info = {
hw/spitz.c +2 -2
@@ -1036,7 +1036,7 @@ static void sl_nand_class_init(ObjectClass *klass, void *data) k->init = sl_nand_init; dc->vmsd = &vmstate_sl_nand_info; - dc->props = sl_nand_properties; + klass->props = sl_nand_properties; }static TypeInfo sl_nand_info = {
@@ -1071,7 +1071,7 @@ static void spitz_keyboard_class_init(ObjectClass *klass, void *data) k->init = spitz_keyboard_init; dc->vmsd = &vmstate_spitz_kbd; - dc->props = spitz_keyboard_properties; + klass->props = spitz_keyboard_properties; }static TypeInfo spitz_keyboard_info = {
hw/stellaris_enet.c +1 -2
@@ -427,11 +427,10 @@ static Property stellaris_enet_properties[] = {static void stellaris_enet_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = stellaris_enet_init; - dc->props = stellaris_enet_properties; + klass->props = stellaris_enet_properties; }static TypeInfo stellaris_enet_info = {
hw/strongarm.c +1 -1
@@ -1295,7 +1295,7 @@ static void strongarm_uart_class_init(ObjectClass *klass, void *data) dc->desc ="StrongARM UART controller" ; dc->reset = strongarm_uart_reset; dc->vmsd = &vmstate_strongarm_uart_regs; - dc->props = strongarm_uart_properties; + klass->props = strongarm_uart_properties; }static TypeInfo strongarm_uart_info = {
hw/sun4m.c +2 -4
@@ -730,11 +730,10 @@ static Property prom_properties[] = {static void prom_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = prom_init1; - dc->props = prom_properties; + klass->props = prom_properties; }static TypeInfo prom_info = {
@@ -794,11 +793,10 @@ static Property ram_properties[] = {static void ram_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = ram_init1; - dc->props = ram_properties; + klass->props = ram_properties; }static TypeInfo ram_info = {
hw/sun4m_iommu.c +1 -1
@@ -370,7 +370,7 @@ static void iommu_class_init(ObjectClass *klass, void *data) k->init = iommu_init1; dc->reset = iommu_reset; dc->vmsd = &vmstate_iommu; - dc->props = iommu_properties; + klass->props = iommu_properties; }static TypeInfo iommu_info = {
hw/sun4u.c +2 -4
@@ -681,11 +681,10 @@ static Property prom_properties[] = {static void prom_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = prom_init1; - dc->props = prom_properties; + klass->props = prom_properties; }static TypeInfo prom_info = {
@@ -738,11 +737,10 @@ static Property ram_properties[] = {static void ram_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = ram_init1; - dc->props = ram_properties; + klass->props = ram_properties; }static TypeInfo ram_info = {
hw/tcx.c +1 -1
@@ -654,7 +654,7 @@ static void tcx_class_init(ObjectClass *klass, void *data) k->init = tcx_init1; dc->reset = tcx_reset; dc->vmsd = &vmstate_tcx; - dc->props = tcx_properties; + klass->props = tcx_properties; }static TypeInfo tcx_info = {
hw/usb/bus.c +1 -1
@@ -589,7 +589,7 @@ static void usb_device_class_init(ObjectClass *klass, void *data) k->init = usb_qdev_init; k->unplug = qdev_simple_unplug_cb; k->exit = usb_qdev_exit; - k->props = usb_props; + klass->props = usb_props; }static TypeInfo usb_device_type_info = {
hw/usb/dev-audio.c +1 -1
@@ -688,7 +688,7 @@ static void usb_audio_class_init(ObjectClass *klass, void *data)USBDeviceClass *k =USB_DEVICE_CLASS (klass); dc->vmsd = &vmstate_usb_audio; - dc->props = usb_audio_properties; + klass->props = usb_audio_properties; k->product_desc ="QEMU USB Audio Interface" ; k->usb_desc = &desc_audio; k->init = usb_audio_initfn;
hw/usb/dev-network.c +1 -1
@@ -1408,7 +1408,7 @@ static void usb_net_class_initfn(ObjectClass *klass, void *data) uc->handle_destroy = usb_net_handle_destroy; dc->fw_name ="network" ; dc->vmsd = &vmstate_usb_net; - dc->props = net_properties; + klass->props = net_properties; }static TypeInfo net_info = {
hw/usb/dev-serial.c +2 -2
@@ -589,7 +589,7 @@ static void usb_serial_class_initfn(ObjectClass *klass, void *data) uc->handle_data = usb_serial_handle_data; uc->handle_destroy = usb_serial_handle_destroy; dc->vmsd = &vmstate_usb_serial; - dc->props = serial_properties; + klass->props = serial_properties; }static TypeInfo serial_info = {
@@ -617,7 +617,7 @@ static void usb_braille_class_initfn(ObjectClass *klass, void *data) uc->handle_data = usb_serial_handle_data; uc->handle_destroy = usb_serial_handle_destroy; dc->vmsd = &vmstate_usb_serial; - dc->props = braille_properties; + klass->props = braille_properties; }static TypeInfo braille_info = {
hw/usb/dev-smartcard-reader.c +2 -2
@@ -1334,7 +1334,7 @@ static void ccid_class_initfn(ObjectClass *klass, void *data) uc->handle_destroy = ccid_handle_destroy; dc->desc ="CCID Rev 1.1 smartcard reader" ; dc->vmsd = &ccid_vmstate; - dc->props = ccid_properties; + klass->props = ccid_properties; }static TypeInfo ccid_info = {
@@ -1350,7 +1350,7 @@ static void ccid_card_class_init(ObjectClass *klass, void *data) k->bus_type =TYPE_CCID_BUS ; k->init = ccid_card_init; k->exit = ccid_card_exit; - k->props = ccid_props; + klass->props = ccid_props; }static TypeInfo ccid_card_type_info = {
hw/usb/dev-storage.c +1 -1
@@ -662,7 +662,7 @@ static void usb_msd_class_initfn(ObjectClass *klass, void *data) uc->handle_data = usb_msd_handle_data; dc->fw_name ="storage" ; dc->vmsd = &vmstate_usb_msd; - dc->props = msd_properties; + klass->props = msd_properties; }static TypeInfo msd_info = {
hw/usb/hcd-ehci.c +2 -2
@@ -2208,7 +2208,7 @@ static void ehci_class_init(ObjectClass *klass, void *data) k->revision =0x10 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_ehci; - dc->props = ehci_properties; + klass->props = ehci_properties; }static TypeInfo ehci_info = {
@@ -2229,7 +2229,7 @@ static void ich9_ehci_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_ehci; - dc->props = ehci_properties; + klass->props = ehci_properties; }static TypeInfo ich9_ehci_info = {
hw/usb/hcd-ohci.c +2 -2
@@ -1863,7 +1863,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_APPLE_IPID_USB ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->desc ="Apple USB Controller" ; - dc->props = ohci_pci_properties; + klass->props = ohci_pci_properties; }static TypeInfo ohci_pci_info = {
@@ -1886,7 +1886,7 @@ static void ohci_sysbus_class_init(ObjectClass *klass, void *data) sbc->init = ohci_init_pxa; dc->desc ="OHCI USB Controller" ; - dc->props = ohci_sysbus_properties; + klass->props = ohci_sysbus_properties; }static TypeInfo ohci_sysbus_info = {
hw/usb/hcd-uhci.c +6 -6
@@ -1259,7 +1259,7 @@ static void piix3_uhci_class_init(ObjectClass *klass, void *data) k->revision =0x01 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo piix3_uhci_info = {
@@ -1281,7 +1281,7 @@ static void piix4_uhci_class_init(ObjectClass *klass, void *data) k->revision =0x01 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo piix4_uhci_info = {
@@ -1303,7 +1303,7 @@ static void vt82c686b_uhci_class_init(ObjectClass *klass, void *data) k->revision =0x01 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo vt82c686b_uhci_info = {
@@ -1324,7 +1324,7 @@ static void ich9_uhci1_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo ich9_uhci1_info = {
@@ -1345,7 +1345,7 @@ static void ich9_uhci2_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo ich9_uhci2_info = {
@@ -1366,7 +1366,7 @@ static void ich9_uhci3_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd = &vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo ich9_uhci3_info = {
hw/usb/hcd-xhci.c +1 -1
@@ -2894,7 +2894,7 @@ static void xhci_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass); dc->vmsd = &vmstate_xhci; - dc->props = xhci_properties; + klass->props = xhci_properties; k->init = usb_xhci_initfn; k->vendor_id =PCI_VENDOR_ID_NEC ; k->device_id =PCI_DEVICE_ID_NEC_UPD720200 ;
hw/usb/host-linux.c +1 -1
@@ -1472,7 +1472,7 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data) uc->handle_reset = usb_host_handle_reset; uc->handle_destroy = usb_host_handle_destroy; dc->vmsd = &vmstate_usb_host; - dc->props = usb_host_dev_properties; + klass->props = usb_host_dev_properties; }static TypeInfo usb_host_dev_info = {
hw/usb/redirect.c +1 -1
@@ -1479,7 +1479,7 @@ static void usbredir_class_initfn(ObjectClass *klass, void *data) uc->handle_reset = usbredir_handle_reset; uc->handle_data = usbredir_handle_data; uc->handle_control = usbredir_handle_control; - dc->props = usbredir_properties; + klass->props = usbredir_properties; }static TypeInfo usbredir_dev_info = {
hw/virtio-console.c +2 -4
@@ -131,7 +131,6 @@ static Property virtconsole_properties[] = {static void virtconsole_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_CLASS (klass); k->is_console = true;
@@ -139,7 +138,7 @@ static void virtconsole_class_init(ObjectClass *klass, void *data) k->have_data = flush_buf; k->guest_open = guest_open; k->guest_close = guest_close; - dc->props = virtconsole_properties; + klass->props = virtconsole_properties; }static TypeInfo virtconsole_info = {
@@ -156,14 +155,13 @@ static Property virtserialport_properties[] = {static void virtserialport_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_CLASS (klass); k->init = virtconsole_initfn; k->have_data = flush_buf; k->guest_open = guest_open; k->guest_close = guest_close; - dc->props = virtserialport_properties; + klass->props = virtserialport_properties; }static TypeInfo virtserialport_info = {
hw/virtio-pci.c +5 -5
@@ -961,7 +961,7 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_STORAGE_SCSI ; dc->reset = virtio_pci_reset; - dc->props = virtio_blk_properties; + klass->props = virtio_blk_properties; }static TypeInfo virtio_blk_info = {
@@ -995,7 +995,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->reset = virtio_pci_reset; - dc->props = virtio_net_properties; + klass->props = virtio_net_properties; }static TypeInfo virtio_net_info = {
@@ -1026,7 +1026,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_COMMUNICATION_OTHER ; dc->reset = virtio_pci_reset; - dc->props = virtio_serial_properties; + klass->props = virtio_serial_properties; }static TypeInfo virtio_serial_info = {
@@ -1054,7 +1054,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_OTHERS ; dc->reset = virtio_pci_reset; - dc->props = virtio_balloon_properties; + klass->props = virtio_balloon_properties; }static TypeInfo virtio_balloon_info = {
@@ -1108,7 +1108,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, void *data) k->revision =0x00 ; k->class_id =PCI_CLASS_STORAGE_SCSI ; dc->reset = virtio_pci_reset; - dc->props = virtio_scsi_properties; + klass->props = virtio_scsi_properties; }static TypeInfo virtio_scsi_info = {
hw/virtio-serial-bus.c +1 -1
@@ -995,7 +995,7 @@ static void virtio_serial_port_class_init(ObjectClass *klass, void *data) k->bus_type =TYPE_VIRTIO_SERIAL_BUS ; k->exit = virtser_port_qdev_exit; k->unplug = qdev_simple_unplug_cb; - k->props = virtser_props; + klass->props = virtser_props; }static TypeInfo virtio_serial_port_type_info = {
hw/vmmouse.c +1 -1
@@ -284,7 +284,7 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = vmmouse_reset; dc->vmsd = &vmstate_vmmouse; - dc->props = vmmouse_properties; + klass->props = vmmouse_properties; }static TypeInfo vmmouse_info = {
hw/vt82c686.c +1 -1
@@ -471,7 +471,7 @@ static void via_pm_class_init(ObjectClass *klass, void *data) k->revision =0x40 ; dc->desc ="PM" ; dc->vmsd = &vmstate_acpi; - dc->props = via_pm_properties; + klass->props = via_pm_properties; }static TypeInfo via_pm_info = {
hw/xgmac.c +1 -1
@@ -415,7 +415,7 @@ static void xgmac_enet_class_init(ObjectClass *klass, void *data) sbc->init = xgmac_enet_init; dc->vmsd = &vmstate_xgmac; - dc->props = xgmac_properties; + klass->props = xgmac_properties; }static TypeInfo xgmac_enet_info = {
hw/xilinx_axidma.c +1 -2
@@ -494,11 +494,10 @@ static Property axidma_properties[] = {static void axidma_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_axidma_init; - dc->props = axidma_properties; + klass->props = axidma_properties; }static TypeInfo axidma_info = {
hw/xilinx_axienet.c +1 -2
@@ -881,11 +881,10 @@ static Property xilinx_enet_properties[] = {static void xilinx_enet_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_enet_init; - dc->props = xilinx_enet_properties; + klass->props = xilinx_enet_properties; }static TypeInfo xilinx_enet_info = {
hw/xilinx_ethlite.c +1 -2
@@ -235,11 +235,10 @@ static Property xilinx_ethlite_properties[] = {static void xilinx_ethlite_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_ethlite_init; - dc->props = xilinx_ethlite_properties; + klass->props = xilinx_ethlite_properties; }static TypeInfo xilinx_ethlite_info = {
hw/xilinx_intc.c +1 -2
@@ -168,11 +168,10 @@ static Property xilinx_intc_properties[] = {static void xilinx_intc_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_intc_init; - dc->props = xilinx_intc_properties; + klass->props = xilinx_intc_properties; }static TypeInfo xilinx_intc_info = {
hw/xilinx_timer.c +1 -2
@@ -227,11 +227,10 @@ static Property xilinx_timer_properties[] = {static void xilinx_timer_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_timer_init; - dc->props = xilinx_timer_properties; + klass->props = xilinx_timer_properties; }static TypeInfo xilinx_timer_info = {
hw/xio3130_downstream.c +1 -1
@@ -193,7 +193,7 @@ static void xio3130_downstream_class_init(ObjectClass *klass, void *data) dc->desc ="TI X3130 Downstream Port of PCI Express Switch" ; dc->reset = xio3130_downstream_reset; dc->vmsd = &vmstate_xio3130_downstream; - dc->props = xio3130_downstream_properties; + klass->props = xio3130_downstream_properties; }static TypeInfo xio3130_downstream_info = {
hw/xio3130_upstream.c +1 -1
@@ -167,7 +167,7 @@ static void xio3130_upstream_class_init(ObjectClass *klass, void *data) dc->desc ="TI X3130 Upstream Port of PCI Express Switch" ; dc->reset = xio3130_upstream_reset; dc->vmsd = &vmstate_xio3130_upstream; - dc->props = xio3130_upstream_properties; + klass->props = xio3130_upstream_properties; }static TypeInfo xio3130_upstream_info = {
hw/zaurus.c +1 -1
@@ -233,7 +233,7 @@ static void scoop_sysbus_class_init(ObjectClass *klass, void *data) k->init = scoop_init; dc->desc ="Scoop2 Sharp custom ASIC" ; dc->vmsd = &vmstate_scoop_regs; - dc->props = scoop_sysbus_properties; + klass->props = scoop_sysbus_properties; }static TypeInfo scoop_sysbus_info = {
include/qemu/object.h +4 -3
@@ -33,6 +33,9 @@ typedef struct TypeInfo TypeInfo;typedef struct InterfaceClass InterfaceClass ;typedef struct InterfaceInfo InterfaceInfo ; +typedef struct Property Property ; +typedef struct PropertyInfo PropertyInfo ; +#define TYPE_OBJECT "object"/**
@@ -241,6 +244,7 @@ struct ObjectClassType type;/*< public >*/ +Property *props;const char *(*get_id)(Object *); };
@@ -983,9 +987,6 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),*/ Object *container_get (Object *root,const char *path); -typedef struct Property Property ; -typedef struct PropertyInfo PropertyInfo ; -struct Property {const char *name;PropertyInfo *info;
qom/object.c +20 -0
@@ -1262,9 +1262,28 @@ bool object_is_realized(Object *obj)return obj->state ==OBJECT_STATE_REALIZED ; } +static void object_class_base_init (ObjectClass *klass,void *data) +{ +/* We explicitly look up properties in the superclasses, +* so do not propagate them to the subclasses. +*/ + klass->props =NULL ; +} +static void object_instance_init (Object *obj) { +ObjectClass *class; +Property *prop; +object_property_add_str (obj,"type" , qdev_get_type,NULL ,NULL ); + + class =object_get_class (obj); +do { +for (prop =OBJECT_CLASS (class)->props; prop && prop->name; prop++) { +object_property_add_static (obj, prop,NULL ); + } + class =object_class_get_parent (class); + }while (class !=object_class_by_name (TYPE_OBJECT )); }static void object_class_init (ObjectClass *klass,void *class_data)
@@ -1283,6 +1302,7 @@ static void register_types(void)static TypeInfo object_info = { .name =TYPE_OBJECT , .instance_size =sizeof (Object), + .class_base_init = object_class_base_init, .instance_init = object_instance_init, .class_init = object_class_init, .abstract = true,
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH qom-next 7/7] qom: Add QERR_PROPERTY_SET_AFTER_REALIZE
In reply to Andreas FärberAm 07.06.2012 21:31, schrieb Andreas Färber:
Quoted 17 lines
From: Peter Maydell <[email protected]>
Add a new QError
QERR_PROPERTY_SET_AFTER_REALIZEfor attempts to set a QOM or qdev property after the object/device has been realized. This allows a slightly more informative diagnostic than the previous "Insufficient permission" message.Signed-off-by Peter Maydell <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>Signed-off-by Andreas Färber <[email protected]>--- hw/qdev-properties.c | 15 ++++++++++----- qerror.c | 4 ++++ qerror.h | 3 +++ qom/object-properties.c | 24 ++++++++++++++++-------- qom/object.c | 6 ++++-- 5 files changed, 37 insertions(+), 15 deletions(-)
[...]
Quoted 15 lines
qom/object.c +2
-1@@ -817,7 +817,8 @@ void object_property_get(Object *obj, Visitor *v, const char *name, }if (!prop->get) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name); }else { prop->get (obj, v, prop->opaque, name, errp); }
qom/object.c void object_property_set(Object *obj, Visitor *v, const char *name, · line 840
Quoted 9 lines
qom/object.c +2
-1@@ -832,7 +833,8 @@ void object_property_set(Object *obj, Visitor *v, const char *name, }if (!prop->set) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , +object_get_id (obj), name); }else { prop->set (obj, v, prop->opaque, name, errp); }
Hm, what does the lack of a setter have to do with realize? :) Reverting these two hunks.
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
Il 07/06/2012 21:30, Andreas Färber ha scritto:
Quoted 25 lines
Hi Paolo,
I've modified the remainder of your static properties series, in particular:
"qdev: Push state up to Object":
*OBJECT_STATE_CREATED->OBJECT_STATE_INITIALIZED, to align with QOM API
* Don't set early inobject_instance_init()but inobject_init_with_type()after all initfns have been run."qom: add
get_id":
*_object_get_id()->object_instance_get_id(), to avoid underscore
* Avoid GCC ?: expression, suggested by malc.
* Use newly introducedobject_property_is_child()helper."qdev: Generalize properties to Objects":
* Fixed indentation."qdev: Move bulk of
qdev-properties.ctoqom/object-properties.c":
* Documentation fix:qdev_property_add_static->object_property_add_static
* Move fromhw/qdev-properties.cto a newqom/object-properties.cinstead ofqom/object.c."qom: Push static properties to Object":
* Build fix: Adaptarm_gic_propertiesinhw/arm_gic.cas well.
Quoted 8 lines
"qom: Add "realized" property":
* Adapted toOBJECT_STATE_INITIALIZED."qom: Add
QERR_PROPERTY_SET_AFTER_REALIZE":
* Redid thehw/qdev-properties.cchanges inqom/object-properties.c.If you're okay with these, I'll append them to the qom-next queue and will send out the PULL.
Of course, thank you very much!
Paolo
Re: [Qemu-devel] [PATCH qom-next 4/7] qdev: Move bulk of qdev-properties.c to qom/object-properties.c
In reply to Andreas FärberIl 07/06/2012 21:31, Andreas Färber ha scritto:
Quoted 1 line
qom/Makefile | 2 +-
This will conflict (trivially) with the Makefile rewrite.
Paolo
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
In reply to Andreas FärberQuoted 244 lines · Andreas Färber
From: Paolo Bonzini<[email protected]>
qdev properties use the state member (an embryo of the "realized" property) in order to disable setting them after a device has been initialized. So, in order to push qdev properties up to Object we need to push this bit there too.
Signed-off-by Paolo Bonzini<[email protected]>[AF: Rename to OBJECT_STATE_INITIALIZED and set it after instance_init.]Signed-off-by Andreas Färber<[email protected]>--- hw/qdev-addr.c | 3 ++- hw/qdev-properties.c | 26 +++++++++++++------------- hw/qdev.c | 11 +++++------ hw/qdev.h | 6 ------ include/qemu/object.h | 14 ++++++++++++++ qom/object.c | 7 +++++++ 6 files changed, 41 insertions(+), 26 deletions(-)hw/qdev-addr.c +2
-1@@ -1,3 +1,4 @@ +#include "qemu/object.h" #include "qdev.h" #include "qdev-addr.h" #include "targphys.h" @@ -39,7 +40,7 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;int64_t value; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }hw/qdev-properties.c +13
-13@@ -53,7 +53,7 @@ static void set_bit(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;bool value; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -93,7 +93,7 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint8_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -160,7 +160,7 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint16_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -193,7 +193,7 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint32_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -218,7 +218,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;int32_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -291,7 +291,7 @@ static void set_uint64(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;uint64_t *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -379,7 +379,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;char *str; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -457,7 +457,7 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,char *str;int ret; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -626,7 +626,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,int64_t id;VLANState *vlan; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -696,7 +696,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,int i, pos;char *str, *p; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -766,7 +766,7 @@ static void set_enum(Object *obj, Visitor *v, void *opaque,Property *prop = opaque;int *ptr =qdev_get_prop_ptr (dev, prop); -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -797,7 +797,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,Error *local_err =NULL ;char *str; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -867,7 +867,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,const int64_t min =512 ;const int64_t max =32768 ; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }hw/qdev.c +5
-6@@ -155,7 +155,7 @@ int qdev_init(DeviceState *dev)DeviceClass *dc =DEVICE_GET_CLASS (dev);int rc; -assert (dev->state ==DEV_STATE_CREATED ); +assert (!object_is_realized (OBJECT (dev))); rc = dc->init (dev);if (rc<0 ) {@@ -178,7 +178,7 @@ int qdev_init(DeviceState *dev) dev->instance_id_alias, dev->alias_required_for_version); } - dev->state =DEV_STATE_INITIALIZED ; +OBJECT (dev)->state =OBJECT_STATE_REALIZED ;if (dev->hotplugged) {device_reset (dev); }@@ -188,7 +188,7 @@ int qdev_init(DeviceState *dev)void qdev_set_legacy_instance_id (DeviceState *dev,int alias_id,int required_for_version) { -assert (dev->state ==DEV_STATE_CREATED ); +assert (!object_is_realized (OBJECT (dev))); dev->instance_id_alias = alias_id; dev->alias_required_for_version = required_for_version; }@@ -567,7 +567,7 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque,char *ptr =NULL ;int ret; -if (dev->state !=DEV_STATE_CREATED ) { +if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );return ; }@@ -674,7 +674,6 @@ static void device_initfn(Object *obj) } dev->instance_id_alias =-1 ; - dev->state =DEV_STATE_CREATED ; class =object_get_class (OBJECT (dev)); do {@@ -697,7 +696,7 @@ static void device_finalize(Object *obj)BusState *bus;DeviceClass *dc =DEVICE_GET_CLASS (dev); -if (dev->state ==DEV_STATE_INITIALIZED ) { +if (object_is_realized (obj)) {while (dev->num_child_bus) { bus =QLIST_FIRST (&dev->child_bus);qbus_free (bus);hw/qdev.h +0
-6@@ -19,11 +19,6 @@ typedef struct BusState BusState;typedef struct BusClass BusClass ; -enum DevState { -DEV_STATE_CREATED =1 , -DEV_STATE_INITIALIZED , -}; -enum {DEV_NVECTORS_UNSPECIFIED =-1 , };@@ -64,7 +59,6 @@ struct DeviceState {Object parent_obj;const char *id; -enum DevState state;QemuOpts *opts;int hotplugged;BusState *parent_bus;include/qemu/object.h +0
-0
include/qemu/object.h struct ObjectClass · line 247
Quoted 7 lines
include/qemu/object.h +4
-0@@ -241,6 +241,11 @@ struct ObjectClassType type; }; +typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;
I think using a bool would be better since it reduces the temptation to add additional states.
Regards,
Anthony Liguori
Anthony Liguori
NAKRe: [Qemu-devel] [PATCH qom-next 2/7] qom: Add get_id
In reply to Andreas FärberQuoted 11 lines · Andreas Färber
From: Paolo Bonzini<[email protected]>
Some classes may present objects differently in errors, for example if they are not part of the composition tree or if they are not assigned an id by the user. Let them do this with a
get_idmethod on Object, and use the method consistently where a %(device) appears in the error.Signed-off-by Paolo Bonzini<[email protected]>[AF: Renamed _object_get_id() to object_instance_get_id(), avoid ?:.][AF: Use object_property_is_child().]Signed-off-by Andreas Färber<[email protected]>
Nack.
This creates confusion IMHO. There's a big difference between an object typename and the path to the object. I don't think we should confuse the two by introducing a third type of name and calling it something generic like id.
Quoted 123 lines
--- hw/qdev-properties.c | 6 +++--- hw/qdev.c | 15 ++++++++++++++- include/qemu/object.h | 11 +++++++++++ qom/object.c | 26 +++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 5 deletions(-)hw/qdev-properties.c +3
-3@@ -937,16 +937,16 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,switch (ret) {case -EEXIST :error_set (errp,QERR_PROPERTY_VALUE_IN_USE , -object_get_typename (OBJECT (dev)), prop->name, value); +object_get_id (OBJECT (dev)), prop->name, value);break ;default :case -EINVAL :error_set (errp,QERR_PROPERTY_VALUE_BAD , -object_get_typename (OBJECT (dev)), prop->name, value); +object_get_id (OBJECT (dev)), prop->name, value);break ;case -ENOENT :error_set (errp,QERR_PROPERTY_VALUE_NOT_FOUND , -object_get_typename (OBJECT (dev)), prop->name, value); +object_get_id (OBJECT (dev)), prop->name, value);break ;case 0 :break ;hw/qdev.c +14
-1@@ -259,7 +259,7 @@ void qdev_init_nofail(DeviceState *dev) {if (qdev_init (dev)<0 ) {error_report ("Initialization of device %s failed" , -object_get_typename (OBJECT (dev))); +object_get_id (OBJECT (dev)));exit (1 ); } }@@ -716,6 +716,13 @@ static void device_finalize(Object *obj) } } +static const char *qdev_get_id (Object *obj) +{ +DeviceState *dev =DEVICE (obj); + +return dev->id !=NULL ? dev->id :object_get_typename (obj); +} +static void device_class_base_init (ObjectClass *class,void *data) {DeviceClass *klass =DEVICE_CLASS (class);@@ -746,6 +753,11 @@ Object *qdev_get_machine(void)return dev; } +static void device_class_init (ObjectClass *class,void *data) +{ + class->get_id = qdev_get_id; +} +static TypeInfo device_type_info = { .name =TYPE_DEVICE , .parent =TYPE_OBJECT ,@@ -753,6 +765,7 @@ static TypeInfo device_type_info = { .instance_init = device_initfn, .instance_finalize = device_finalize, .class_base_init = device_class_base_init, + .class_init = device_class_init, .abstract = true, .class_size = sizeof(DeviceClass), };include/qemu/object.h +11
-0@@ -239,6 +239,9 @@ struct ObjectClass {/*< private>*/ Type type; + +/*< public>*/ +const char *(*get_id)(Object *); }; typedef enum ObjectState {@@ -507,6 +510,14 @@ Object *object_dynamic_cast(Object *obj, const char *typename);Object *object_dynamic_cast_assert (Object *obj,const char *typename);/** +* object_get_id: +* @obj: A derivative of #Object +* +* Returns: A string that can be used to refer to @obj. +*/ +const char *object_get_id (Object *obj); + +/** * object_get_class: * @obj: A derivative of #Object * qom/object.c +8
-0@@ -346,6 +346,24 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp) } } +static const char *object_instance_get_id (Object *obj) +{ +ObjectProperty *prop; + + QTAILQ_FOREACH(prop,&obj->properties, node) { +if (object_property_is_child (prop)&& prop->opaque == obj) { +return prop->name; + }
qom/object.c static void object_property_del_child(Object *obj, Object *child, Error **errp) · line 366
Quoted 10 lines
qom/object.c +10
-0+ } + +return "" ; +} + +const char *object_get_id (Object *obj) +{ +return obj->class->get_id (obj); +} +
We should use a canonical path IMHO instead of returning a partial name.
Partial names are ambiguous.
Regards,
Anthony Liguori
Re: [Qemu-devel] [PATCH qom-next 3/7] qdev: Generalize properties to Objects
In reply to Andreas FärberQuoted 8 lines · Andreas Färber
From: Paolo Bonzini<[email protected]>
The property machinery uses DeviceState arguments in a few places. Replace this with Object so that we can push properties up.
Signed-off-by Paolo Bonzini<[email protected]>[AF: Fixed indentation in set_taddr().]Signed-off-by Andreas Färber<[email protected]>
Reviewed-by; Anthony Liguori <[email protected]>
Regards,
Anthony Liguori
Quoted 739 lines
--- hw/qdev-addr.c | 19 ++--- hw/qdev-properties.c | 180 +++++++++++++++++++++---------------------------- hw/qdev.c | 8 +-- hw/qdev.h | 10 ++-- 4 files changed, 93 insertions(+), 124 deletions(-)hw/qdev-addr.c +8
-11@@ -5,26 +5,25 @@/* --- target physical address --- */ -static int parse_taddr (DeviceState *dev,Property *prop,const char *str) +static int parse_taddr (Object *obj,Property *prop,const char *str) { -target_phys_addr_t *ptr =qdev_get_prop_ptr (dev, prop); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop); *ptr =strtoull (str,NULL ,16 );return 0 ; } -static int print_taddr (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_taddr (Object *obj,Property *prop,char *dest,size_t len) { -target_phys_addr_t *ptr =qdev_get_prop_ptr (dev, prop); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop);return snprintf (dest, len,"0x" TARGET_FMT_plx, *ptr); }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); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop);int64_t value; value = *ptr;@@ -34,9 +33,8 @@ static void get_taddr(Object *obj, 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); +target_phys_addr_t *ptr =object_get_prop_ptr (obj, prop);Error *local_err =NULL ;int64_t value;@@ -53,9 +51,8 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,if ((uint64_t )value<= (uint64_t ) ~(target_phys_addr_t )0 ) { *ptr = value; }else { -error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE , - dev->id?:"" , name, value, (uint64_t )0 , - (uint64_t ) ~(target_phys_addr_t )0 ); +error_set (errp,QERR_INVALID_PARAMETER_VALUE , + name,"target_phys_addr_t" ); } }hw/qdev-properties.c +77
-103@@ -3,23 +3,23 @@#include "qerror.h" #include "blockdev.h" -void *qdev_get_prop_ptr (DeviceState *dev,Property *prop) +void *object_get_prop_ptr (Object *obj,Property *prop) { -void *ptr = dev; +void *ptr = obj; ptr += prop->offset;return ptr; } -static uint32_t qdev_get_prop_mask (Property *prop) +static uint32_t get_prop_mask (Property *prop) {assert (prop->info ==&qdev_prop_bit);return 0x1 << prop->bitnr; } -static void bit_prop_set (DeviceState *dev,Property *props,bool val) +static void bit_prop_set (Object *obj,Property *props,bool val) { -uint32_t *p =qdev_get_prop_ptr (dev, props); -uint32_t mask =qdev_get_prop_mask (props); +uint32_t *p =object_get_prop_ptr (obj, props); +uint32_t mask =get_prop_mask (props);if (val) *p |= mask;else @@ -28,19 +28,18 @@ static void bit_prop_set(DeviceState *dev, Property *props, bool val)/* Bit */ -static int print_bit (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_bit (Object *obj,Property *prop,char *dest,size_t len) { -uint32_t *p =qdev_get_prop_ptr (dev, prop); -return snprintf (dest, len, (*p&qdev_get_prop_mask (prop)) ?"on" :"off" ); +uint32_t *p =object_get_prop_ptr (obj, prop); +return snprintf (dest, len, (*p&get_prop_mask (prop)) ?"on" :"off" ); }static void get_bit (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint32_t *p =qdev_get_prop_ptr (dev, prop); -bool value = (*p&qdev_get_prop_mask (prop)) !=0 ; +uint32_t *p =object_get_prop_ptr (obj, prop); +bool value = (*p&get_prop_mask (prop)) !=0 ;visit_type_bool (v,&value, name, errp); }@@ -48,7 +47,6 @@ static void get_bit(Object *obj, Visitor *v, void *opaque,static void set_bit (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;Error *local_err =NULL ;bool value;@@ -63,7 +61,7 @@ static void set_bit(Object *obj, Visitor *v, void *opaque,error_propagate (errp, local_err);return ; } -bit_prop_set (dev, prop, value); +bit_prop_set (obj, prop, value); }PropertyInfo qdev_prop_bit = {@@ -79,9 +77,8 @@ PropertyInfo qdev_prop_bit = {static void get_uint8 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint8_t *ptr =qdev_get_prop_ptr (dev, prop); +uint8_t *ptr =object_get_prop_ptr (obj, prop);visit_type_uint8 (v, ptr, name, errp); }@@ -89,9 +86,8 @@ static void get_uint8(Object *obj, Visitor *v, void *opaque,static void set_uint8 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint8_t *ptr =qdev_get_prop_ptr (dev, prop); +uint8_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );@@ -109,9 +105,9 @@ PropertyInfo qdev_prop_uint8 = {/* --- 8bit hex value --- */ -static int parse_hex8 (DeviceState *dev,Property *prop,const char *str) +static int parse_hex8 (Object *obj,Property *prop,const char *str) { -uint8_t *ptr =qdev_get_prop_ptr (dev, prop); +uint8_t *ptr =object_get_prop_ptr (obj, prop);char *end;if (str[0 ] !='0' || str[1 ] !='x' ) {@@ -126,9 +122,9 @@ static int parse_hex8(DeviceState *dev, Property *prop, const char *str)return 0 ; } -static int print_hex8 (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_hex8 (Object *obj,Property *prop,char *dest,size_t len) { -uint8_t *ptr =qdev_get_prop_ptr (dev, prop); +uint8_t *ptr =object_get_prop_ptr (obj, prop);return snprintf (dest, len,"0x%" PRIx8, *ptr); }@@ -146,9 +142,8 @@ PropertyInfo qdev_prop_hex8 = {static void get_uint16 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint16_t *ptr =qdev_get_prop_ptr (dev, prop); +uint16_t *ptr =object_get_prop_ptr (obj, prop);visit_type_uint16 (v, ptr, name, errp); }@@ -156,9 +151,8 @@ static void get_uint16(Object *obj, Visitor *v, void *opaque,static void set_uint16 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint16_t *ptr =qdev_get_prop_ptr (dev, prop); +uint16_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );@@ -179,9 +173,8 @@ PropertyInfo qdev_prop_uint16 = {static void get_uint32 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (dev, prop); +uint32_t *ptr =object_get_prop_ptr (obj, prop);visit_type_uint32 (v, ptr, name, errp); }@@ -189,9 +182,8 @@ static void get_uint32(Object *obj, Visitor *v, void *opaque,static void set_uint32 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (dev, prop); +uint32_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );@@ -204,9 +196,8 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,static void get_int32 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -int32_t *ptr =qdev_get_prop_ptr (dev, prop); +int32_t *ptr =object_get_prop_ptr (obj, prop);visit_type_int32 (v, ptr, name, errp); }@@ -214,9 +205,8 @@ static void get_int32(Object *obj, Visitor *v, void *opaque,static void set_int32 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -int32_t *ptr =qdev_get_prop_ptr (dev, prop); +int32_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );@@ -240,9 +230,9 @@ PropertyInfo qdev_prop_int32 = {/* --- 32bit hex value --- */ -static int parse_hex32 (DeviceState *dev,Property *prop,const char *str) +static int parse_hex32 (Object *obj,Property *prop,const char *str) { -uint32_t *ptr =qdev_get_prop_ptr (dev, prop); +uint32_t *ptr =object_get_prop_ptr (obj, prop);char *end;if (str[0 ] !='0' || str[1 ] !='x' ) {@@ -257,9 +247,9 @@ static int parse_hex32(DeviceState *dev, Property *prop, const char *str)return 0 ; } -static int print_hex32 (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_hex32 (Object *obj,Property *prop,char *dest,size_t len) { -uint32_t *ptr =qdev_get_prop_ptr (dev, prop); +uint32_t *ptr =object_get_prop_ptr (obj, prop);return snprintf (dest, len,"0x%" PRIx32, *ptr); }@@ -277,9 +267,8 @@ PropertyInfo qdev_prop_hex32 = {static void get_uint64 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint64_t *ptr =qdev_get_prop_ptr (dev, prop); +uint64_t *ptr =object_get_prop_ptr (obj, prop);visit_type_uint64 (v, ptr, name, errp); }@@ -287,9 +276,8 @@ static void get_uint64(Object *obj, Visitor *v, void *opaque,static void set_uint64 (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint64_t *ptr =qdev_get_prop_ptr (dev, prop); +uint64_t *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );@@ -307,9 +295,9 @@ PropertyInfo qdev_prop_uint64 = {/* --- 64bit hex value --- */ -static int parse_hex64 (DeviceState *dev,Property *prop,const char *str) +static int parse_hex64 (Object *obj,Property *prop,const char *str) { -uint64_t *ptr =qdev_get_prop_ptr (dev, prop); +uint64_t *ptr =object_get_prop_ptr (obj, prop);char *end;if (str[0 ] !='0' || str[1 ] !='x' ) {@@ -324,9 +312,9 @@ static int parse_hex64(DeviceState *dev, Property *prop, const char *str)return 0 ; } -static int print_hex64 (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_hex64 (Object *obj,Property *prop,char *dest,size_t len) { -uint64_t *ptr =qdev_get_prop_ptr (dev, prop); +uint64_t *ptr =object_get_prop_ptr (obj, prop);return snprintf (dest, len,"0x%" PRIx64, *ptr); }@@ -344,12 +332,12 @@ PropertyInfo qdev_prop_hex64 = {static void release_string (Object *obj,const char *name,void *opaque) {Property *prop = opaque; -g_free (*(char **)qdev_get_prop_ptr (DEVICE (obj), prop)); +g_free (*(char **)object_get_prop_ptr (obj, prop)); } -static int print_string (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_string (Object *obj,Property *prop,char *dest,size_t len) { -char **ptr =qdev_get_prop_ptr (dev, prop); +char **ptr =object_get_prop_ptr (obj, prop);if (!*ptr)return snprintf (dest, len,"<null>" );return snprintf (dest, len,"\"%s\"" , *ptr);@@ -358,9 +346,8 @@ static int print_string(DeviceState *dev, Property *prop, char *dest, size_t lenstatic void get_string (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -char **ptr =qdev_get_prop_ptr (dev, prop); +char **ptr =object_get_prop_ptr (obj, prop);if (!*ptr) {char *str = (char *)"" ;@@ -373,9 +360,8 @@ static void get_string(Object *obj, Visitor *v, void *opaque,static void set_string (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -char **ptr =qdev_get_prop_ptr (dev, prop); +char **ptr =object_get_prop_ptr (obj, prop);Error *local_err =NULL ;char *str;@@ -405,14 +391,14 @@ PropertyInfo qdev_prop_string = {/* --- drive --- */ -static int parse_drive (DeviceState *dev,const char *str,void **ptr) +static int parse_drive (Object *obj,const char *str,void **ptr) {BlockDriverState *bs; bs =bdrv_find (str);if (bs ==NULL )return -ENOENT ; -if (bdrv_attach_dev (bs, dev)<0 ) +if (bdrv_attach_dev (bs, obj)<0 )return -EEXIST ; *ptr = bs;return 0 ;@@ -420,12 +406,11 @@ static int parse_drive(DeviceState *dev, const char *str, void **ptr)static void release_drive (Object *obj,const char *name,void *opaque) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -BlockDriverState **ptr =qdev_get_prop_ptr (dev, prop); +BlockDriverState **ptr =object_get_prop_ptr (obj, prop);if (*ptr) { -bdrv_detach_dev (*ptr, dev); +bdrv_detach_dev (*ptr, obj);blockdev_auto_del (*ptr); } }@@ -439,8 +424,7 @@ static void get_pointer(Object *obj, Visitor *v, Property *prop,const char *(*print)(void *ptr), const char *name, Error **errp) { - DeviceState *dev = DEVICE(obj); -void **ptr =qdev_get_prop_ptr (dev, prop); + void **ptr = object_get_prop_ptr(obj, prop);char *p; p = (char *) (*ptr ?"" );@@ -448,12 +432,11 @@ static void get_pointer(Object *obj, Visitor *v, Property *prop, }static void set_pointer (Object *obj,Visitor *v,Property *prop, -int (*parse)(DeviceState *dev,const char *str,void **ptr), +int (*parse)(Object *obj,const char *str,void **ptr),const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Error *local_err =NULL ; -void **ptr =qdev_get_prop_ptr (dev, prop); +void **ptr =object_get_prop_ptr (obj, prop);char *str;int ret;@@ -472,8 +455,8 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop, *ptr =NULL ;return ; } - ret =parse (dev, str, ptr); -error_set_from_qdev_prop_error (errp, ret, dev, prop, str); + ret =parse (obj, str, ptr); +error_set_from_prop_error (errp, ret, obj, prop, str);g_free (str); }@@ -498,7 +481,7 @@ PropertyInfo qdev_prop_drive = {/* --- character device --- */ -static int parse_chr (DeviceState *dev,const char *str,void **ptr) +static int parse_chr (Object *obj,const char *str,void **ptr) {CharDriverState *chr =qemu_chr_find (str);if (chr ==NULL ) {@@ -514,9 +497,8 @@ static int parse_chr(DeviceState *dev, const char *str, void **ptr)static void release_chr (Object *obj,const char *name,void *opaque) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -CharDriverState **ptr =qdev_get_prop_ptr (dev, prop); +CharDriverState **ptr =object_get_prop_ptr (obj, prop);if (*ptr) {qemu_chr_add_handlers (*ptr,NULL ,NULL ,NULL ,NULL );@@ -552,7 +534,7 @@ PropertyInfo qdev_prop_chr = {/* --- netdev device --- */ -static int parse_netdev (DeviceState *dev,const char *str,void **ptr) +static int parse_netdev (Object *obj,const char *str,void **ptr) {VLANClientState *netdev =qemu_find_netdev (str);@@ -593,9 +575,9 @@ PropertyInfo qdev_prop_netdev = {/* --- vlan --- */ -static int print_vlan (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_vlan (Object *obj,Property *prop,char *dest,size_t len) { -VLANState **ptr =qdev_get_prop_ptr (dev, prop); +VLANState **ptr =object_get_prop_ptr (obj, prop);if (*ptr) {return snprintf (dest, len,"%d" , (*ptr)->id);@@ -607,9 +589,8 @@ static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)static void get_vlan (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -VLANState **ptr =qdev_get_prop_ptr (dev, prop); +VLANState **ptr =object_get_prop_ptr (obj, prop);int64_t id; id = *ptr ? (*ptr)->id :-1 ;@@ -619,9 +600,8 @@ static void get_vlan(Object *obj, Visitor *v, void *opaque,static void set_vlan (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -VLANState **ptr =qdev_get_prop_ptr (dev, prop); +VLANState **ptr =object_get_prop_ptr (obj, prop);Error *local_err =NULL ;int64_t id;VLANState *vlan;@@ -673,9 +653,8 @@ PropertyInfo qdev_prop_ptr = {static void get_mac (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -MACAddr *mac =qdev_get_prop_ptr (dev, prop); +MACAddr *mac =object_get_prop_ptr (obj, prop);char buffer[2 *6 +5 +1 ];char *p = buffer;@@ -689,9 +668,8 @@ static void get_mac(Object *obj, Visitor *v, void *opaque,static void set_mac (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -MACAddr *mac =qdev_get_prop_ptr (dev, prop); +MACAddr *mac =object_get_prop_ptr (obj, prop);Error *local_err =NULL ;int i, pos;char *str, *p;@@ -725,7 +703,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,return ; inval: -error_set_from_qdev_prop_error (errp,EINVAL , dev, prop, str); +error_set_from_prop_error (errp,EINVAL , obj, prop, str);g_free (str); }@@ -751,9 +729,8 @@ QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));static void get_enum (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -int *ptr =qdev_get_prop_ptr (dev, prop); +int *ptr =object_get_prop_ptr (obj, prop);visit_type_enum (v, ptr, prop->info->enum_table, prop->info->name, prop->name, errp);@@ -762,9 +739,8 @@ static void get_enum(Object *obj, Visitor *v, void *opaque,static void set_enum (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -int *ptr =qdev_get_prop_ptr (dev, prop); +int *ptr =object_get_prop_ptr (obj, prop);if (object_is_realized (obj)) {error_set (errp,QERR_PERMISSION_DENIED );@@ -790,9 +766,8 @@ PropertyInfo qdev_prop_losttickpolicy = {static void set_pci_devfn (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -int32_t value, *ptr =qdev_get_prop_ptr (dev, prop); +int32_t value, *ptr =object_get_prop_ptr (obj, prop);unsigned int slot, fn, n;Error *local_err =NULL ;char *str;@@ -832,13 +807,13 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,return ; invalid: -error_set_from_qdev_prop_error (errp,EINVAL , dev, prop, str); +error_set_from_prop_error (errp,EINVAL , obj, prop, str);g_free (str); } -static int print_pci_devfn (DeviceState *dev,Property *prop,char *dest,size_t len) +static int print_pci_devfn (Object *obj,Property *prop,char *dest,size_t len) { -int32_t *ptr =qdev_get_prop_ptr (dev, prop); +int32_t *ptr =object_get_prop_ptr (obj, prop);if (*ptr ==-1 ) {return snprintf (dest, len,"<unset>" );@@ -860,9 +835,8 @@ PropertyInfo qdev_prop_pci_devfn = {static void set_blocksize (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -uint16_t value, *ptr =qdev_get_prop_ptr (dev, prop); +uint16_t value, *ptr =object_get_prop_ptr (obj, prop);Error *local_err =NULL ;const int64_t min =512 ;const int64_t max =32768 ;@@ -879,14 +853,14 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque, }if (value< min || value> max) {error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE , - dev->id?:"" , name, (int64_t )value, min, max); +object_get_id (obj), name, (int64_t )value, min, max);return ; }/* We rely on power-of-2 blocksizes for bitmasks */ if ((value& (value -1 )) !=0 ) {error_set (errp,QERR_PROPERTY_VALUE_NOT_POWER_OF_2 , - dev->id?:"" , name, (int64_t )value); +object_get_id (obj), name, (int64_t )value);return ; }@@ -913,13 +887,13 @@ static Property *qdev_prop_walk(Property *props, const char *name)return NULL ; } -static Property *qdev_prop_find (DeviceState *dev,const char *name) +static Property *qdev_prop_find (Object *obj,const char *name) {ObjectClass *class;Property *prop;/* device properties */ - class =object_get_class (OBJECT (dev)); + class =object_get_class (obj); do { prop = qdev_prop_walk(DEVICE_CLASS(class)->props, name); if (prop) {@@ -931,22 +905,22 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)return NULL ; } -void error_set_from_qdev_prop_error (Error **errp,int ret,DeviceState *dev, -Property *prop,const char *value) +void error_set_from_prop_error (Error **errp,int ret,Object *obj, +Property *prop,const char *value) {switch (ret) {case -EEXIST :error_set (errp,QERR_PROPERTY_VALUE_IN_USE , -object_get_id (OBJECT (dev)), prop->name, value); +object_get_id (obj), prop->name, value);break ;default :case -EINVAL :error_set (errp,QERR_PROPERTY_VALUE_BAD , -object_get_id (OBJECT (dev)), prop->name, value); +object_get_id (obj), prop->name, value);break ;case -ENOENT :error_set (errp,QERR_PROPERTY_VALUE_NOT_FOUND , -object_get_id (OBJECT (dev)), prop->name, value); +object_get_id (obj), prop->name, value);break ;case 0 :break ;@@ -1084,7 +1058,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value)Property *prop;Error *errp =NULL ; - prop =qdev_prop_find (dev, name); + prop =qdev_prop_find (OBJECT (dev), name);object_property_set_str (OBJECT (dev), prop->info->enum_table[value], name,&errp);assert_no_error (errp);@@ -1095,9 +1069,9 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)Property *prop;void **ptr; - prop =qdev_prop_find (dev, name); + prop =qdev_prop_find (OBJECT (dev), name);assert (prop&& prop->info ==&qdev_prop_ptr); - ptr =qdev_get_prop_ptr (dev, prop); + ptr =object_get_prop_ptr (OBJECT (dev), prop); *ptr = value; }hw/qdev.c +3
-5@@ -548,20 +548,18 @@ char *qdev_get_dev_path(DeviceState *dev)static void qdev_get_legacy_property (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;char buffer[1024 ];char *ptr = buffer; - prop->info->sizeof (buffer)); + prop->info->sizeof (buffer));visit_type_str (v,&ptr, name, errp); }static void qdev_set_legacy_property (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;Error *local_err =NULL ;char *ptr =NULL ;@@ -578,8 +576,8 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque,return ; } - ret = prop->info->parse (dev, prop, ptr); -error_set_from_qdev_prop_error (errp, ret, dev, prop, ptr); + ret = prop->info->parse (obj, prop, ptr); +error_set_from_prop_error (errp, ret, obj, prop, ptr);g_free (ptr); }hw/qdev.h +5
-5@@ -130,8 +130,8 @@ struct PropertyInfo {const char *name;const char *legacy_name;const char **enum_table; -int (*parse)(DeviceState *dev,Property *prop,const char *str); -int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len); +int (*parse)(Object *obj,Property *prop,const char *str); +int (*print)(Object *obj,Property *prop,char *dest,size_t len);ObjectPropertyAccessor *get;ObjectPropertyAccessor *set;ObjectPropertyRelease *release;@@ -299,7 +299,7 @@ extern PropertyInfo qdev_prop_blocksize; {}/* Set properties between creation and init. */ -void *qdev_get_prop_ptr (DeviceState *dev,Property *prop); +void *object_get_prop_ptr (Object *obj,Property *prop);int qdev_prop_parse (DeviceState *dev,const char *name,const char *value);void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value);void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);@@ -320,8 +320,8 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);void qdev_prop_register_global_list (GlobalProperty *props);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); +void error_set_from_prop_error (Error **errp,int ret,Object *obj, +Property *prop,const char *value);char *qdev_get_fw_dev_path (DeviceState *dev);
Re: [Qemu-devel] [PATCH qom-next 4/7] qdev: Move bulk of qdev-properties.c to qom/object-properties.c
In reply to Andreas FärberQuoted 5 lines · Andreas Färber
From: Paolo Bonzini<[email protected]>
Signed-off-by Paolo Bonzini<[email protected]>[AF: Move to new qom/object-properties.c, update documentation.]Signed-off-by Andreas Färber<[email protected]>
Regards,
Anthony Liguori
Quoted 1,353 lines
--- hw/qdev-properties.c | 487 +++++------------------------------------------ hw/qdev.c | 47 +----- hw/qdev.h | 87 --------- include/qemu/object.h | 98 ++++++++++ qom/Makefile | 2 +- qom/object-properties.c | 461 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 607 insertions(+), 575 deletions(-)create mode 100644
qom/object-properties.chw/qdev-properties.c +46
-441@@ -3,392 +3,27 @@#include "qerror.h" #include "blockdev.h" -void *object_get_prop_ptr (Object *obj,Property *prop) -{ -void *ptr = obj; - ptr += prop->offset; -return ptr; -} - -static uint32_t get_prop_mask (Property *prop) -{ -assert (prop->info ==&qdev_prop_bit); -return 0x1 << prop->bitnr; -} - -static void bit_prop_set (Object *obj,Property *props,bool val) -{ -uint32_t *p =object_get_prop_ptr (obj, props); -uint32_t mask =get_prop_mask (props); -if (val) - *p |= mask; -else - *p&= ~mask; -} - -/* Bit */ - -static int print_bit (Object *obj,Property *prop,char *dest,size_t len) -{ -uint32_t *p =object_get_prop_ptr (obj, prop); -return snprintf (dest, len, (*p&get_prop_mask (prop)) ?"on" :"off" ); -} - -static void get_bit (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint32_t *p =object_get_prop_ptr (obj, prop); -bool value = (*p&get_prop_mask (prop)) !=0 ; - -visit_type_bool (v,&value, name, errp); -} - -static void set_bit (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -Error *local_err =NULL ; -bool value; - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_bool (v,&value, name,&local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } -bit_prop_set (obj, prop, value); -} - -PropertyInfo qdev_prop_bit = { - .name ="boolean" , - .legacy_name ="on/off" , - .print = print_bit, - .get = get_bit, - .set = set_bit, -}; - -/* --- 8bit integer --- */ - -static void get_uint8 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint8_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint8 (v, ptr, name, errp); -} - -static void set_uint8 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint8_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint8 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint8 = { - .name ="uint8" , - .get = get_uint8, - .set = set_uint8, -}; - -/* --- 8bit hex value --- */ - -static int parse_hex8 (Object *obj,Property *prop,const char *str) -{ -uint8_t *ptr =object_get_prop_ptr (obj, prop); -char *end; - -if (str[0 ] !='0' || str[1 ] !='x' ) { -return -EINVAL ; - } - - *ptr =strtoul (str,&end,16 ); -if ((*end !='\0' ) || (end == str)) { -return -EINVAL ; - } - -return 0 ; -} - -static int print_hex8 (Object *obj,Property *prop,char *dest,size_t len) -{ -uint8_t *ptr =object_get_prop_ptr (obj, prop); -return snprintf (dest, len,"0x%" PRIx8, *ptr); -} - -PropertyInfo qdev_prop_hex8 = { - .name ="uint8" , - .legacy_name ="hex8" , - .parse = parse_hex8, - .print = print_hex8, - .get = get_uint8, - .set = set_uint8, -}; - -/* --- 16bit integer --- */ - -static void get_uint16 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint16_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint16 (v, ptr, name, errp); -} - -static void set_uint16 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint16_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint16 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint16 = { - .name ="uint16" , - .get = get_uint16, - .set = set_uint16, -}; - -/* --- 32bit integer --- */ - -static void get_uint32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint32_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint32 (v, ptr, name, errp); -} - -static void set_uint32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint32_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint32 (v, ptr, name, errp); -} - -static void get_int32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int32_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_int32 (v, ptr, name, errp); -} - -static void set_int32 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int32_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_int32 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint32 = { - .name ="uint32" , - .get = get_uint32, - .set = set_uint32, -}; - -PropertyInfo qdev_prop_int32 = { - .name ="int32" , - .get = get_int32, - .set = set_int32, -}; - -/* --- 32bit hex value --- */ - -static int parse_hex32 (Object *obj,Property *prop,const char *str) -{ -uint32_t *ptr =object_get_prop_ptr (obj, prop); -char *end; - -if (str[0 ] !='0' || str[1 ] !='x' ) { -return -EINVAL ; - } - - *ptr =strtoul (str,&end,16 ); -if ((*end !='\0' ) || (end == str)) { -return -EINVAL ; - } - -return 0 ; -} - -static int print_hex32 (Object *obj,Property *prop,char *dest,size_t len) -{ -uint32_t *ptr =object_get_prop_ptr (obj, prop); -return snprintf (dest, len,"0x%" PRIx32, *ptr); -} - -PropertyInfo qdev_prop_hex32 = { - .name ="uint32" , - .legacy_name ="hex32" , - .parse = parse_hex32, - .print = print_hex32, - .get = get_uint32, - .set = set_uint32, -}; - -/* --- 64bit integer --- */ - -static void get_uint64 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint64_t *ptr =object_get_prop_ptr (obj, prop); - -visit_type_uint64 (v, ptr, name, errp); -} - -static void set_uint64 (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -uint64_t *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_uint64 (v, ptr, name, errp); -} - -PropertyInfo qdev_prop_uint64 = { - .name ="uint64" , - .get = get_uint64, - .set = set_uint64, -}; - -/* --- 64bit hex value --- */ - -static int parse_hex64 (Object *obj,Property *prop,const char *str) -{ -uint64_t *ptr =object_get_prop_ptr (obj, prop); -char *end; - -if (str[0 ] !='0' || str[1 ] !='x' ) { -return -EINVAL ; - } - - *ptr =strtoull (str,&end,16 ); -if ((*end !='\0' ) || (end == str)) { -return -EINVAL ; - } - -return 0 ; -} - -static int print_hex64 (Object *obj,Property *prop,char *dest,size_t len) -{ -uint64_t *ptr =object_get_prop_ptr (obj, prop); -return snprintf (dest, len,"0x%" PRIx64, *ptr); -} - -PropertyInfo qdev_prop_hex64 = { - .name ="uint64" , - .legacy_name ="hex64" , - .parse = parse_hex64, - .print = print_hex64, - .get = get_uint64, - .set = set_uint64, -}; - -/* --- string --- */ - -static void release_string (Object *obj,const char *name,void *opaque) -{ -Property *prop = opaque; -g_free (*(char **)object_get_prop_ptr (obj, prop)); -} - -static int print_string (Object *obj,Property *prop,char *dest,size_t len) -{ -char **ptr =object_get_prop_ptr (obj, prop); -if (!*ptr) -return snprintf (dest, len,"<null>" ); -return snprintf (dest, len,"\"%s\"" , *ptr); -} - -static void get_string (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -char **ptr =object_get_prop_ptr (obj, prop); - -if (!*ptr) { -char *str = (char *)"" ; -visit_type_str (v,&str, name, errp); - }else { -visit_type_str (v, ptr, name, errp); - } -} - -static void set_string (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) +void error_set_from_prop_error (Error **errp,int ret,Object *obj, +Property *prop,const char *value) { -Property *prop = opaque; -char **ptr =object_get_prop_ptr (obj, prop); -Error *local_err =NULL ; -char *str; - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_str (v,&str, name,&local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } -if (*ptr) { -g_free (*ptr); +switch (ret) { +case -EEXIST : +error_set (errp,QERR_PROPERTY_VALUE_IN_USE , +object_get_id (obj), prop->name, value); +break ; +default : +case -EINVAL : +error_set (errp,QERR_PROPERTY_VALUE_BAD , +object_get_id (obj), prop->name, value); +break ; +case -ENOENT : +error_set (errp,QERR_PROPERTY_VALUE_NOT_FOUND , +object_get_id (obj), prop->name, value); +break ; +case 0 : +break ; } - *ptr = str; } - -PropertyInfo qdev_prop_string = { - .name ="string" , - .print = print_string, - .release = release_string, - .get = get_string, - .set = set_string, -}; -/* --- drive --- */ static int parse_drive (Object *obj,const char *str,void **ptr)@@ -636,13 +271,6 @@ PropertyInfo qdev_prop_vlan = { .set = set_vlan, }; -/* --- pointer --- */ - -/* Not a proper property, just for dirty hacks. TODO Remove it! */ -PropertyInfo qdev_prop_ptr = { - .name ="ptr" , -}; -/* --- mac address --- */ /* @@ -713,6 +341,12 @@ PropertyInfo qdev_prop_macaddr = { .set = set_mac, }; +/* --- pointer --- */ + +/* Not a proper property, just for dirty hacks. TODO Remove it! */ +PropertyInfo qdev_prop_ptr = { + .name ="ptr" , +};/* --- lost tick policy --- */ @@ -726,40 +360,24 @@ static const char *lost_tick_policy_table[LOST_TICK_MAX+1] = {QEMU_BUILD_BUG_ON (sizeof (LostTickPolicy) !=sizeof (int )); -static void get_enum (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int *ptr =object_get_prop_ptr (obj, prop); - -visit_type_enum (v, ptr, prop->info->enum_table, - prop->info->name, prop->name, errp); -} - -static void set_enum (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -Property *prop = opaque; -int *ptr =object_get_prop_ptr (obj, prop); - -if (object_is_realized (obj)) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_enum (v, ptr, prop->info->enum_table, - prop->info->name, prop->name, errp); -} -PropertyInfo qdev_prop_losttickpolicy = { .name ="LostTickPolicy" , .enum_table = lost_tick_policy_table, - .get = get_enum, - .set = set_enum, + .get = property_get_enum, + .set = property_set_enum, };/* --- pci address --- */ +static void get_pci_devfn (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +int32_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_int32 (v, ptr, name, errp); +} +/* * bus-local address, i.e. "$slot" or "$slot.$fn" */ @@ -826,12 +444,21 @@ PropertyInfo qdev_prop_pci_devfn = { .name = "int32", .legacy_name = "pci-devfn", .print = print_pci_devfn, - .get = get_int32, + .get = get_pci_devfn, .set = set_pci_devfn, };/* --- blocksize --- */ +static void get_blocksize (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint16_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_uint16 (v, ptr, name, errp); +} +static void set_blocksize (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {@@ -869,7 +496,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_blocksize = { .name ="blocksize" , - .get = get_uint16, + .get = get_blocksize, .set = set_blocksize, };@@ -905,28 +532,6 @@ static Property *qdev_prop_find(Object *obj, const char *name)return NULL ; } -void error_set_from_prop_error (Error **errp,int ret,Object *obj, -Property *prop,const char *value) -{ -switch (ret) { -case -EEXIST : -error_set (errp,QERR_PROPERTY_VALUE_IN_USE , -object_get_id (obj), prop->name, value); -break ; -default : -case -EINVAL : -error_set (errp,QERR_PROPERTY_VALUE_BAD , -object_get_id (obj), prop->name, value); -break ; -case -ENOENT : -error_set (errp,QERR_PROPERTY_VALUE_NOT_FOUND , -object_get_id (obj), prop->name, value); -break ; -case 0 : -break ; - } -} -int qdev_prop_parse (DeviceState *dev,const char *name,const char *value) {char *legacy_name;hw/qdev.c +1
-46@@ -615,51 +615,6 @@ void qdev_property_add_legacy(DeviceState *dev, Property *prop,g_free (name); } -/** -* @qdev_property_add_static - add a @Property to a device. -* -* Static properties access data in a struct. The actual type of the -* property and the field depends on the property type. -*/ -void qdev_property_add_static (DeviceState *dev,Property *prop, -Error **errp) -{ -Error *local_err =NULL ; -Object *obj =OBJECT (dev); - -/* -* TODO qdev_prop_ptr does not have getters or setters. It must -* go now that it can be replaced with links. The test should be -* removed along with it: all static properties are read/write. -*/ -if (!prop->info->get&& !prop->info->set) { -return ; - } - -object_property_add (obj, prop->name, prop->info->name, - prop->info->get, prop->info->set, - prop->info->release, - prop,&local_err); - -if (local_err) { -error_propagate (errp, local_err); -return ; - } -if (prop->qtype ==QTYPE_NONE ) { -return ; - } - -if (prop->qtype ==QTYPE_QBOOL ) { -object_property_set_bool (obj, prop->defval, prop->name,&local_err); - }else if (prop->info->enum_table) { -object_property_set_str (obj, prop->info->enum_table[prop->defval], - prop->name,&local_err); - }else if (prop->qtype ==QTYPE_QINT ) { -object_property_set_int (obj, prop->defval, prop->name,&local_err); - } -assert_no_error (local_err); -} -static void device_initfn (Object *obj) {DeviceState *dev =DEVICE (obj);@@ -677,7 +632,7 @@ static void device_initfn(Object *obj)do {for (prop =DEVICE_CLASS (class)->props; prop&& prop->name; prop++) {qdev_property_add_legacy (dev, prop,NULL ); -qdev_property_add_static (dev, prop,NULL ); +object_property_add_static (OBJECT (dev), prop,NULL ); } class =object_class_get_parent (class); }while (class !=object_class_by_name (TYPE_DEVICE ));hw/qdev.h +0
-87@@ -9,10 +9,6 @@#include "qemu/object.h" #include "error.h" -typedef struct Property Property ; - -typedef struct PropertyInfo PropertyInfo ; -typedef struct CompatProperty CompatProperty ;typedef struct BusState BusState ;@@ -117,26 +113,6 @@ struct BusState {QLIST_ENTRY (BusState) sibling; }; -struct Property { -const char *name; -PropertyInfo *info; -int offset; -uint8_t bitnr; -uint8_t qtype; -int64_t defval; -}; - -struct PropertyInfo { -const char *name; -const char *legacy_name; -const char **enum_table; -int (*parse)(Object *obj,Property *prop,const char *str); -int (*print)(Object *obj,Property *prop,char *dest,size_t len); -ObjectPropertyAccessor *get; -ObjectPropertyAccessor *set; -ObjectPropertyRelease *release; -}; - typedef struct GlobalProperty { const char *driver; const char *property;@@ -212,16 +188,6 @@ int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);/*** qdev-properties.c ***/ -extern PropertyInfo qdev_prop_bit; -extern PropertyInfo qdev_prop_uint8; -extern PropertyInfo qdev_prop_uint16; -extern PropertyInfo qdev_prop_uint32; -extern PropertyInfo qdev_prop_int32; -extern PropertyInfo qdev_prop_uint64; -extern PropertyInfo qdev_prop_hex8; -extern PropertyInfo qdev_prop_hex32; -extern PropertyInfo qdev_prop_hex64; -extern PropertyInfo qdev_prop_string;extern PropertyInfo qdev_prop_chr;extern PropertyInfo qdev_prop_ptr;extern PropertyInfo qdev_prop_macaddr;@@ -232,55 +198,12 @@ extern PropertyInfo qdev_prop_vlan;extern PropertyInfo qdev_prop_pci_devfn;extern PropertyInfo qdev_prop_blocksize; -#define DEFINE_PROP (_name, _state, _field, _prop, _type) { \ - .name = (_name), \ - .info =&(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type,typeof_field(_state, _field)), \ - } -#define DEFINE_PROP_DEFAULT (_name, _state, _field, _defval, _prop, _type) { \ - .name = (_name), \ - .info =&(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type,typeof_field(_state, _field)), \ - .qtype = QTYPE_QINT, \ - .defval = (_type)_defval, \ - } -#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) { \ - .name = (_name), \ - .info =&(qdev_prop_bit), \ - .bitnr = (_bit), \ - .offset = offsetof(_state, _field) \ - + type_check(uint32_t,typeof_field(_state, _field)), \ - .qtype = QTYPE_QBOOL, \ - .defval = (bool)_defval, \ - } - -#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) -#define DEFINE_PROP_UINT16 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) -#define DEFINE_PROP_UINT32 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) -#define DEFINE_PROP_INT32 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t) -#define DEFINE_PROP_UINT64 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) -#define DEFINE_PROP_HEX8 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t) -#define DEFINE_PROP_HEX32 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t) -#define DEFINE_PROP_HEX64 (_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)#define DEFINE_PROP_PCI_DEVFN (_n, _s, _f, _d) \ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) -#define DEFINE_PROP_PTR (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)#define DEFINE_PROP_CHR (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*) -#define DEFINE_PROP_STRING (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)#define DEFINE_PROP_NETDEV (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)#define DEFINE_PROP_VLAN (_n, _s, _f) \@@ -295,11 +218,7 @@ extern PropertyInfo qdev_prop_blocksize;#define DEFINE_PROP_BLOCKSIZE (_n, _s, _f, _d) \ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t) -#define DEFINE_PROP_END_OF_LIST () \ - {} -/* Set properties between creation and init. */ -void *object_get_prop_ptr (Object *obj,Property *prop);int qdev_prop_parse (DeviceState *dev,const char *name,const char *value);void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value);void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);@@ -326,12 +245,6 @@ void error_set_from_prop_error(Error **errp, int ret, Object *obj,char *qdev_get_fw_dev_path (DeviceState *dev);/** -* @qdev_property_add_static - add a @Property to a device referencing a -* field in a struct. -*/ -void qdev_property_add_static (DeviceState *dev,Property *prop,Error **errp); - -/** * @qdev_machine_init * * Initialize platform devices before machine init. This is a hack until full include/qemu/object.h +98
-0@@ -983,5 +983,103 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),*/ Object *container_get (Object *root,const char *path); +typedef struct Property Property ; +typedef struct PropertyInfo PropertyInfo ; + +struct Property { +const char *name; +PropertyInfo *info; +int offset; +uint8_t bitnr; +uint8_t qtype; +int64_t defval; +}; + +struct PropertyInfo { +const char *name; +const char *legacy_name; +const char **enum_table; +int (*parse)(Object *obj,Property *prop,const char *str); +int (*print)(Object *obj,Property *prop,char *dest,size_t len); +ObjectPropertyAccessor *get; +ObjectPropertyAccessor *set; +ObjectPropertyRelease *release; +}; + +extern PropertyInfo qdev_prop_bit; +extern PropertyInfo qdev_prop_uint8; +extern PropertyInfo qdev_prop_uint16; +extern PropertyInfo qdev_prop_uint32; +extern PropertyInfo qdev_prop_int32; +extern PropertyInfo qdev_prop_uint64; +extern PropertyInfo qdev_prop_hex8; +extern PropertyInfo qdev_prop_hex32; +extern PropertyInfo qdev_prop_hex64; +extern PropertyInfo qdev_prop_string; + +#define DEFINE_PROP (_name, _state, _field, _prop, _type) { \ + .name = (_name), \ + .info =&(_prop), \ + .offset = offsetof(_state, _field) \ + + type_check(_type,typeof_field(_state, _field)), \ + } +#define DEFINE_PROP_DEFAULT (_name, _state, _field, _defval, _prop, _type) { \ + .name = (_name), \ + .info =&(_prop), \ + .offset = offsetof(_state, _field) \ + + type_check(_type,typeof_field(_state, _field)), \ + .qtype = QTYPE_QINT, \ + .defval = (_type)_defval, \ + } +#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) { \ + .name = (_name), \ + .info =&(qdev_prop_bit), \ + .bitnr = (_bit), \ + .offset = offsetof(_state, _field) \ + + type_check(uint32_t,typeof_field(_state, _field)), \ + .qtype = QTYPE_QBOOL, \ + .defval = (bool)_defval, \ + } + +#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) +#define DEFINE_PROP_UINT16 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) +#define DEFINE_PROP_UINT32 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) +#define DEFINE_PROP_INT32 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t) +#define DEFINE_PROP_UINT64 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) +#define DEFINE_PROP_HEX8 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t) +#define DEFINE_PROP_HEX32 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t) +#define DEFINE_PROP_HEX64 (_n, _s, _f, _d) \ + DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t) +#define DEFINE_PROP_STRING (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) + +#define DEFINE_PROP_END_OF_LIST () \ + {} + +void property_get_enum (Object *obj,struct Visitor *v,void *opaque, +const char *name,struct Error **errp); +void property_set_enum (Object *obj,struct Visitor *v,void *opaque, +const char *name,struct Error **errp); + +void *object_get_prop_ptr (Object *obj,Property *prop); + +/** +* object_property_add_static: +* @obj: the object to add the property to +* @prop: the property to be added +* @errp: if an error occurs, a pointer to an area to store the error +* +* Add a #Property to an object referencing a field in a struct. +*/ +void object_property_add_static (Object *obj,Property *prop, +struct Error **errp); +#endif qom/Makefile +1
-1@@ -1,2 +1,2 @@ -qom-y = object.o container.o qom-qobject.o +qom-y = object.o object-properties.o container.o qom-qobject.o qom-twice-y = cpu.oqom/object-properties.c new file +461
-0@@ -0,0 +1,461 @@ +#include "qemu/object.h" +#include "qapi/qapi-visit-core.h" + +void *object_get_prop_ptr (Object *obj,Property *prop) +{ +void *ptr = obj; + ptr += prop->offset; +return ptr; +} + +static uint32_t get_prop_mask (Property *prop) +{ +assert (prop->info ==&qdev_prop_bit); +return 0x1 << prop->bitnr; +} + +static void bit_prop_set (Object *obj,Property *props,bool val) +{ +uint32_t *p =object_get_prop_ptr (obj, props); +uint32_t mask =get_prop_mask (props); +if (val) + *p |= mask; +else + *p&= ~mask; +} + +/* Bit */ + +static int print_bit (Object *obj,Property *prop,char *dest,size_t len) +{ +uint32_t *p =object_get_prop_ptr (obj, prop); +return snprintf (dest, len, (*p&get_prop_mask (prop)) ?"on" :"off" ); +} + +static void get_bit (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint32_t *p =object_get_prop_ptr (obj, prop); +bool value = (*p&get_prop_mask (prop)) !=0 ; + +visit_type_bool (v,&value, name, errp); +} + +static void set_bit (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +Error *local_err =NULL ; +bool value; + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_bool (v,&value, name,&local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } +bit_prop_set (obj, prop, value); +} + +PropertyInfo qdev_prop_bit = { + .name ="boolean" , + .legacy_name ="on/off" , + .print = print_bit, + .get = get_bit, + .set = set_bit, +}; + +/* --- 8bit integer --- */ + +static void get_uint8 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint8_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_uint8 (v, ptr, name, errp); +} + +static void set_uint8 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint8_t *ptr =object_get_prop_ptr (obj, prop); + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_uint8 (v, ptr, name, errp); +} + +PropertyInfo qdev_prop_uint8 = { + .name ="uint8" , + .get = get_uint8, + .set = set_uint8, +}; + +/* --- 8bit hex value --- */ + +static int parse_hex8 (Object *obj,Property *prop,const char *str) +{ +uint8_t *ptr =object_get_prop_ptr (obj, prop); +char *end; + +if (str[0 ] !='0' || str[1 ] !='x' ) { +return -EINVAL ; + } + + *ptr =strtoul (str,&end,16 ); +if ((*end !='\0' ) || (end == str)) { +return -EINVAL ; + } + +return 0 ; +} + +static int print_hex8 (Object *obj,Property *prop,char *dest,size_t len) +{ +uint8_t *ptr =object_get_prop_ptr (obj, prop); +return snprintf (dest, len,"0x%" PRIx8, *ptr); +} + +PropertyInfo qdev_prop_hex8 = { + .name ="uint8" , + .legacy_name ="hex8" , + .parse = parse_hex8, + .print = print_hex8, + .get = get_uint8, + .set = set_uint8, +}; + +/* --- 16bit integer --- */ + +static void get_uint16 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint16_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_uint16 (v, ptr, name, errp); +} + +static void set_uint16 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint16_t *ptr =object_get_prop_ptr (obj, prop); + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_uint16 (v, ptr, name, errp); +} + +PropertyInfo qdev_prop_uint16 = { + .name ="uint16" , + .get = get_uint16, + .set = set_uint16, +}; + +/* --- 32bit integer --- */ + +static void get_uint32 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint32_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_uint32 (v, ptr, name, errp); +} + +static void set_uint32 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint32_t *ptr =object_get_prop_ptr (obj, prop); + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_uint32 (v, ptr, name, errp); +} + +static void get_int32 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +int32_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_int32 (v, ptr, name, errp); +} + +static void set_int32 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +int32_t *ptr =object_get_prop_ptr (obj, prop); + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_int32 (v, ptr, name, errp); +} + +PropertyInfo qdev_prop_uint32 = { + .name ="uint32" , + .get = get_uint32, + .set = set_uint32, +}; + +PropertyInfo qdev_prop_int32 = { + .name ="int32" , + .get = get_int32, + .set = set_int32, +}; + +/* --- 32bit hex value --- */ + +static int parse_hex32 (Object *obj,Property *prop,const char *str) +{ +uint32_t *ptr =object_get_prop_ptr (obj, prop); +char *end; + +if (str[0 ] !='0' || str[1 ] !='x' ) { +return -EINVAL ; + } + + *ptr =strtoul (str,&end,16 ); +if ((*end !='\0' ) || (end == str)) { +return -EINVAL ; + } + +return 0 ; +} + +static int print_hex32 (Object *obj,Property *prop,char *dest,size_t len) +{ +uint32_t *ptr =object_get_prop_ptr (obj, prop); +return snprintf (dest, len,"0x%" PRIx32, *ptr); +} + +PropertyInfo qdev_prop_hex32 = { + .name ="uint32" , + .legacy_name ="hex32" , + .parse = parse_hex32, + .print = print_hex32, + .get = get_uint32, + .set = set_uint32, +}; + +/* --- 64bit integer --- */ + +static void get_uint64 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint64_t *ptr =object_get_prop_ptr (obj, prop); + +visit_type_uint64 (v, ptr, name, errp); +} + +static void set_uint64 (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +uint64_t *ptr =object_get_prop_ptr (obj, prop); + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_uint64 (v, ptr, name, errp); +} + +PropertyInfo qdev_prop_uint64 = { + .name ="uint64" , + .get = get_uint64, + .set = set_uint64, +}; + +/* --- 64bit hex value --- */ + +static int parse_hex64 (Object *obj,Property *prop,const char *str) +{ +uint64_t *ptr =object_get_prop_ptr (obj, prop); +char *end; + +if (str[0 ] !='0' || str[1 ] !='x' ) { +return -EINVAL ; + } + + *ptr =strtoull (str,&end,16 ); +if ((*end !='\0' ) || (end == str)) { +return -EINVAL ; + } + +return 0 ; +} + +static int print_hex64 (Object *obj,Property *prop,char *dest,size_t len) +{ +uint64_t *ptr =object_get_prop_ptr (obj, prop); +return snprintf (dest, len,"0x%" PRIx64, *ptr); +} + +PropertyInfo qdev_prop_hex64 = { + .name ="uint64" , + .legacy_name ="hex64" , + .parse = parse_hex64, + .print = print_hex64, + .get = get_uint64, + .set = set_uint64, +}; + +/* --- string --- */ + +static void release_string (Object *obj,const char *name,void *opaque) +{ +Property *prop = opaque; +g_free (*(char **)object_get_prop_ptr (obj, prop)); +} + +static int print_string (Object *obj,Property *prop,char *dest,size_t len) +{ +char **ptr =object_get_prop_ptr (obj, prop); +if (!*ptr) +return snprintf (dest, len,"<null>" ); +return snprintf (dest, len,"\"%s\"" , *ptr); +} + +static void get_string (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +char **ptr =object_get_prop_ptr (obj, prop); + +if (!*ptr) { +char *str = (char *)"" ; +visit_type_str (v,&str, name, errp); + }else { +visit_type_str (v, ptr, name, errp); + } +} + +static void set_string (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +char **ptr =object_get_prop_ptr (obj, prop); +Error *local_err =NULL ; +char *str; + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_str (v,&str, name,&local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } +if (*ptr) { +g_free (*ptr); + } + *ptr = str; +} + +PropertyInfo qdev_prop_string = { + .name ="string" , + .print = print_string, + .release = release_string, + .get = get_string, + .set = set_string, +}; + + +/* --- enums --- */ + +void property_get_enum (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +int *ptr =object_get_prop_ptr (obj, prop); + +visit_type_enum (v, ptr, prop->info->enum_table, + prop->info->name, prop->name, errp); +} + +void property_set_enum (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +Property *prop = opaque; +int *ptr =object_get_prop_ptr (obj, prop); + +if (object_is_realized (obj)) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_enum (v, ptr, prop->info->enum_table, + prop->info->name, prop->name, errp); +} + + +/** +* @object_property_add_static - add a @Property to a device. +* +* Static properties access data in a struct. The actual type of the +* property and the field depends on the property type. +*/ +void object_property_add_static (Object *obj,Property *prop, +Error **errp) +{ +Error *local_err =NULL ; + +/* +* TODO qdev_prop_ptr does not have getters or setters. It must +* go now that it can be replaced with links. The test should be +* removed along with it: all static properties are read/write. +*/ +if (!prop->info->get&& !prop->info->set) { +return ; + } + +object_property_add (obj, prop->name, prop->info->name, + prop->info->get, prop->info->set, + prop->info->release, + prop,&local_err); + +if (local_err) { +error_propagate (errp, local_err); +return ; + } +if (prop->qtype ==QTYPE_NONE ) { +return ; + } + +if (prop->qtype ==QTYPE_QBOOL ) { +object_property_set_bool (obj, prop->defval, prop->name,&local_err); + }else if (prop->info->enum_table) { +object_property_set_str (obj, prop->info->enum_table[prop->defval], + prop->name,&local_err); + }else if (prop->qtype ==QTYPE_QINT ) { +object_property_set_int (obj, prop->defval, prop->name,&local_err); + } +assert_no_error (local_err); +}
Re: [Qemu-devel] [PATCH qom-next 6/7] qom: Add "realized" property
In reply to Andreas FärberQuoted 15 lines · Andreas Färber
From: Paolo Bonzini<[email protected]>
Since we had to move the state field from DeviceState to Object, we cannot delay the implementation of the "realized" property. The property is a trigger for two actions that propagate through the composition tree. "Realize" is called when the property becomes true, and propagates in pre-order; realize can fail if the values of the properties are not valid. "Unrealize" is called when the property becomes false, and propagates in post-order; unrealize cannot fail.
Realize/unrealize is separate from reset. Reset propagation is a thorny issue of its own. We expect classes that care to implement a reset method and call it from realize or
realize_children, depending on whether pre-order or post-order is more appropriate.
Quoted 6 lines
This patch adds four methods (realize,
realize_children, unrealize,unrealize_children) to ObjectClass, together with a default implementation ofrealize_childrenandunrealize_children.Signed-off-by Paolo Bonzini<[email protected]>Signed-off-by Andreas Färber<[email protected]>
Regards,
Anthony Liguori
Quoted 171 lines
--- include/qemu/object.h | 20 +++++++++++ qom/object.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 0 deletions(-)include/qemu/object.h +20
-0@@ -246,6 +246,10 @@ struct ObjectClass/*< public>*/ Property *props;const char *(*get_id)(Object *); +void (*realize)(Object *obj,struct Error **errp); +void (*realize_children)(Object *obj,struct Error **errp); +void (*unrealize)(Object *obj); +void (*unrealize_children)(Object *obj); }; typedef enum ObjectState {@@ -464,6 +468,22 @@ Object *object_new_with_type(Type type);void object_delete (Object *obj);/** +* object_realize_children: +* @obj: The object whose children should be realized. +* +* The default implementation of realize_children. +*/ +void object_realize_children (Object *obj,struct Error **errp); + +/** +* object_unrealize_children: +* @obj: The object whose children should be unrealize. +* +* The default implementation of unrealize_children. +*/ +void object_unrealize_children (Object *obj); + +/** * object_initialize_with_type: * @obj: A pointer to the memory to be used for the object. * @type: The type of the object to instantiate. qom/object.c +89
-0@@ -265,6 +265,87 @@ static void object_interface_init(Object *obj, InterfaceImpl *iface) obj->interfaces =g_slist_prepend (obj->interfaces, iface_obj); } +static void object_get_realized (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +bool value =object_is_realized (obj); + +visit_type_bool (v,&value, name, errp); +} + +static void object_unrealize (Object *obj) +{ +ObjectClass *klass =object_get_class (obj); + +if (klass->unrealize_children) { + klass->unrealize_children (obj); + } +if (obj->state !=OBJECT_STATE_INITIALIZED && klass->unrealize) { + klass->unrealize (obj); + } + obj->state =OBJECT_STATE_INITIALIZED ; +} + +static int object_unrealize_one (Object *obj,void *unused) +{ +object_unrealize (obj); +return 0 ; +} + +void object_unrealize_children (Object *obj) +{ +object_child_foreach (obj, object_unrealize_one,NULL ); +} + +static void object_realize (Object *obj,Error **errp) +{ +ObjectClass *klass =object_get_class (obj); + +if (obj->state !=OBJECT_STATE_REALIZED && klass->realize) { + klass->realize (obj, errp); + } + obj->state =OBJECT_STATE_REALIZED ; +if (klass->realize_children) { + klass->realize_children (obj, errp); + } +} + +static int object_realize_one (Object *obj,void *errp) +{ +Error *err =NULL ; +object_realize (obj,&err); +if (err) { +error_propagate ((Error **)errp, err); +return 1 ; + } + +return 0 ; +} + +void object_realize_children (Object *obj,Error **errp) +{ +object_child_foreach (obj, object_realize_one, errp); +} + +static void object_set_realized (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +bool value; +Error *err =NULL ; + +visit_type_bool (v,&value, name,&err); +if (err) { +error_propagate (errp, err); +return ; + } + +if (value) { +object_realize (obj, errp); + }else { +object_unrealize (obj); + } +} +static void object_init_with_type (Object *obj,TypeImpl *ti) {int i;@@ -373,6 +454,8 @@ void object_unparent(Object *obj)static void object_deinit (Object *obj,TypeImpl *type) { +object_property_set_bool (obj, false,"realized" ,NULL ); +if (type->instance_finalize) { type->instance_finalize (obj); }@@ -1277,6 +1360,9 @@ static void object_instance_init(Object *obj)object_property_add_str (obj,"type" , qdev_get_type,NULL ,NULL ); +object_property_add (obj,"realized" ,"bool" , object_get_realized, + object_set_realized,NULL ,NULL ,NULL ); + class =object_get_class (obj); do { for (prop = OBJECT_CLASS(class)->props; prop&& prop->name; prop++) {@@ -1289,6 +1375,8 @@ static void object_instance_init(Object *obj)static void object_class_init (ObjectClass *klass,void *class_data) { klass->get_id = object_instance_get_id; + klass->realize_children = object_realize_children; + klass->unrealize_children = object_unrealize_children; }static void register_types (void )@@ -1303,6 +1391,7 @@ static void register_types(void) .name = TYPE_OBJECT, .instance_size = sizeof(Object), .class_base_init = object_class_base_init, + .class_init = object_class_init, .instance_init = object_instance_init, .class_init = object_class_init, .abstract = true,
Re: [Qemu-devel] [PATCH qom-next 5/7] qom: Push static properties to Object
In reply to Andreas FärberQuoted 10 lines · Andreas Färber
From: Paolo Bonzini<[email protected]>
This patch is made much larger by the need to touch all assignments of props. The interesting changes are in
hw/qdev-monitor.c,hw/qdev-properties.c,hw/qdev.c,hw/qdev.h,include/qemu/object.h,qom/object.c.Signed-off-by Paolo Bonzini<[email protected]>[AF: Convert arm_gic_properties as well]Signed-off-by Andreas Färber<[email protected]>
Regards,
Anthony Liguori
Quoted 2,595 lines
--- hw/9pfs/virtio-9p-device.c | 2 +- hw/a15mpcore.c | 3 +-- hw/a9mpcore.c | 2 +- hw/ac97.c | 2 +- hw/acpi_piix4.c | 2 +- hw/apic_common.c | 2 +- hw/applesmc.c | 2 +- hw/arm11mpcore.c | 6 ++---- hw/arm_gic.c | 2 +- hw/arm_l2x0.c | 2 +- hw/arm_mptimer.c | 2 +- hw/arm_sysctl.c | 2 +- hw/arm_timer.c | 3 +-- hw/armv7m.c | 3 +-- hw/armv7m_nvic.c | 2 +- hw/cadence_gem.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/cs4231.c | 2 +- hw/cs4231a.c | 2 +- hw/debugcon.c | 3 +-- hw/ds1225y.c | 2 +- hw/e1000.c | 2 +- hw/eccmemctl.c | 2 +- hw/eepro100.c | 2 +- hw/escc.c | 2 +- hw/esp.c | 2 +- hw/etraxfs_eth.c | 3 +-- hw/etraxfs_pic.c | 3 +-- hw/exynos4210_combiner.c | 2 +- hw/exynos4210_gic.c | 3 +-- hw/exynos4210_uart.c | 2 +- hw/fdc.c | 6 +++--- hw/fw_cfg.c | 2 +- hw/g364fb.c | 2 +- hw/grlib_apbuart.c | 3 +-- hw/grlib_gptimer.c | 2 +- hw/grlib_irqmp.c | 2 +- hw/gus.c | 2 +- hw/hda-audio.c | 6 +++--- hw/hpet.c | 2 +- hw/i2c.c | 2 +- hw/i82374.c | 2 +- hw/i82378.c | 2 +- hw/i8254.c | 2 +- hw/i8259_common.c | 2 +- hw/ide/ahci.c | 2 +- hw/ide/cmd646.c | 3 +-- hw/ide/isa.c | 2 +- hw/ide/qdev.c | 8 ++++---- hw/integratorcp.c | 3 +-- hw/intel-hda.c | 4 ++-- hw/ioh3420.c | 2 +- hw/ivshmem.c | 2 +- hw/kvm/i8254.c | 2 +- hw/kvm/ioapic.c | 2 +- hw/lan9118.c | 2 +- hw/lance.c | 2 +- hw/lm32_sys.c | 2 +- hw/lm32_timer.c | 2 +- hw/m48t59.c | 4 ++-- hw/marvell_88w8618_audio.c | 2 +- hw/mc146818rtc.c | 2 +- hw/milkymist-minimac2.c | 2 +- hw/milkymist-softusb.c | 2 +- hw/milkymist-sysctl.c | 2 +- hw/milkymist-vgafb.c | 2 +- hw/mipsnet.c | 2 +- hw/musicpal.c | 2 +- hw/nand.c | 2 +- hw/ne2000-isa.c | 3 +-- hw/ne2000.c | 2 +- hw/omap_gpio.c | 4 ++-- hw/omap_i2c.c | 2 +- hw/omap_intc.c | 4 ++-- hw/onenand.c | 2 +- hw/opencores_eth.c | 2 +- hw/parallel.c | 3 +-- hw/pc_sysfw.c | 2 +- hw/pci.c | 2 +- hw/pci_bridge_dev.c | 2 +- hw/pcnet-pci.c | 2 +- hw/pcspk.c | 2 +- hw/pl041.c | 2 +- hw/pxa2xx.c | 2 +- hw/pxa2xx_dma.c | 2 +- hw/pxa2xx_gpio.c | 2 +- hw/pxa2xx_timer.c | 4 ++-- hw/qdev-monitor.c | 4 ++-- hw/qdev-properties.c | 2 +- hw/qdev.c | 14 +------------- hw/qdev.h | 1 - hw/qxl.c | 4 ++-- hw/rtl8139.c | 2 +- hw/s390-virtio-bus.c | 12 ++++-------- hw/sb16.c | 2 +- hw/scsi-bus.c | 2 +- hw/scsi-disk.c | 8 ++++---- hw/scsi-generic.c | 2 +- hw/serial.c | 2 +- hw/slavio_timer.c | 2 +- hw/smbus_eeprom.c | 3 +-- hw/smc91c111.c | 2 +- hw/spapr_llan.c | 3 +-- hw/spapr_pci.c | 3 +-- hw/spapr_vio.c | 2 +- hw/spapr_vscsi.c | 3 +-- hw/spapr_vty.c | 3 +-- hw/sparc32_dma.c | 2 +- hw/spitz.c | 4 ++-- hw/stellaris_enet.c | 3 +-- hw/strongarm.c | 2 +- hw/sun4m.c | 6 ++---- hw/sun4m_iommu.c | 2 +- hw/sun4u.c | 6 ++---- hw/tcx.c | 2 +- hw/usb/bus.c | 2 +- hw/usb/dev-audio.c | 2 +- hw/usb/dev-network.c | 2 +- hw/usb/dev-serial.c | 4 ++-- hw/usb/dev-smartcard-reader.c | 4 ++-- hw/usb/dev-storage.c | 2 +- hw/usb/hcd-ehci.c | 4 ++-- hw/usb/hcd-ohci.c | 4 ++-- hw/usb/hcd-uhci.c | 12 ++++++------ hw/usb/hcd-xhci.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio-console.c | 6 ++---- hw/virtio-pci.c | 10 +++++----- hw/virtio-serial-bus.c | 2 +- hw/vmmouse.c | 2 +- hw/vt82c686.c | 2 +- hw/xgmac.c | 2 +- hw/xilinx_axidma.c | 3 +-- hw/xilinx_axienet.c | 3 +-- hw/xilinx_ethlite.c | 3 +-- hw/xilinx_intc.c | 3 +-- hw/xilinx_timer.c | 3 +-- hw/xio3130_downstream.c | 2 +- hw/xio3130_upstream.c | 2 +- hw/zaurus.c | 2 +- include/qemu/object.h | 7 ++++--- qom/object.c | 20 ++++++++++++++++++++ 144 files changed, 203 insertions(+), 230 deletions(-)hw/9pfs/virtio-9p-device.c +1
-1@@ -173,7 +173,7 @@ 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; + klass->props = virtio_9p_properties; dc->reset = virtio_pci_reset; }hw/a15mpcore.c +1
-2@@ -85,10 +85,9 @@ static Property a15mp_priv_properties[] = {static void a15mp_priv_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = a15mp_priv_init; - dc->props = a15mp_priv_properties; + klass->props = a15mp_priv_properties;/* We currently have no savable state */ }hw/a9mpcore.c +1
-1@@ -222,7 +222,7 @@ static void a9mp_priv_class_init(ObjectClass *klass, void *data)SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = a9mp_priv_init; - dc->props = a9mp_priv_properties; + klass->props = a9mp_priv_properties; dc->vmsd =&vmstate_a9mp_priv; dc->reset = a9mp_priv_reset; }hw/ac97.c +1
-1@@ -1352,7 +1352,7 @@ static void ac97_class_init (ObjectClass *klass, void *data) k->class_id =PCI_CLASS_MULTIMEDIA_AUDIO ; dc->desc ="Intel 82801AA AC97 Audio" ; dc->vmsd =&vmstate_ac97; - dc->props = ac97_properties; + klass->props = ac97_properties; }static TypeInfo ac97_info = {hw/acpi_piix4.c +1
-1@@ -463,7 +463,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) dc->desc ="PM" ; dc->no_user =1 ; dc->vmsd =&vmstate_acpi; - dc->props = piix4_pm_properties; + klass->props = piix4_pm_properties; }static TypeInfo piix4_pm_info = {hw/apic_common.c +1
-1@@ -370,7 +370,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data) dc->vmsd =&vmstate_apic_common; dc->reset = apic_reset_common; dc->no_user =1 ; - dc->props = apic_properties_common; + klass->props = apic_properties_common; sc->init = apic_init_common; }hw/applesmc.c +1
-1@@ -233,7 +233,7 @@ static void qdev_applesmc_class_init(ObjectClass *klass, void *data)ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = applesmc_isa_init; dc->reset = qdev_applesmc_isa_reset; - dc->props = applesmc_isa_properties; + klass->props = applesmc_isa_properties; }static TypeInfo applesmc_isa_info = {hw/arm11mpcore.c +2
-4@@ -210,11 +210,10 @@ 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; + klass->props = mpcore_rirq_properties; }static TypeInfo mpcore_rirq_info = {@@ -240,11 +239,10 @@ 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; + klass->props = mpcore_priv_properties; }static TypeInfo mpcore_priv_info = {hw/arm_gic.c +1
-1@@ -945,7 +945,7 @@ static void arm_gic_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *sbc =SYS_BUS_DEVICE_CLASS (klass); sbc->init = arm_gic_init; - dc->props = arm_gic_properties; + klass->props = arm_gic_properties; dc->reset = gic_reset; dc->no_user =1 ; }hw/arm_l2x0.c +1
-1@@ -173,7 +173,7 @@ static void l2x0_class_init(ObjectClass *klass, void *data) k->init = l2x0_priv_init; dc->vmsd =&vmstate_l2x0; dc->no_user =1 ; - dc->props = l2x0_properties; + klass->props = l2x0_properties; dc->reset = l2x0_priv_reset; }hw/arm_mptimer.c +1
-1@@ -326,7 +326,7 @@ static void arm_mptimer_class_init(ObjectClass *klass, void *data) dc->vmsd =&vmstate_arm_mptimer; dc->reset = arm_mptimer_reset; dc->no_user =1 ; - dc->props = arm_mptimer_properties; + klass->props = arm_mptimer_properties; }static TypeInfo arm_mptimer_info = {hw/arm_sysctl.c +1
-1@@ -403,7 +403,7 @@ static void arm_sysctl_class_init(ObjectClass *klass, void *data) k->init = arm_sysctl_init; dc->reset = arm_sysctl_reset; dc->vmsd =&vmstate_arm_sysctl; - dc->props = arm_sysctl_properties; + klass->props = arm_sysctl_properties; }static TypeInfo arm_sysctl_info = {hw/arm_timer.c +1
-2@@ -370,10 +370,9 @@ static Property sp804_properties[] = {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; + klass->props = sp804_properties; }static TypeInfo sp804_info = {hw/armv7m.c +1
-2@@ -257,11 +257,10 @@ 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; + klass->props = bitband_properties; }static TypeInfo bitband_info = {hw/armv7m_nvic.c +1
-1@@ -415,7 +415,7 @@ static void armv7m_nvic_class_init(ObjectClass *klass, void *data) sdc->init = armv7m_nvic_init; dc->vmsd =&vmstate_nvic; dc->reset = armv7m_nvic_reset; - dc->props = armv7m_nvic_properties; + klass->props = armv7m_nvic_properties; }static TypeInfo armv7m_nvic_info = {hw/cadence_gem.c +1
-1@@ -1213,7 +1213,7 @@ static void gem_class_init(ObjectClass *klass, void *data)SysBusDeviceClass *sdc =SYS_BUS_DEVICE_CLASS (klass); sdc->init = gem_init; - dc->props = gem_properties; + klass->props = gem_properties; dc->vmsd =&vmstate_cadence_gem; dc->reset = gem_reset; }hw/ccid-card-emulated.c +1
-1@@ -584,7 +584,7 @@ static void emulated_class_initfn(ObjectClass *klass, void *data) cc->get_atr = emulated_get_atr; cc->apdu_from_guest = emulated_apdu_from_guest; dc->desc ="emulated smartcard" ; - dc->props = emulated_card_properties; + klass->props = emulated_card_properties; }static TypeInfo emulated_card_info = {hw/ccid-card-passthru.c +1
-1@@ -333,7 +333,7 @@ static void passthru_class_initfn(ObjectClass *klass, void *data) cc->apdu_from_guest = passthru_apdu_from_guest; dc->desc ="passthrough smartcard" ; dc->vmsd =&passthru_vmstate; - dc->props = passthru_card_properties; + klass->props = passthru_card_properties; }static TypeInfo passthru_card_info = {hw/cs4231.c +1
-1@@ -163,7 +163,7 @@ static void cs4231_class_init(ObjectClass *klass, void *data) k->init = cs4231_init1; dc->reset = cs_reset; dc->vmsd =&vmstate_cs4231; - dc->props = cs4231_properties; + klass->props = cs4231_properties; }static TypeInfo cs4231_info = {hw/cs4231a.c +1
-1@@ -679,7 +679,7 @@ static void cs4231a_class_initfn (ObjectClass *klass, void *data) ic->init = cs4231a_initfn; dc->desc ="Crystal Semiconductor CS4231A" ; dc->vmsd =&vmstate_cs4231a; - dc->props = cs4231a_properties; + klass->props = cs4231a_properties; }static TypeInfo cs4231a_info = {hw/debugcon.c +1
-2@@ -96,10 +96,9 @@ static Property debugcon_isa_properties[] = {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; + klass->props = debugcon_isa_properties; }static TypeInfo debugcon_isa_info = {hw/ds1225y.c +1
-1@@ -147,7 +147,7 @@ static void nvram_sysbus_class_init(ObjectClass *klass, void *data) k->init = nvram_sysbus_initfn; dc->vmsd =&vmstate_nvram; - dc->props = nvram_sysbus_properties; + klass->props = nvram_sysbus_properties; }static TypeInfo nvram_sysbus_info = {hw/e1000.c +1
-1@@ -1284,7 +1284,7 @@ static void e1000_class_init(ObjectClass *klass, void *data) dc->desc ="Intel Gigabit Ethernet" ; dc->reset = qdev_e1000_reset; dc->vmsd =&vmstate_e1000; - dc->props = e1000_properties; + klass->props = e1000_properties; }static TypeInfo e1000_info = {hw/eccmemctl.c +1
-1@@ -321,7 +321,7 @@ static void ecc_class_init(ObjectClass *klass, void *data) k->init = ecc_init1; dc->reset = ecc_reset; dc->vmsd =&vmstate_ecc; - dc->props = ecc_properties; + klass->props = ecc_properties; }static TypeInfo ecc_info = {hw/eepro100.c +1
-1@@ -2075,7 +2075,7 @@ static void eepro100_class_init(ObjectClass *klass, void *data) info =eepro100_get_class_by_name (object_class_get_name (klass)); - dc->props = e100_properties; + klass->props = e100_properties; dc->desc = info->desc; k->vendor_id =PCI_VENDOR_ID_INTEL ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ;hw/escc.c +1
-1@@ -921,7 +921,7 @@ static void escc_class_init(ObjectClass *klass, void *data) k->init = escc_init1; dc->reset = escc_reset; dc->vmsd =&vmstate_escc; - dc->props = escc_properties; + klass->props = escc_properties; }static TypeInfo escc_info = {hw/esp.c +1
-1@@ -766,7 +766,7 @@ static void esp_class_init(ObjectClass *klass, void *data) k->init = esp_init1; dc->reset = esp_hard_reset; dc->vmsd =&vmstate_esp; - dc->props = esp_properties; + klass->props = esp_properties; }static TypeInfo esp_info = {hw/etraxfs_eth.c +1
-2@@ -623,11 +623,10 @@ 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; + klass->props = etraxfs_eth_properties; }static TypeInfo etraxfs_eth_info = {hw/etraxfs_pic.c +1
-2@@ -158,11 +158,10 @@ 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; + klass->props = etraxfs_pic_properties; }static TypeInfo etraxfs_pic_info = {hw/exynos4210_combiner.c +1
-1@@ -440,7 +440,7 @@ static void exynos4210_combiner_class_init(ObjectClass *klass, void *data) k->init = exynos4210_combiner_init; dc->reset = exynos4210_combiner_reset; - dc->props = exynos4210_combiner_properties; + klass->props = exynos4210_combiner_properties; dc->vmsd =&vmstate_exynos4210_combiner; }hw/exynos4210_gic.c +1
-2@@ -341,11 +341,10 @@ static Property exynos4210_gic_properties[] = {static void exynos4210_gic_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = exynos4210_gic_init; - dc->props = exynos4210_gic_properties; + klass->props = exynos4210_gic_properties; }static TypeInfo exynos4210_gic_info = {hw/exynos4210_uart.c +1
-1@@ -657,7 +657,7 @@ static void exynos4210_uart_class_init(ObjectClass *klass, void *data) k->init = exynos4210_uart_init; dc->reset = exynos4210_uart_reset; - dc->props = exynos4210_uart_properties; + klass->props = exynos4210_uart_properties; dc->vmsd =&vmstate_exynos4210_uart; }hw/fdc.c +3
-3@@ -2062,7 +2062,7 @@ static void isabus_fdc_class_init1(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = fdctrl_external_reset_isa; dc->vmsd =&vmstate_isa_fdc; - dc->props = isa_fdc_properties; + klass->props = isa_fdc_properties; }static TypeInfo isa_fdc_info = {@@ -2096,7 +2096,7 @@ static void sysbus_fdc_class_init(ObjectClass *klass, void *data) k->init = sysbus_fdc_init1; dc->reset = fdctrl_external_reset_sysbus; dc->vmsd =&vmstate_sysbus_fdc; - dc->props = sysbus_fdc_properties; + klass->props = sysbus_fdc_properties; }static TypeInfo sysbus_fdc_info = {@@ -2119,7 +2119,7 @@ static void sun4m_fdc_class_init(ObjectClass *klass, void *data) k->init = sun4m_fdc_init1; dc->reset = fdctrl_external_reset_sysbus; dc->vmsd =&vmstate_sysbus_fdc; - dc->props = sun4m_fdc_properties; + klass->props = sun4m_fdc_properties; }static TypeInfo sun4m_fdc_info = {hw/fw_cfg.c +1
-1@@ -546,7 +546,7 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = fw_cfg_reset; dc->vmsd =&vmstate_fw_cfg; - dc->props = fw_cfg_properties; + klass->props = fw_cfg_properties; }static TypeInfo fw_cfg_info = {hw/g364fb.c +1
-1@@ -564,7 +564,7 @@ static void g364fb_sysbus_class_init(ObjectClass *klass, void *data) dc->desc ="G364 framebuffer" ; dc->reset = g364fb_sysbus_reset; dc->vmsd =&vmstate_g364fb; - dc->props = g364fb_sysbus_properties; + klass->props = g364fb_sysbus_properties; }static TypeInfo g364fb_sysbus_info = {hw/grlib_apbuart.c +1
-2@@ -249,11 +249,10 @@ 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; + klass->props = grlib_gptimer_properties; }static TypeInfo grlib_gptimer_info = {hw/grlib_gptimer.c +1
-1@@ -386,7 +386,7 @@ static void grlib_gptimer_class_init(ObjectClass *klass, void *data) k->init = grlib_gptimer_init; dc->reset = grlib_gptimer_reset; - dc->props = grlib_gptimer_properties; + klass->props = grlib_gptimer_properties; }static TypeInfo grlib_gptimer_info = {hw/grlib_irqmp.c +1
-1@@ -367,7 +367,7 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data) k->init = grlib_irqmp_init; dc->reset = grlib_irqmp_reset; - dc->props = grlib_irqmp_properties; + klass->props = grlib_irqmp_properties; }static TypeInfo grlib_irqmp_info = {hw/gus.c +1
-1@@ -314,7 +314,7 @@ static void gus_class_initfn (ObjectClass *klass, void *data) ic->init = gus_initfn; dc->desc ="Gravis Ultrasound GF1" ; dc->vmsd =&vmstate_gus; - dc->props = gus_properties; + klass->props = gus_properties; }static TypeInfo gus_info = {hw/hda-audio.c +3
-3@@ -1036,7 +1036,7 @@ static void hda_audio_output_class_init(ObjectClass *klass, void *data) k->stream = hda_audio_stream; dc->desc ="HDA Audio Codec, output-only (line-out)" ; dc->vmsd =&vmstate_hda_audio; - dc->props = hda_audio_properties; + klass->props = hda_audio_properties; }static TypeInfo hda_audio_output_info = {@@ -1057,7 +1057,7 @@ static void hda_audio_duplex_class_init(ObjectClass *klass, void *data) k->stream = hda_audio_stream; dc->desc ="HDA Audio Codec, duplex (line-out, line-in)" ; dc->vmsd =&vmstate_hda_audio; - dc->props = hda_audio_properties; + klass->props = hda_audio_properties; }static TypeInfo hda_audio_duplex_info = {@@ -1078,7 +1078,7 @@ static void hda_audio_micro_class_init(ObjectClass *klass, void *data) k->stream = hda_audio_stream; dc->desc ="HDA Audio Codec, duplex (speaker, microphone)" ; dc->vmsd =&vmstate_hda_audio; - dc->props = hda_audio_properties; + klass->props = hda_audio_properties; }static TypeInfo hda_audio_micro_info = {hw/hpet.c +1
-1@@ -742,7 +742,7 @@ static void hpet_device_class_init(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = hpet_reset; dc->vmsd =&vmstate_hpet; - dc->props = hpet_device_properties; + klass->props = hpet_device_properties; }static TypeInfo hpet_device_info = {hw/i2c.c +1
-1@@ -225,7 +225,7 @@ static void i2c_slave_class_init(ObjectClass *klass, void *data)DeviceClass *k =DEVICE_CLASS (klass); k->init = i2c_slave_qdev_init; k->bus_type =TYPE_I2C_BUS ; - k->props = i2c_props; + klass->props = i2c_props; }static TypeInfo i2c_slave_type_info = {hw/i82374.c +1
-1@@ -150,7 +150,7 @@ static void i82374_class_init(ObjectClass *klass, void *data) k->init = i82374_isa_init; dc->vmsd =&vmstate_isa_i82374; - dc->props = i82374_properties; + klass->props = i82374_properties; }static TypeInfo i82374_isa_info = {hw/i82378.c +1
-1@@ -260,7 +260,7 @@ static void pci_i82378_class_init(ObjectClass *klass, void *data) k->subsystem_vendor_id =0x0 ; k->subsystem_id =0x0 ; dc->vmsd =&vmstate_pci_i82378; - dc->props = i82378_properties; + klass->props = i82378_properties; }static TypeInfo pci_i82378_info = {hw/i8254.c +1
-1@@ -342,7 +342,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data) k->get_channel_info = pit_get_channel_info_common; k->post_load = pit_post_load; dc->reset = pit_reset; - dc->props = pit_properties; + klass->props = pit_properties; }static TypeInfo pit_info = {hw/i8259_common.c +1
-1@@ -140,7 +140,7 @@ static void pic_common_class_init(ObjectClass *klass, void *data) dc->vmsd =&vmstate_pic_common; dc->no_user =1 ; - dc->props = pic_properties_common; + klass->props = pic_properties_common; ic->init = pic_init_common; }hw/ide/ahci.c +1
-1@@ -1202,7 +1202,7 @@ static void sysbus_ahci_class_init(ObjectClass *klass, void *data) sbc->init = sysbus_ahci_init; dc->vmsd =&vmstate_sysbus_ahci; - dc->props = sysbus_ahci_properties; + klass->props = sysbus_ahci_properties; }static TypeInfo sysbus_ahci_info = {hw/ide/cmd646.c +1
-2@@ -332,7 +332,6 @@ 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;@@ -341,7 +340,7 @@ 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; + klass->props = cmd646_ide_properties; }static TypeInfo cmd646_ide_info = {hw/ide/isa.c +1
-1@@ -108,7 +108,7 @@ static void isa_ide_class_initfn(ObjectClass *klass, void *data) ic->init = isa_ide_initfn; dc->fw_name ="ide" ; dc->reset = isa_ide_reset; - dc->props = isa_ide_properties; + klass->props = isa_ide_properties; }static TypeInfo isa_ide_info = {hw/ide/qdev.c +4
-4@@ -199,7 +199,7 @@ static void ide_hd_class_init(ObjectClass *klass, void *data) k->init = ide_hd_initfn; dc->fw_name ="drive" ; dc->desc ="virtual IDE disk" ; - dc->props = ide_hd_properties; + klass->props = ide_hd_properties; }static TypeInfo ide_hd_info = {@@ -221,7 +221,7 @@ static void ide_cd_class_init(ObjectClass *klass, void *data) k->init = ide_cd_initfn; dc->fw_name ="drive" ; dc->desc ="virtual IDE CD-ROM" ; - dc->props = ide_cd_properties; + klass->props = ide_cd_properties; }static TypeInfo ide_cd_info = {@@ -243,7 +243,7 @@ static void ide_drive_class_init(ObjectClass *klass, void *data) k->init = ide_drive_initfn; dc->fw_name ="drive" ; dc->desc ="virtual IDE disk or CD-ROM (legacy)" ; - dc->props = ide_drive_properties; + klass->props = ide_drive_properties; }static TypeInfo ide_drive_info = {@@ -258,7 +258,7 @@ static void ide_device_class_init(ObjectClass *klass, void *data)DeviceClass *k =DEVICE_CLASS (klass); k->init = ide_qdev_init; k->bus_type =TYPE_IDE_BUS ; - k->props = ide_props; + klass->props = ide_props; }static TypeInfo ide_device_type_info = {hw/integratorcp.c +1
-2@@ -526,11 +526,10 @@ 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; + klass->props = core_properties; }static TypeInfo core_info = {hw/intel-hda.c +2
-2@@ -1265,7 +1265,7 @@ static void intel_hda_class_init(ObjectClass *klass, void *data) dc->desc ="Intel HD Audio Controller" ; dc->reset = intel_hda_reset; dc->vmsd =&vmstate_intel_hda; - dc->props = intel_hda_properties; + klass->props = intel_hda_properties; }static TypeInfo intel_hda_info = {@@ -1281,7 +1281,7 @@ static void hda_codec_device_class_init(ObjectClass *klass, void *data) k->init = hda_codec_dev_init; k->exit = hda_codec_dev_exit; k->bus_type =TYPE_HDA_BUS ; - k->props = hda_props; + klass->props = hda_props; }static TypeInfo hda_codec_device_type_info = {hw/ioh3420.c +1
-1@@ -227,7 +227,7 @@ static void ioh3420_class_init(ObjectClass *klass, void *data) dc->desc ="Intel IOH device id 3420 PCIE Root Port" ; dc->reset = ioh3420_reset; dc->vmsd =&vmstate_ioh3420; - dc->props = ioh3420_properties; + klass->props = ioh3420_properties; }static TypeInfo ioh3420_info = {hw/ivshmem.c +1
-1@@ -806,7 +806,7 @@ static void ivshmem_class_init(ObjectClass *klass, void *data) k->device_id =0x1110 ; k->class_id =PCI_CLASS_MEMORY_RAM ; dc->reset = ivshmem_reset; - dc->props = ivshmem_properties; + klass->props = ivshmem_properties; }static TypeInfo ivshmem_info = {hw/kvm/i8254.c +1
-1@@ -236,7 +236,7 @@ static void kvm_pit_class_init(ObjectClass *klass, void *data) k->pre_save = kvm_pit_get; k->post_load = kvm_pit_put; dc->reset = kvm_pit_reset; - dc->props = kvm_pit_properties; + klass->props = kvm_pit_properties; }static TypeInfo kvm_pit_info = {hw/kvm/ioapic.c +1
-1@@ -107,7 +107,7 @@ static void kvm_ioapic_class_init(ObjectClass *klass, void *data) k->pre_save = kvm_ioapic_get; k->post_load = kvm_ioapic_put; dc->reset = kvm_ioapic_reset; - dc->props = kvm_ioapic_properties; + klass->props = kvm_ioapic_properties; }static TypeInfo kvm_ioapic_info = {hw/lan9118.c +1
-1@@ -1362,7 +1362,7 @@ static void lan9118_class_init(ObjectClass *klass, void *data) k->init = lan9118_init1; dc->reset = lan9118_reset; - dc->props = lan9118_properties; + klass->props = lan9118_properties; dc->vmsd =&vmstate_lan9118; }hw/lance.c +1
-1@@ -152,7 +152,7 @@ static void lance_class_init(ObjectClass *klass, void *data) dc->fw_name ="ethernet" ; dc->reset = lance_reset; dc->vmsd =&vmstate_lance; - dc->props = lance_properties; + klass->props = lance_properties; }static TypeInfo lance_info = {hw/lm32_sys.c +1
-1@@ -154,7 +154,7 @@ static void lm32_sys_class_init(ObjectClass *klass, void *data) k->init = lm32_sys_init; dc->reset = sys_reset; dc->vmsd =&vmstate_lm32_sys; - dc->props = lm32_sys_properties; + klass->props = lm32_sys_properties; }static TypeInfo lm32_sys_info = {hw/lm32_timer.c +1
-1@@ -212,7 +212,7 @@ static void lm32_timer_class_init(ObjectClass *klass, void *data) k->init = lm32_timer_init; dc->reset = timer_reset; dc->vmsd =&vmstate_lm32_timer; - dc->props = lm32_timer_properties; + klass->props = lm32_timer_properties; }static TypeInfo lm32_timer_info = {hw/m48t59.c +2
-2@@ -738,7 +738,7 @@ static void m48t59_init_class_isa1(ObjectClass *klass, void *data) ic->init = m48t59_init_isa1; dc->no_user =1 ; dc->reset = m48t59_reset_isa; - dc->props = m48t59_isa_properties; + klass->props = m48t59_isa_properties; }static TypeInfo m48t59_isa_info = {@@ -762,7 +762,7 @@ static void m48t59_class_init(ObjectClass *klass, void *data) k->init = m48t59_init1; dc->reset = m48t59_reset_sysbus; - dc->props = m48t59_properties; + klass->props = m48t59_properties; }static TypeInfo m48t59_info = {hw/marvell_88w8618_audio.c +1
-1@@ -285,7 +285,7 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data) k->init = mv88w8618_audio_init; dc->reset = mv88w8618_audio_reset; dc->vmsd =&mv88w8618_audio_vmsd; - dc->props = mv88w8618_audio_properties; + klass->props = mv88w8618_audio_properties; }static TypeInfo mv88w8618_audio_info = {hw/mc146818rtc.c +1
-1@@ -697,7 +697,7 @@ static void rtc_class_initfn(ObjectClass *klass, void *data) ic->init = rtc_initfn; dc->no_user =1 ; dc->vmsd =&vmstate_rtc; - dc->props = mc146818rtc_properties; + klass->props = mc146818rtc_properties; }static TypeInfo mc146818rtc_info = {hw/milkymist-minimac2.c +1
-1@@ -532,7 +532,7 @@ static void milkymist_minimac2_class_init(ObjectClass *klass, void *data) k->init = milkymist_minimac2_init; dc->reset = milkymist_minimac2_reset; dc->vmsd =&vmstate_milkymist_minimac2; - dc->props = milkymist_minimac2_properties; + klass->props = milkymist_minimac2_properties; }static TypeInfo milkymist_minimac2_info = {hw/milkymist-softusb.c +1
-1@@ -313,7 +313,7 @@ static void milkymist_softusb_class_init(ObjectClass *klass, void *data) k->init = milkymist_softusb_init; dc->reset = milkymist_softusb_reset; dc->vmsd =&vmstate_milkymist_softusb; - dc->props = milkymist_softusb_properties; + klass->props = milkymist_softusb_properties; }static TypeInfo milkymist_softusb_info = {hw/milkymist-sysctl.c +1
-1@@ -320,7 +320,7 @@ static void milkymist_sysctl_class_init(ObjectClass *klass, void *data) k->init = milkymist_sysctl_init; dc->reset = milkymist_sysctl_reset; dc->vmsd =&vmstate_milkymist_sysctl; - dc->props = milkymist_sysctl_properties; + klass->props = milkymist_sysctl_properties; }static TypeInfo milkymist_sysctl_info = {hw/milkymist-vgafb.c +1
-1@@ -316,7 +316,7 @@ static void milkymist_vgafb_class_init(ObjectClass *klass, void *data) k->init = milkymist_vgafb_init; dc->reset = milkymist_vgafb_reset; dc->vmsd =&vmstate_milkymist_vgafb; - dc->props = milkymist_vgafb_properties; + klass->props = milkymist_vgafb_properties; }static TypeInfo milkymist_vgafb_info = {hw/mipsnet.c +1
-1@@ -266,7 +266,7 @@ static void mipsnet_class_init(ObjectClass *klass, void *data) dc->desc ="MIPS Simulator network device" ; dc->reset = mipsnet_sysbus_reset; dc->vmsd =&vmstate_mipsnet; - dc->props = mipsnet_properties; + klass->props = mipsnet_properties; }static TypeInfo mipsnet_info = {hw/musicpal.c +1
-1@@ -424,7 +424,7 @@ static void mv88w8618_eth_class_init(ObjectClass *klass, void *data) k->init = mv88w8618_eth_init; dc->vmsd =&mv88w8618_eth_vmsd; - dc->props = mv88w8618_eth_properties; + klass->props = mv88w8618_eth_properties; }static TypeInfo mv88w8618_eth_info = {hw/nand.c +1
-1@@ -432,7 +432,7 @@ static void nand_class_init(ObjectClass *klass, void *data) k->init = nand_device_init; dc->reset = nand_reset; dc->vmsd =&vmstate_nand; - dc->props = nand_properties; + klass->props = nand_properties; }static TypeInfo nand_info = {hw/ne2000-isa.c +1
-2@@ -91,10 +91,9 @@ static Property ne2000_isa_properties[] = {static void isa_ne2000_class_initfn (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = isa_ne2000_initfn; - dc->props = ne2000_isa_properties; + klass->props = ne2000_isa_properties; }static TypeInfo ne2000_isa_info = {hw/ne2000.c +1
-1@@ -771,7 +771,7 @@ static void ne2000_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_REALTEK_8029 ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->vmsd =&vmstate_pci_ne2000; - dc->props = ne2000_properties; + klass->props = ne2000_properties; }static TypeInfo ne2000_info = {hw/omap_gpio.c +2
-2@@ -744,7 +744,7 @@ static void omap_gpio_class_init(ObjectClass *klass, void *data) k->init = omap_gpio_init; dc->reset = omap_gpif_reset; - dc->props = omap_gpio_properties; + klass->props = omap_gpio_properties; }static TypeInfo omap_gpio_info = {@@ -773,7 +773,7 @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data) k->init = omap2_gpio_init; dc->reset = omap2_gpif_reset; - dc->props = omap2_gpio_properties; + klass->props = omap2_gpio_properties; }static TypeInfo omap2_gpio_info = {hw/omap_i2c.c +1
-1@@ -467,7 +467,7 @@ static void omap_i2c_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = omap_i2c_init; - dc->props = omap_i2c_properties; + klass->props = omap_i2c_properties; dc->reset = omap_i2c_reset; }hw/omap_intc.c +2
-2@@ -386,7 +386,7 @@ static void omap_intc_class_init(ObjectClass *klass, void *data) k->init = omap_intc_init; dc->reset = omap_inth_reset; - dc->props = omap_intc_properties; + klass->props = omap_intc_properties; }static TypeInfo omap_intc_info = {@@ -630,7 +630,7 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data) k->init = omap2_intc_init; dc->reset = omap_inth_reset; - dc->props = omap2_intc_properties; + klass->props = omap2_intc_properties; }static TypeInfo omap2_intc_info = {hw/onenand.c +1
-1@@ -818,7 +818,7 @@ static void onenand_class_init(ObjectClass *klass, void *data) k->init = onenand_initfn; dc->reset = onenand_system_reset; - dc->props = onenand_properties; + klass->props = onenand_properties; }static TypeInfo onenand_info = {hw/opencores_eth.c +1
-1@@ -715,7 +715,7 @@ static void open_eth_class_init(ObjectClass *klass, void *data) k->init = sysbus_open_eth_init; dc->desc ="Opencores 10/100 Mbit Ethernet" ; dc->reset = qdev_open_eth_reset; - dc->props = open_eth_properties; + klass->props = open_eth_properties; }static TypeInfo open_eth_info = {hw/parallel.c +1
-2@@ -593,10 +593,9 @@ static Property parallel_isa_properties[] = {static void parallel_isa_class_initfn (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = parallel_isa_initfn; - dc->props = parallel_isa_properties; + klass->props = parallel_isa_properties; }static TypeInfo parallel_isa_info = {hw/pc_sysfw.c +1
-1@@ -246,7 +246,7 @@ static void pcsysfw_class_init (ObjectClass *klass, void *data) dc->desc ="PC System Firmware" ; dc->init = pcsysfw_init; - dc->props = pcsysfw_properties; + klass->props = pcsysfw_properties; }static TypeInfo pcsysfw_info = {hw/pci.c +1
-1@@ -2010,7 +2010,7 @@ static void pci_device_class_init(ObjectClass *klass, void *data) k->unplug = pci_unplug_device; k->exit = pci_unregister_device; k->bus_type =TYPE_PCI_BUS ; - k->props = pci_props; + klass->props = pci_props; }static TypeInfo pci_device_type_info = {hw/pci_bridge_dev.c +1
-1@@ -155,8 +155,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) k->is_bridge =1 , dc->desc ="Standard PCI Bridge" ; dc->reset = qdev_pci_bridge_dev_reset; - dc->props = pci_bridge_dev_properties; dc->vmsd =&pci_bridge_dev_vmstate; + klass->props = pci_bridge_dev_properties; }static TypeInfo pci_bridge_dev_info = {hw/pcnet-pci.c +1
-1@@ -359,7 +359,7 @@ static void pcnet_class_init(ObjectClass *klass, void *data) k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->reset = pci_reset; dc->vmsd =&vmstate_pci_pcnet; - dc->props = pcnet_properties; + klass->props = pcnet_properties; }static TypeInfo pcnet_info = {hw/pcspk.c +1
-1@@ -184,7 +184,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data) ic->init = pcspk_initfn; dc->no_user =1 ; - dc->props = pcspk_properties; + klass->props = pcspk_properties; }static TypeInfo pcspk_info = {hw/pl041.c +1
-1@@ -628,7 +628,7 @@ static void pl041_device_class_init(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = pl041_device_reset; dc->vmsd =&vmstate_pl041; - dc->props = pl041_device_properties; + klass->props = pl041_device_properties; }static TypeInfo pl041_device_info = {hw/pxa2xx.c +1
-1@@ -1556,7 +1556,7 @@ static void pxa2xx_i2c_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_i2c_initfn; dc->desc ="PXA2xx I2C Bus Controller" ; dc->vmsd =&vmstate_pxa2xx_i2c; - dc->props = pxa2xx_i2c_properties; + klass->props = pxa2xx_i2c_properties; }static TypeInfo pxa2xx_i2c_info = {hw/pxa2xx_dma.c +1
-1@@ -556,7 +556,7 @@ static void pxa2xx_dma_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_dma_init; dc->desc ="PXA2xx DMA controller" ; dc->vmsd =&vmstate_pxa2xx_dma; - dc->props = pxa2xx_dma_properties; + klass->props = pxa2xx_dma_properties; }static TypeInfo pxa2xx_dma_info = {hw/pxa2xx_gpio.c +1
-1@@ -331,7 +331,7 @@ static void pxa2xx_gpio_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_gpio_initfn; dc->desc ="PXA2xx GPIO controller" ; - dc->props = pxa2xx_gpio_properties; + klass->props = pxa2xx_gpio_properties; }static TypeInfo pxa2xx_gpio_info = {hw/pxa2xx_timer.c +2
-2@@ -492,7 +492,7 @@ static void pxa25x_timer_dev_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_timer_init; dc->desc ="PXA25x timer" ; dc->vmsd =&vmstate_pxa2xx_timer_regs; - dc->props = pxa25x_timer_dev_properties; + klass->props = pxa25x_timer_dev_properties; }static TypeInfo pxa25x_timer_dev_info = {@@ -517,7 +517,7 @@ static void pxa27x_timer_dev_class_init(ObjectClass *klass, void *data) k->init = pxa2xx_timer_init; dc->desc ="PXA27x timer" ; dc->vmsd =&vmstate_pxa2xx_timer_regs; - dc->props = pxa27x_timer_dev_properties; + klass->props = pxa27x_timer_dev_properties; }static TypeInfo pxa27x_timer_dev_info = {hw/qdev-monitor.c +2
-2@@ -149,7 +149,7 @@ int qdev_device_help(QemuOpts *opts)return 0 ; } do { - for (prop = DEVICE_CLASS(klass)->props; prop&& prop->name; prop++) { + for (prop = OBJECT_CLASS(klass)->props; prop&& prop->name; prop++) { /* * TODO Properties without a parser are just for dirty hacks. * qdev_prop_ptr is the only such PropertyInfo. It's marked@@ -527,7 +527,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent) } class =object_get_class (OBJECT (dev));do { -qdev_print_props (mon, dev,DEVICE_CLASS (class)->props, indent); +qdev_print_props (mon, dev,OBJECT_CLASS (class)->props, indent); class =object_class_get_parent (class); }while (class !=object_class_by_name (TYPE_DEVICE ));bus_print_dev (dev->parent_bus, mon, dev, indent +2 );hw/qdev-properties.c +1
-1@@ -522,7 +522,7 @@ static Property *qdev_prop_find(Object *obj, const char *name)/* device properties */ class =object_get_class (obj); do { - prop = qdev_prop_walk(DEVICE_CLASS(class)->props, name); + prop = qdev_prop_walk(OBJECT_CLASS(class)->props, name); if (prop) { return prop; }hw/qdev.c +1
-13@@ -630,9 +630,8 @@ static void device_initfn(Object *obj) class =object_get_class (OBJECT (dev));do { -for (prop =DEVICE_CLASS (class)->props; prop&& prop->name; prop++) { +for (prop =OBJECT_CLASS (class)->props; prop&& prop->name; prop++) {qdev_property_add_legacy (dev, prop,NULL ); -object_property_add_static (OBJECT (dev), prop,NULL ); } class =object_class_get_parent (class); }while (class !=object_class_by_name (TYPE_DEVICE ));@@ -676,16 +675,6 @@ static const char *qdev_get_id(Object *obj)return dev->id !=NULL ? dev->id :object_get_typename (obj); } -static void device_class_base_init (ObjectClass *class,void *data) -{ -DeviceClass *klass =DEVICE_CLASS (class); - -/* We explicitly look up properties in the superclasses, -* so do not propagate them to the subclasses. -*/ - klass->props =NULL ; -} -void device_reset (DeviceState *dev) {DeviceClass *klass =DEVICE_GET_CLASS (dev);@@ -717,7 +706,6 @@ static TypeInfo device_type_info = { .instance_size = sizeof(DeviceState), .instance_init = device_initfn, .instance_finalize = device_finalize, - .class_base_init = device_class_base_init, .class_init = device_class_init, .abstract = true, .class_size = sizeof(DeviceClass),hw/qdev.h +0
-1@@ -33,7 +33,6 @@ typedef struct DeviceClass {const char *fw_name;const char *desc; -Property *props;int no_user;/* callbacks */ hw/qxl.c +2
-2@@ -2051,7 +2051,7 @@ static void qxl_primary_class_init(ObjectClass *klass, void *data) dc->desc ="Spice QXL GPU (primary, vga compatible)" ; dc->reset = qxl_reset_handler; dc->vmsd =&qxl_vmstate; - dc->props = qxl_properties; + klass->props = qxl_properties; }static TypeInfo qxl_primary_info = {@@ -2073,7 +2073,7 @@ static void qxl_secondary_class_init(ObjectClass *klass, void *data) dc->desc ="Spice QXL GPU (secondary)" ; dc->reset = qxl_reset_handler; dc->vmsd =&qxl_vmstate; - dc->props = qxl_properties; + klass->props = qxl_properties; }static TypeInfo qxl_secondary_info = {hw/rtl8139.c +1
-1@@ -3525,7 +3525,7 @@ static void rtl8139_class_init(ObjectClass *klass, void *data) k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->reset = rtl8139_reset; dc->vmsd =&vmstate_rtl8139; - dc->props = rtl8139_properties; + klass->props = rtl8139_properties; }static TypeInfo rtl8139_info = {hw/s390-virtio-bus.c +4
-8@@ -384,11 +384,10 @@ static Property s390_virtio_net_properties[] = {static void s390_virtio_net_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_net_init; - dc->props = s390_virtio_net_properties; + klass->props = s390_virtio_net_properties; }static TypeInfo s390_virtio_net = {@@ -409,11 +408,10 @@ static Property s390_virtio_blk_properties[] = {static void s390_virtio_blk_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_blk_init; - dc->props = s390_virtio_blk_properties; + klass->props = s390_virtio_blk_properties; }static TypeInfo s390_virtio_blk = {@@ -431,11 +429,10 @@ static Property s390_virtio_serial_properties[] = {static void s390_virtio_serial_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_serial_init; - dc->props = s390_virtio_serial_properties; + klass->props = s390_virtio_serial_properties; }static TypeInfo s390_virtio_serial = {@@ -478,11 +475,10 @@ static Property s390_virtio_scsi_properties[] = {static void s390_virtio_scsi_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); k->init = s390_virtio_scsi_init; - dc->props = s390_virtio_scsi_properties; + klass->props = s390_virtio_scsi_properties; }static TypeInfo s390_virtio_scsi = {hw/sb16.c +1
-1@@ -1407,7 +1407,7 @@ static void sb16_class_initfn (ObjectClass *klass, void *data) ic->init = sb16_initfn; dc->desc ="Creative Sound Blaster 16" ; dc->vmsd =&vmstate_sb16; - dc->props = sb16_properties; + klass->props = sb16_properties; }static TypeInfo sb16_info = {hw/scsi-bus.c +1
-1@@ -1609,7 +1609,7 @@ static void scsi_device_class_init(ObjectClass *klass, void *data) k->init = scsi_qdev_init; k->unplug = qdev_simple_unplug_cb; k->exit = scsi_qdev_exit; - k->props = scsi_props; + klass->props = scsi_props; }static TypeInfo scsi_device_type_info = {hw/scsi-disk.c +4
-4@@ -1945,7 +1945,7 @@ static void scsi_hd_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="virtual SCSI disk" ; dc->reset = scsi_disk_reset; - dc->props = scsi_hd_properties; + klass->props = scsi_hd_properties; dc->vmsd =&vmstate_scsi_disk_state; }@@ -1973,7 +1973,7 @@ static void scsi_cd_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="virtual SCSI CD-ROM" ; dc->reset = scsi_disk_reset; - dc->props = scsi_cd_properties; + klass->props = scsi_cd_properties; dc->vmsd =&vmstate_scsi_disk_state; }@@ -2001,7 +2001,7 @@ static void scsi_block_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="SCSI block device passthrough" ; dc->reset = scsi_disk_reset; - dc->props = scsi_block_properties; + klass->props = scsi_block_properties; dc->vmsd =&vmstate_scsi_disk_state; }@@ -2034,7 +2034,7 @@ static void scsi_disk_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="virtual SCSI disk or CD-ROM (legacy)" ; dc->reset = scsi_disk_reset; - dc->props = scsi_disk_properties; + klass->props = scsi_disk_properties; dc->vmsd =&vmstate_scsi_disk_state; }hw/scsi-generic.c +1
-1@@ -497,7 +497,7 @@ static void scsi_generic_class_initfn(ObjectClass *klass, void *data) dc->fw_name ="disk" ; dc->desc ="pass through generic scsi device (/dev/sg*)" ; dc->reset = scsi_generic_reset; - dc->props = scsi_generic_properties; + klass->props = scsi_generic_properties; dc->vmsd =&vmstate_scsi_device; }hw/serial.c +1
-1@@ -902,7 +902,7 @@ static void serial_isa_class_initfn(ObjectClass *klass, void *data)ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); ic->init = serial_isa_initfn; dc->vmsd =&vmstate_isa_serial; - dc->props = serial_isa_properties; + klass->props = serial_isa_properties; }static TypeInfo serial_isa_info = {hw/slavio_timer.c +1
-1@@ -417,7 +417,7 @@ static void slavio_timer_class_init(ObjectClass *klass, void *data) k->init = slavio_timer_init1; dc->reset = slavio_timer_reset; dc->vmsd =&vmstate_slavio_timer; - dc->props = slavio_timer_properties; + klass->props = slavio_timer_properties; }static TypeInfo slavio_timer_info = {hw/smbus_eeprom.c +1
-2@@ -111,7 +111,6 @@ static Property smbus_eeprom_properties[] = {static void smbus_eeprom_class_initfn (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SMBusDeviceClass *sc =SMBUS_DEVICE_CLASS (klass); sc->init = smbus_eeprom_initfn;@@ -120,7 +119,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data) sc->receive_byte = eeprom_receive_byte; sc->write_data = eeprom_write_data; sc->read_data = eeprom_read_data; - dc->props = smbus_eeprom_properties; + klass->props = smbus_eeprom_properties; }static TypeInfo smbus_eeprom_info = {hw/smc91c111.c +1
-1@@ -771,7 +771,7 @@ static void smc91c111_class_init(ObjectClass *klass, void *data) k->init = smc91c111_init1; dc->reset = smc91c111_reset; dc->vmsd =&vmstate_smc91c111; - dc->props = smc91c111_properties; + klass->props = smc91c111_properties; }static TypeInfo smc91c111_info = {hw/spapr_llan.c +1
-2@@ -486,7 +486,6 @@ static Property spapr_vlan_properties[] = {static void spapr_vlan_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VIOsPAPRDeviceClass *k =VIO_SPAPR_DEVICE_CLASS (klass); k->init = spapr_vlan_init;@@ -496,7 +495,7 @@ static void spapr_vlan_class_init(ObjectClass *klass, void *data) k->dt_type ="network" ; k->dt_compatible ="IBM,l-lan" ; k->signal_mask =0x1 ; - dc->props = spapr_vlan_properties; + klass->props = spapr_vlan_properties; }static TypeInfo spapr_vlan_info = {hw/spapr_pci.c +1
-2@@ -344,10 +344,9 @@ static Property spapr_phb_properties[] = {static void spapr_phb_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *sdc =SYS_BUS_DEVICE_CLASS (klass); -DeviceClass *dc =DEVICE_CLASS (klass); sdc->init = spapr_phb_init; - dc->props = spapr_phb_properties; + klass->props = spapr_phb_properties;spapr_rtas_register ("read-pci-config" , rtas_read_pci_config);spapr_rtas_register ("write-pci-config" , rtas_write_pci_config);hw/spapr_vio.c +1
-1@@ -797,7 +797,7 @@ static void vio_spapr_device_class_init(ObjectClass *klass, void *data) k->init = spapr_vio_busdev_init; k->reset = spapr_vio_busdev_reset; k->bus_type =TYPE_SPAPR_VIO_BUS ; - k->props = spapr_vio_props; + klass->props = spapr_vio_props; }static TypeInfo spapr_vio_type_info = {hw/spapr_vscsi.c +1
-2@@ -951,7 +951,6 @@ static Property spapr_vscsi_properties[] = {static void spapr_vscsi_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VIOsPAPRDeviceClass *k =VIO_SPAPR_DEVICE_CLASS (klass); k->init = spapr_vscsi_init;@@ -961,7 +960,7 @@ static void spapr_vscsi_class_init(ObjectClass *klass, void *data) k->dt_type ="vscsi" ; k->dt_compatible ="IBM,v-scsi" ; k->signal_mask =0x00000001 ; - dc->props = spapr_vscsi_properties; + klass->props = spapr_vscsi_properties; }static TypeInfo spapr_vscsi_info = {hw/spapr_vty.c +1
-2@@ -140,14 +140,13 @@ static Property spapr_vty_properties[] = {static void spapr_vty_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VIOsPAPRDeviceClass *k =VIO_SPAPR_DEVICE_CLASS (klass); k->init = spapr_vty_init; k->dt_name ="vty" ; k->dt_type ="serial" ; k->dt_compatible ="hvterm1" ; - dc->props = spapr_vty_properties; + klass->props = spapr_vty_properties; }static TypeInfo spapr_vty_info = {hw/sparc32_dma.c +1
-1@@ -297,7 +297,7 @@ static void sparc32_dma_class_init(ObjectClass *klass, void *data) k->init = sparc32_dma_init1; dc->reset = dma_reset; dc->vmsd =&vmstate_dma; - dc->props = sparc32_dma_properties; + klass->props = sparc32_dma_properties; }static TypeInfo sparc32_dma_info = {hw/spitz.c +2
-2@@ -1036,7 +1036,7 @@ static void sl_nand_class_init(ObjectClass *klass, void *data) k->init = sl_nand_init; dc->vmsd =&vmstate_sl_nand_info; - dc->props = sl_nand_properties; + klass->props = sl_nand_properties; }static TypeInfo sl_nand_info = {@@ -1071,7 +1071,7 @@ static void spitz_keyboard_class_init(ObjectClass *klass, void *data) k->init = spitz_keyboard_init; dc->vmsd =&vmstate_spitz_kbd; - dc->props = spitz_keyboard_properties; + klass->props = spitz_keyboard_properties; }static TypeInfo spitz_keyboard_info = {hw/stellaris_enet.c +1
-2@@ -427,11 +427,10 @@ static Property stellaris_enet_properties[] = {static void stellaris_enet_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = stellaris_enet_init; - dc->props = stellaris_enet_properties; + klass->props = stellaris_enet_properties; }static TypeInfo stellaris_enet_info = {hw/strongarm.c +1
-1@@ -1295,7 +1295,7 @@ static void strongarm_uart_class_init(ObjectClass *klass, void *data) dc->desc ="StrongARM UART controller" ; dc->reset = strongarm_uart_reset; dc->vmsd =&vmstate_strongarm_uart_regs; - dc->props = strongarm_uart_properties; + klass->props = strongarm_uart_properties; }static TypeInfo strongarm_uart_info = {hw/sun4m.c +2
-4@@ -730,11 +730,10 @@ static Property prom_properties[] = {static void prom_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = prom_init1; - dc->props = prom_properties; + klass->props = prom_properties; }static TypeInfo prom_info = {@@ -794,11 +793,10 @@ static Property ram_properties[] = {static void ram_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = ram_init1; - dc->props = ram_properties; + klass->props = ram_properties; }static TypeInfo ram_info = {hw/sun4m_iommu.c +1
-1@@ -370,7 +370,7 @@ static void iommu_class_init(ObjectClass *klass, void *data) k->init = iommu_init1; dc->reset = iommu_reset; dc->vmsd =&vmstate_iommu; - dc->props = iommu_properties; + klass->props = iommu_properties; }static TypeInfo iommu_info = {hw/sun4u.c +2
-4@@ -681,11 +681,10 @@ static Property prom_properties[] = {static void prom_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = prom_init1; - dc->props = prom_properties; + klass->props = prom_properties; }static TypeInfo prom_info = {@@ -738,11 +737,10 @@ static Property ram_properties[] = {static void ram_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = ram_init1; - dc->props = ram_properties; + klass->props = ram_properties; }static TypeInfo ram_info = {hw/tcx.c +1
-1@@ -654,7 +654,7 @@ static void tcx_class_init(ObjectClass *klass, void *data) k->init = tcx_init1; dc->reset = tcx_reset; dc->vmsd =&vmstate_tcx; - dc->props = tcx_properties; + klass->props = tcx_properties; }static TypeInfo tcx_info = {hw/usb/bus.c +1
-1@@ -589,7 +589,7 @@ static void usb_device_class_init(ObjectClass *klass, void *data) k->init = usb_qdev_init; k->unplug = qdev_simple_unplug_cb; k->exit = usb_qdev_exit; - k->props = usb_props; + klass->props = usb_props; }static TypeInfo usb_device_type_info = {hw/usb/dev-audio.c +1
-1@@ -688,7 +688,7 @@ static void usb_audio_class_init(ObjectClass *klass, void *data)USBDeviceClass *k =USB_DEVICE_CLASS (klass); dc->vmsd =&vmstate_usb_audio; - dc->props = usb_audio_properties; + klass->props = usb_audio_properties; k->product_desc ="QEMU USB Audio Interface" ; k->usb_desc =&desc_audio; k->init = usb_audio_initfn;hw/usb/dev-network.c +1
-1@@ -1408,7 +1408,7 @@ static void usb_net_class_initfn(ObjectClass *klass, void *data) uc->handle_destroy = usb_net_handle_destroy; dc->fw_name ="network" ; dc->vmsd =&vmstate_usb_net; - dc->props = net_properties; + klass->props = net_properties; }static TypeInfo net_info = {hw/usb/dev-serial.c +2
-2@@ -589,7 +589,7 @@ static void usb_serial_class_initfn(ObjectClass *klass, void *data) uc->handle_data = usb_serial_handle_data; uc->handle_destroy = usb_serial_handle_destroy; dc->vmsd =&vmstate_usb_serial; - dc->props = serial_properties; + klass->props = serial_properties; }static TypeInfo serial_info = {@@ -617,7 +617,7 @@ static void usb_braille_class_initfn(ObjectClass *klass, void *data) uc->handle_data = usb_serial_handle_data; uc->handle_destroy = usb_serial_handle_destroy; dc->vmsd =&vmstate_usb_serial; - dc->props = braille_properties; + klass->props = braille_properties; }static TypeInfo braille_info = {hw/usb/dev-smartcard-reader.c +2
-2@@ -1334,7 +1334,7 @@ static void ccid_class_initfn(ObjectClass *klass, void *data) uc->handle_destroy = ccid_handle_destroy; dc->desc ="CCID Rev 1.1 smartcard reader" ; dc->vmsd =&ccid_vmstate; - dc->props = ccid_properties; + klass->props = ccid_properties; }static TypeInfo ccid_info = {@@ -1350,7 +1350,7 @@ static void ccid_card_class_init(ObjectClass *klass, void *data) k->bus_type =TYPE_CCID_BUS ; k->init = ccid_card_init; k->exit = ccid_card_exit; - k->props = ccid_props; + klass->props = ccid_props; }static TypeInfo ccid_card_type_info = {hw/usb/dev-storage.c +1
-1@@ -662,7 +662,7 @@ static void usb_msd_class_initfn(ObjectClass *klass, void *data) uc->handle_data = usb_msd_handle_data; dc->fw_name ="storage" ; dc->vmsd =&vmstate_usb_msd; - dc->props = msd_properties; + klass->props = msd_properties; }static TypeInfo msd_info = {hw/usb/hcd-ehci.c +2
-2@@ -2208,7 +2208,7 @@ static void ehci_class_init(ObjectClass *klass, void *data) k->revision =0x10 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_ehci; - dc->props = ehci_properties; + klass->props = ehci_properties; }static TypeInfo ehci_info = {@@ -2229,7 +2229,7 @@ static void ich9_ehci_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_ehci; - dc->props = ehci_properties; + klass->props = ehci_properties; }static TypeInfo ich9_ehci_info = {hw/usb/hcd-ohci.c +2
-2@@ -1863,7 +1863,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_APPLE_IPID_USB ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->desc ="Apple USB Controller" ; - dc->props = ohci_pci_properties; + klass->props = ohci_pci_properties; }static TypeInfo ohci_pci_info = {@@ -1886,7 +1886,7 @@ static void ohci_sysbus_class_init(ObjectClass *klass, void *data) sbc->init = ohci_init_pxa; dc->desc ="OHCI USB Controller" ; - dc->props = ohci_sysbus_properties; + klass->props = ohci_sysbus_properties; }static TypeInfo ohci_sysbus_info = {hw/usb/hcd-uhci.c +6
-6@@ -1259,7 +1259,7 @@ static void piix3_uhci_class_init(ObjectClass *klass, void *data) k->revision =0x01 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo piix3_uhci_info = {@@ -1281,7 +1281,7 @@ static void piix4_uhci_class_init(ObjectClass *klass, void *data) k->revision =0x01 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo piix4_uhci_info = {@@ -1303,7 +1303,7 @@ static void vt82c686b_uhci_class_init(ObjectClass *klass, void *data) k->revision =0x01 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo vt82c686b_uhci_info = {@@ -1324,7 +1324,7 @@ static void ich9_uhci1_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo ich9_uhci1_info = {@@ -1345,7 +1345,7 @@ static void ich9_uhci2_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo ich9_uhci2_info = {@@ -1366,7 +1366,7 @@ static void ich9_uhci3_class_init(ObjectClass *klass, void *data) k->revision =0x03 ; k->class_id =PCI_CLASS_SERIAL_USB ; dc->vmsd =&vmstate_uhci; - dc->props = uhci_properties; + klass->props = uhci_properties; }static TypeInfo ich9_uhci3_info = {hw/usb/hcd-xhci.c +1
-1@@ -2894,7 +2894,7 @@ static void xhci_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass); dc->vmsd =&vmstate_xhci; - dc->props = xhci_properties; + klass->props = xhci_properties; k->init = usb_xhci_initfn; k->vendor_id =PCI_VENDOR_ID_NEC ; k->device_id =PCI_DEVICE_ID_NEC_UPD720200 ;hw/usb/host-linux.c +1
-1@@ -1472,7 +1472,7 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data) uc->handle_reset = usb_host_handle_reset; uc->handle_destroy = usb_host_handle_destroy; dc->vmsd =&vmstate_usb_host; - dc->props = usb_host_dev_properties; + klass->props = usb_host_dev_properties; }static TypeInfo usb_host_dev_info = {hw/usb/redirect.c +1
-1@@ -1479,7 +1479,7 @@ static void usbredir_class_initfn(ObjectClass *klass, void *data) uc->handle_reset = usbredir_handle_reset; uc->handle_data = usbredir_handle_data; uc->handle_control = usbredir_handle_control; - dc->props = usbredir_properties; + klass->props = usbredir_properties; }static TypeInfo usbredir_dev_info = {hw/virtio-console.c +2
-4@@ -131,7 +131,6 @@ static Property virtconsole_properties[] = {static void virtconsole_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_CLASS (klass); k->is_console = true;@@ -139,7 +138,7 @@ static void virtconsole_class_init(ObjectClass *klass, void *data) k->have_data = flush_buf; k->guest_open = guest_open; k->guest_close = guest_close; - dc->props = virtconsole_properties; + klass->props = virtconsole_properties; }static TypeInfo virtconsole_info = {@@ -156,14 +155,13 @@ static Property virtserialport_properties[] = {static void virtserialport_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_CLASS (klass); k->init = virtconsole_initfn; k->have_data = flush_buf; k->guest_open = guest_open; k->guest_close = guest_close; - dc->props = virtserialport_properties; + klass->props = virtserialport_properties; }static TypeInfo virtserialport_info = {hw/virtio-pci.c +5
-5@@ -961,7 +961,7 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_STORAGE_SCSI ; dc->reset = virtio_pci_reset; - dc->props = virtio_blk_properties; + klass->props = virtio_blk_properties; }static TypeInfo virtio_blk_info = {@@ -995,7 +995,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_NETWORK_ETHERNET ; dc->reset = virtio_pci_reset; - dc->props = virtio_net_properties; + klass->props = virtio_net_properties; }static TypeInfo virtio_net_info = {@@ -1026,7 +1026,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_COMMUNICATION_OTHER ; dc->reset = virtio_pci_reset; - dc->props = virtio_serial_properties; + klass->props = virtio_serial_properties; }static TypeInfo virtio_serial_info = {@@ -1054,7 +1054,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data) k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_OTHERS ; dc->reset = virtio_pci_reset; - dc->props = virtio_balloon_properties; + klass->props = virtio_balloon_properties; }static TypeInfo virtio_balloon_info = {@@ -1108,7 +1108,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, void *data) k->revision =0x00 ; k->class_id =PCI_CLASS_STORAGE_SCSI ; dc->reset = virtio_pci_reset; - dc->props = virtio_scsi_properties; + klass->props = virtio_scsi_properties; }static TypeInfo virtio_scsi_info = {hw/virtio-serial-bus.c +1
-1@@ -995,7 +995,7 @@ static void virtio_serial_port_class_init(ObjectClass *klass, void *data) k->bus_type =TYPE_VIRTIO_SERIAL_BUS ; k->exit = virtser_port_qdev_exit; k->unplug = qdev_simple_unplug_cb; - k->props = virtser_props; + klass->props = virtser_props; }static TypeInfo virtio_serial_port_type_info = {hw/vmmouse.c +1
-1@@ -284,7 +284,7 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data) dc->no_user =1 ; dc->reset = vmmouse_reset; dc->vmsd =&vmstate_vmmouse; - dc->props = vmmouse_properties; + klass->props = vmmouse_properties; }static TypeInfo vmmouse_info = {hw/vt82c686.c +1
-1@@ -471,7 +471,7 @@ static void via_pm_class_init(ObjectClass *klass, void *data) k->revision =0x40 ; dc->desc ="PM" ; dc->vmsd =&vmstate_acpi; - dc->props = via_pm_properties; + klass->props = via_pm_properties; }static TypeInfo via_pm_info = {hw/xgmac.c +1
-1@@ -415,7 +415,7 @@ static void xgmac_enet_class_init(ObjectClass *klass, void *data) sbc->init = xgmac_enet_init; dc->vmsd =&vmstate_xgmac; - dc->props = xgmac_properties; + klass->props = xgmac_properties; }static TypeInfo xgmac_enet_info = {hw/xilinx_axidma.c +1
-2@@ -494,11 +494,10 @@ static Property axidma_properties[] = {static void axidma_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_axidma_init; - dc->props = axidma_properties; + klass->props = axidma_properties; }static TypeInfo axidma_info = {hw/xilinx_axienet.c +1
-2@@ -881,11 +881,10 @@ static Property xilinx_enet_properties[] = {static void xilinx_enet_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_enet_init; - dc->props = xilinx_enet_properties; + klass->props = xilinx_enet_properties; }static TypeInfo xilinx_enet_info = {hw/xilinx_ethlite.c +1
-2@@ -235,11 +235,10 @@ static Property xilinx_ethlite_properties[] = {static void xilinx_ethlite_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_ethlite_init; - dc->props = xilinx_ethlite_properties; + klass->props = xilinx_ethlite_properties; }static TypeInfo xilinx_ethlite_info = {hw/xilinx_intc.c +1
-2@@ -168,11 +168,10 @@ static Property xilinx_intc_properties[] = {static void xilinx_intc_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_intc_init; - dc->props = xilinx_intc_properties; + klass->props = xilinx_intc_properties; }static TypeInfo xilinx_intc_info = {hw/xilinx_timer.c +1
-2@@ -227,11 +227,10 @@ static Property xilinx_timer_properties[] = {static void xilinx_timer_class_init (ObjectClass *klass,void *data) { -DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); k->init = xilinx_timer_init; - dc->props = xilinx_timer_properties; + klass->props = xilinx_timer_properties; }static TypeInfo xilinx_timer_info = {hw/xio3130_downstream.c +1
-1@@ -193,7 +193,7 @@ static void xio3130_downstream_class_init(ObjectClass *klass, void *data) dc->desc ="TI X3130 Downstream Port of PCI Express Switch" ; dc->reset = xio3130_downstream_reset; dc->vmsd =&vmstate_xio3130_downstream; - dc->props = xio3130_downstream_properties; + klass->props = xio3130_downstream_properties; }static TypeInfo xio3130_downstream_info = {hw/xio3130_upstream.c +1
-1@@ -167,7 +167,7 @@ static void xio3130_upstream_class_init(ObjectClass *klass, void *data) dc->desc ="TI X3130 Upstream Port of PCI Express Switch" ; dc->reset = xio3130_upstream_reset; dc->vmsd =&vmstate_xio3130_upstream; - dc->props = xio3130_upstream_properties; + klass->props = xio3130_upstream_properties; }static TypeInfo xio3130_upstream_info = {hw/zaurus.c +1
-1@@ -233,7 +233,7 @@ static void scoop_sysbus_class_init(ObjectClass *klass, void *data) k->init = scoop_init; dc->desc ="Scoop2 Sharp custom ASIC" ; dc->vmsd =&vmstate_scoop_regs; - dc->props = scoop_sysbus_properties; + klass->props = scoop_sysbus_properties; }static TypeInfo scoop_sysbus_info = {include/qemu/object.h +4
-3@@ -33,6 +33,9 @@ typedef struct TypeInfo TypeInfo;typedef struct InterfaceClass InterfaceClass ;typedef struct InterfaceInfo InterfaceInfo ; +typedef struct Property Property ; +typedef struct PropertyInfo PropertyInfo ; +#define TYPE_OBJECT "object"/** @@ -241,6 +244,7 @@ struct ObjectClassType type;/*< public>*/ +Property *props;const char *(*get_id)(Object *); };@@ -983,9 +987,6 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),*/ Object *container_get (Object *root,const char *path); -typedef struct Property Property ; -typedef struct PropertyInfo PropertyInfo ; -struct Property {const char *name;PropertyInfo *info;qom/object.c +20
-0@@ -1262,9 +1262,28 @@ bool object_is_realized(Object *obj)return obj->state ==OBJECT_STATE_REALIZED ; } +static void object_class_base_init (ObjectClass *klass,void *data) +{ +/* We explicitly look up properties in the superclasses, +* so do not propagate them to the subclasses. +*/ + klass->props =NULL ; +} +static void object_instance_init (Object *obj) { +ObjectClass *class; +Property *prop; +object_property_add_str (obj,"type" , qdev_get_type,NULL ,NULL ); + + class =object_get_class (obj); +do { +for (prop =OBJECT_CLASS (class)->props; prop&& prop->name; prop++) { +object_property_add_static (obj, prop,NULL ); + } + class =object_class_get_parent (class); + }while (class !=object_class_by_name (TYPE_OBJECT )); }static void object_class_init (ObjectClass *klass,void *class_data)@@ -1283,6 +1302,7 @@ static void register_types(void)static TypeInfo object_info = { .name =TYPE_OBJECT , .instance_size =sizeof (Object), + .class_base_init = object_class_base_init, .instance_init = object_instance_init, .class_init = object_class_init, .abstract = true,
Re: [Qemu-devel] [PATCH qom-next 2/7] qom: Add get_id
In reply to Anthony LiguoriAm 08.06.2012 03:22, schrieb Anthony Liguori:
Quoted 9 lines · Andreas Färber
Quoted 8 lines
From: Paolo Bonzini<[email protected]>
Some classes may present objects differently in errors, for example if they
are not part of the composition tree or if they are not assigned an id by the user. Let them do this with aget_idmethod on Object, and use the method consistently where a %(device) appears in the error.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Paolo Bonzini<[email protected]>[AF: Renamed _object_get_id() to object_instance_get_id(), avoid ?:.][AF: Use object_property_is_child().]Signed-off-by Andreas Färber<[email protected]>Nack.
Unfortunately that comment comes a bit late (original submission May 23rd, me specifically cc'ing you in my reply that it's new and not covered by your carte blanche). It renders all your later Reviewed-bys on this series obsolete since they introduce uses of this function.
The general idea as I understand it is to have a mechanism for having devices fill in their ID into %(device) in the error messages once the code emitting those errors is at Object level. Peter's improved error message practically becomes "Property '.propertyname' ..." because without it we'll need to fill in "" in lack of an actual value.
Quoted 4 lines
This creates confusion IMHO. There's a big difference between an object typename and the path to the object. I don't think we should confuse the two by introducing a third type of name and calling it something generic like id.
[...]
Quoted 30 lines
Quoted 17 lines
qom/object.c +8
-0@@ -346,6 +346,24 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp) } } +static const char *object_instance_get_id (Object *obj) +{ +ObjectProperty *prop; + + QTAILQ_FOREACH(prop,&obj->properties, node) { +if (object_property_is_child (prop)&& prop->opaque == obj) { +return prop->name; + }qom/object.c static void object_property_del_child(Object · line 367
Quoted 10 lines
qom/object.c +10
-0+ } + +return "" ; +} + +const char *object_get_id (Object *obj) +{ +return obj->class->get_id (obj); +} +We should use a canonical path IMHO instead of returning a partial name.
Quoted 1 line
Partial names are ambiguous.
Possibly, but a partial name still is an improvement over the current situation with no name at all. Also my previous request to not use %(device) for Object-level API was rejected with reference to existing QMP users, so by the same argument we cannot stuff a QOM path into %(device) either and would need a new QMP field %(path) or so. Cc'ing Luiz.
There is no guarantee that the object actually has a canonical path at that point, and object_get_canonical_path() would g_assert() in such a case.
Please advise on how to proceed with this series.
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 qom-next 2/7] qom: Add get_id
Quoted 15 lines · Andreas Färber
Am 08.06.2012 03:22, schrieb Anthony Liguori:
Quoted 14 lines · Andreas Färber
Quoted 12 lines
From: Paolo Bonzini<[email protected]>
Some classes may present objects differently in errors, for example if they
are not part of the composition tree or if they are not assigned an id by the user. Let them do this with aget_idmethod on Object, and use the method consistently where a %(device) appears in the error.Signed-off-by Paolo Bonzini<[email protected]>[AF: Renamed _object_get_id() to object_instance_get_id(), avoid ?:.][AF: Use object_property_is_child().]Signed-off-by Andreas Färber<[email protected]>
Quoted 5 lines
Quoted 1 line
Nack.
Unfortunately that comment comes a bit late (original submission May 23rd, me specifically cc'ing you in my reply that it's new and not covered by your carte blanche).
Uh, that was a week before the release. Don't send significant things during the final part of a release and expect to get significant review.
Quoted 5 lines
The general idea as I understand it is to have a mechanism for having devices fill in their ID into %(device) in the error messages once the code emitting those errors is at Object level. Peter's improved error message practically becomes "Property '.propertyname' ..." because without it we'll need to fill in "" in lack of an actual value.
Ambiguity is fundamentally bad. If you want to return the path, return the path. If you want to return the type, return the type. Returning the type because we're too lazy to implement the path properly is not acceptable and makes the error messages useless (because they're ambiguous).
Have a separate 'path' and 'typename' attribute in the errors. With some cleverness, you can probably use '%p' and interpret the pointer an as Object * and automagically generate an embedded 'device': { 'path': '/path/to/device', 'typename': 'FancyType' }.
Quoted 10 lines
Quoted 4 lines
We should use a canonical path IMHO instead of returning a partial name.
Partial names are ambiguous.
Possibly, but a partial name still is an improvement over the current situation with no name at all. Also my previous request to not use %(device) for Object-level API was rejected with reference to existing QMP users, so by the same argument we cannot stuff a QOM path into %(device) either and would need a new QMP field %(path) or so. Cc'ing Luiz.
Since qdev->id is NULL 90% of the time, I don't think a user can realistically rely on it. I don't think changing the type of the data in the error is going to be a problem.
Doesn't libvirt ignore the contents of an error object?
Regards,
Anthony Liguori
Quoted 8 lines
There is no guarantee that the object actually has a canonical path at that point, and
object_get_canonical_path()wouldg_assert()in such a case.Please advise on how to proceed with this series.
Andreas
Re: [Qemu-devel] [PATCH qom-next 2/7] qom: Add get_id
Am 08.06.2012 09:44, schrieb Anthony Liguori:
Quoted 17 lines · Andreas Färber
Quoted 16 lines
Am 08.06.2012 03:22, schrieb Anthony Liguori:
Quoted 15 lines · Andreas Färber
Quoted 13 lines
From: Paolo Bonzini<[email protected]>
Some classes may present objects differently in errors, for example if they
are not part of the composition tree or if they are not assigned an id by
the user. Let them do this with aget_idmethod on Object, and use the method consistently where a %(device) appears in the error.Signed-off-by Paolo Bonzini<[email protected]>[AF: Renamed _object_get_id() to object_instance_get_id(), avoid ?:.][AF: Use object_property_is_child().]Signed-off-by Andreas Färber<[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Nack.
Unfortunately that comment comes a bit late (original submission May 23rd, me specifically cc'ing you in my reply that it's new and not covered by your carte blanche).
Uh, that was a week before the release. Don't send significant things during the final part of a release and expect to get significant review.
Well, obviously we were hoping to get this series committed immediately after the release, so we needed to get review before that. :)
Quoted 29 lines
Quoted 5 lines
The general idea as I understand it is to have a mechanism for having devices fill in their ID into %(device) in the error messages once the code emitting those errors is at Object level. Peter's improved error message practically becomes "Property '.propertyname' ..." because without it we'll need to fill in "" in lack of an actual value.
Ambiguity is fundamentally bad. If you want to return the path, return the path. If you want to return the type, return the type. Returning the type because we're too lazy to implement the path properly is not acceptable and makes the error messages useless (because they're ambiguous).
Have a separate 'path' and 'typename' attribute in the errors. With some cleverness, you can probably use '%p' and interpret the pointer an as Object * and automagically generate an embedded 'device': { 'path':
'/path/to/device', 'typename': 'FancyType' }.Quoted 11 lines
Quoted 4 lines
We should use a canonical path IMHO instead of returning a partial name.
Partial names are ambiguous.
Possibly, but a partial name still is an improvement over the current situation with no name at all. Also my previous request to not use %(device) for Object-level API was rejected with reference to existing QMP users, so by the same argument we cannot stuff a QOM path into %(device) either and would need a new QMP field %(path) or so. Cc'ing Luiz.
Quoted 5 lines
Since
qdev->idis NULL 90% of the time, I don't think a user can realistically rely on it. I don't think changing the type of the data in the error is going to be a problem.Doesn't libvirt ignore the contents of an error object?
I'm out of my field there, those questions are for Luiz and the libvirt guys to answer. (Context is ongoing DeviceState -> Object transition on qom-next branch, properties being moved to Object and what info to include in Error objects then)
If you reach consensus how to handle this, I can refactor accordingly, or Paolo could pick up my tweaked series again and refactor himself.
Regards,
Andreas
Quoted 3 lines
Quoted 3 lines
There is no guarantee that the object actually has a canonical path at that point, and
object_get_canonical_path()wouldg_assert()in such a case.
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] [libvirt] [PATCH qom-next 2/7] qom: Add get_id
Quoted 6 lines · Andreas Färber
Am 08.06.2012 09:44, schrieb Anthony Liguori:
Quoted 5 lines · Andreas Färber
Since
qdev->idis NULL 90% of the time, I don't think a user can realistically rely on it. I don't think changing the type of the data in the error is going to be a problem.
Quoted 6 lines
Quoted 1 line
Doesn't libvirt ignore the contents of an error object?
I'm out of my field there, those questions are for Luiz and the libvirt guys to answer. (Context is ongoing DeviceState -> Object transition on qom-next branch, properties being moved to Object and what info to include in Error objects then)
Libvirt will look at two fields in the a JSON 'error' reply. We will pass 'desc' field through to the libvirt code - we treat it as an opaque value. We will look at the string value in the 'class' field to check for certain types of error - eg we strcmp against things like MigrationExpected, DeviceNotActive, CommandNotFound, KVMMissingCap, DeviceInUse, etc. All other fields are ignored.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Re: [Qemu-devel] [PATCH qom-next 2/7] qom: Add get_id
In reply to Anthony LiguoriQuoted 5 lines · Anthony Liguori
Since
qdev->idis NULL 90% of the time, I don't think a user can realistically rely on it. I don't think changing the type of the data in the error is going to be a problem.Doesn't libvirt ignore the contents of an error object?
Libvirt tries to parse the contents of an error object in order to reconstruct the most user-friendly message possible for libvirt's error message. There's already some special-casing in libvirt's code, and we can probably add more if you change the layout of particular errors.
Signature · 2 lines
Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
In reply to Anthony LiguoriIl 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 8 lines
include/qemu/object.h struct ObjectClass · line 247
Quoted 5 lines
include/qemu/object.h +4
-0+typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;I think using a bool would be better since it reduces the temptation to add additional states.
In fact someone already discussed having a third state for block devices... :)
Paolo
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
Quoted 10 lines · Paolo Bonzini
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 8 lines
include/qemu/object.h struct ObjectClass · line 247
Quoted 5 lines
include/qemu/object.h +4
-0+typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;I think using a bool would be better since it reduces the temptation to add additional states.
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
This is *exactly* why bool is better. Because too many people will be tempted to add stuff that doesn't belong in Object.
A classic problem with OO design is bloating base classes--especially when you have one common base class.
Everything in Object must be relevant to all subclasses, not just some. Having an OBJECT_STATE_OPENED only makes sense for BlockDevices. Therefore the concept of opened should live in the BlockDevice parent class.
Regards,
Anthony Liguori
Quoted 2 lines
Paolo
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
In reply to Paolo BonziniAm 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 10 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 8 lines
include/qemu/object.h struct ObjectClass · line 247
Quoted 5 lines
include/qemu/object.h +4
-0+typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;I think using a bool would be better since it reduces the temptation to add additional states.
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
I would expect that file_opened state to remain internal to the block layer. Thought we discussed that on IRC?
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 qom-next 1/7] qdev: Push state up to Object
Am 10.06.2012 19:38, schrieb Andreas Färber:
Quoted 11 lines
Am 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 10 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 8 lines
include/qemu/object.h struct ObjectClass · line 247
Quoted 5 lines
include/qemu/object.h +4
-0+typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;I think using a bool would be better since it reduces the temptation to add additional states.
Quoted 5 lines
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
I would expect that
file_openedstate to remain internal to the block layer. Thought we discussed that on IRC?
I think I still don't understand well enough what 'realized' is really supposed to mean.
Does some magic happen when an object gets realised? From outside, what's the difference between an INITIALIZED and a REALIZED object? Is it more or less an implementation detail of the base class or is it something that affects the object model itself?
I think the file_opened state should have more or less the same status as the realisation of an object. They are quite similar, so they should both be an implementation detail of their respective class, or they should both be baked into the object model.
A comment in this patch says it means that an object is fully constructed. So if we add a file_opened state in the block layer, in order to keep this consistent, it would have to be a state that comes between INITIALIZED and REALIZED.
Where would we have checks, for example whether the image that you assign to a block device is really opened? Would QOM commands to create a link only link to already realised objects? Would each single block device have to check this during its own realisation phase? Would we check object_is_realized() or rather bdrv_file_is_opened()? If the latter, it can't be generic monitor code that checks it.
Let's start with this, I'm sure I'll have more questions...
Kevin
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
Quoted 12 lines · Kevin Wolf
Am 10.06.2012 19:38, schrieb Andreas Färber:
Quoted 11 lines
Am 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 10 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 8 lines
include/qemu/object.h struct ObjectClass · line 247
Quoted 5 lines
include/qemu/object.h +4
-0+typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;I think using a bool would be better since it reduces the temptation to add additional states.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
I would expect that
file_openedstate to remain internal to the block layer. Thought we discussed that on IRC?I think I still don't understand well enough what 'realized' is really supposed to mean.
realized is essentially the Vcc pin for the device.
When realized = true, it means power has been applied to the device (and the guest potentially is interacting with it).
When realized = false, it means that power is not applied to the device and the guest is not running.
Quoted 5 lines
Does some magic happen when an object gets realised? From outside, what's the difference between an INITIALIZED and a REALIZED object? Is it more or less an implementation detail of the base class or is it something that affects the object model itself?
On the rising edge of realized, you typically will validate any parameters and do any actions necessary based on the parameters. As long as the guest isn't running, we want the ability to make changes to the devices that we normally couldn't change while the guest is running (like updating the CharDriverState pointer).
Quoted 4 lines
I think the
file_openedstate should have more or less the same status as the realisation of an object. They are quite similar, so they should both be an implementation detail of their respective class, or they should both be baked into the object model.
I think we need to think about what realized means to a non-Device. Does file_opened have the same logical semantics as the above?
Quoted 3 lines
A comment in this patch says it means that an object is fully constructed.
That's not really the best wording. See above.
Regards,
Anthony Liguori
Quoted 14 lines
So if we add a
file_openedstate in the block layer, in order to keep this consistent, it would have to be a state that comes between INITIALIZED and REALIZED.Where would we have checks, for example whether the image that you assign to a block device is really opened? Would QOM commands to create a link only link to already realised objects? Would each single block device have to check this during its own realisation phase? Would we check
object_is_realized()or ratherbdrv_file_is_opened()? If the latter, it can't be generic monitor code that checks it.Let's start with this, I'm sure I'll have more questions...
Kevin
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
Am 11.06.2012 15:21, schrieb Anthony Liguori:
Quoted 16 lines · Kevin Wolf
Quoted 15 lines
Am 10.06.2012 19:38, schrieb Andreas Färber:
Quoted 14 lines
Am 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 12 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 8 lines
include/qemu/object.h struct ObjectClass · line 247
Quoted 5 lines
include/qemu/object.h +4
-0+typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;I think using a bool would be better since it reduces the temptation to add additional states.
In fact someone already discussed having a third state for block devices... :)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I would expect that
file_openedstate to remain internal to the block layer. Thought we discussed that on IRC?I think I still don't understand well enough what 'realized' is really supposed to mean.
realized is essentially the Vcc pin for the device.
My BlockDriverState doesn't have a Vcc pin, and neither has my Error object. I thought realize() did exist in Object and not only in Device? If so, it must have a more generic meaning.
Quoted 10 lines
Quoted 4 lines
Does some magic happen when an object gets realised? From outside, what's the difference between an INITIALIZED and a REALIZED object? Is it more or less an implementation detail of the base class or is it something that affects the object model itself?
On the rising edge of realized, you typically will validate any parameters and do any actions necessary based on the parameters. As long as the guest isn't running, we want the ability to make changes to the devices that we normally couldn't change while the guest is running (like updating the CharDriverState pointer).
Okay, that matches my understanding.
Are all of the checks and the status change of properties (modifiable -> const) done by the specific subclass or is it done by QOM to some degree?
Quoted 7 lines
Quoted 4 lines
I think the
file_openedstate should have more or less the same status as the realisation of an object. They are quite similar, so they should both be an implementation detail of their respective class, or they should both be baked into the object model.I think we need to think about what realized means to a non-Device. Does
file_openedhave the same logical semantics as the above?
Yes, I think it's quite similar, just at an intermediate stage of the object creation. As I imagine it, you would:
1. Create a BlockDriveState
2. Modify the filename property (you can really modify any property if you want for some reason)
3. Call file_open, which opens the image file and may derive some default property values from the image file (flags in the header or whatever). Typical example: The backing file path. I think this would roughly correspond to an extended .bdrv_probe.
4. Modify more properties, overriding any defaults of the image. file_open has made some properties read-only (like the filename), which cannot be modified any more.
5. Call realize. This is the actual .bdrv_open call that makes the BlockDriverState ready to be used. This makes some more properties read-only, like the backing file and format.
Quoted 4 lines
Quoted 2 lines
A comment in this patch says it means that an object is fully constructed.
That's not really the best wording. See above.
For non-Devices it's still the best explanation I have found.
Kevin
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
In reply to Anthony LiguoriAm 11.06.2012 15:21, schrieb Anthony Liguori:
Quoted 23 lines · Kevin Wolf
Quoted 13 lines
Am 10.06.2012 19:38, schrieb Andreas Färber:
Quoted 12 lines
Am 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 11 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 9 lines
include/qemu/object.h struct ObjectClass · line 247
Quoted 5 lines
include/qemu/object.h +4
-0+typedef enum ObjectState { +OBJECT_STATE_INITIALIZED =1 , +OBJECT_STATE_REALIZED , +}ObjectState ;I think using a bool would be better since it reduces the temptation to
add additional states.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
I would expect that
file_openedstate to remain internal to the block layer. Thought we discussed that on IRC?I think I still don't understand well enough what 'realized' is really supposed to mean.
Quoted 7 lines
realized is essentially the Vcc pin for the device.
When realized = true, it means power has been applied to the device (and the guest potentially is interacting with it).
When realized = false, it means that power is not applied to the device and the guest is not running.
That does not match my understanding of realize.
To me, realize is the second-stage (final) initialization of an object. It's purpose is to set up an object based on properties set after its initialization, so that it can be fully used.
Contrary to the initialization phase, where failure would lead to inability to run finalizers, realization can fail and leaves the object in a defined state so that it can either be realized again with changed properties or deleted, running any finalizers.
The main difference to qdev init is that we are working towards replacing the init-after-create pattern with late, central realization so that users have a chance to modify objects through QMP once initialized. (Which is what the don't-create-objects-in-realize and in-place initialization discussion is about.)
Thus I do not think this has anything to do with devices or power. A device within a SoC or Super I/O chip that is turned off / powered down may still be there wrt MemoryRegions. It would be possible though to amend realize functionality by overriding realize for DeviceState or specific devices.
For block devices I thought the discussion had been that they would get a block-specific open(Error**) method, called after initialization and setting the file name / URL, setting some bool opened state. Some block properties would then depend on "opened" rather than on object_is_realized() and fail otherwise. Realize would still be the final construction of the object based on user-settable properties.
A variation of this patch here would be to introduce bool realized while leaving the qdev state untouched. But that would be in the way of generalizing static properties to Object, which would mean for the block layer that any trivial property would need to be implemented through manually coded getters and setters.
Regards,
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 qom-next 1/7] qdev: Push state up to Object
Am 11.06.2012 23:31, schrieb Andreas Färber:
Quoted 42 lines
Am 11.06.2012 15:21, schrieb Anthony Liguori:
Quoted 23 lines · Kevin Wolf
Quoted 13 lines
Am 10.06.2012 19:38, schrieb Andreas Färber:
Quoted 12 lines
Am 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 11 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+typedef enum ObjectState { + OBJECT_STATE_INITIALIZED = 1, + OBJECT_STATE_REALIZED, +} ObjectState;I think using a bool would be better since it reduces the temptation to
add additional states.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
I would expect that
file_openedstate to remain internal to the block layer. Thought we discussed that on IRC?I think I still don't understand well enough what 'realized' is really supposed to mean.
Quoted 7 lines
realized is essentially the Vcc pin for the device.
When realized = true, it means power has been applied to the device (and the guest potentially is interacting with it).
When realized = false, it means that power is not applied to the device and the guest is not running.
That does not match my understanding of realize.
To me, realize is the second-stage (final) initialization of an object. It's purpose is to set up an object based on properties set after its initialization, so that it can be fully used.
Contrary to the initialization phase, where failure would lead to inability to run finalizers, realization can fail and leaves the object in a defined state so that it can either be realized again with changed properties or deleted, running any finalizers.
Quoted 5 lines
The main difference to qdev init is that we are working towards replacing the init-after-create pattern with late, central realization so that users have a chance to modify objects through QMP once initialized. (Which is what the don't-create-objects-in-realize and in-place initialization discussion is about.)
This is the part that I think can be interpreted as "machine is powered on" or Vcc, but there's nothing stopping us from calling realize at a slightly different point in time for non-device objects not connected to /machine.
An SD card for instance could be realized before it is inserted into the drive and thereby before it gets any Vcc.
/-F
Quoted 21 lines
Thus I do not think this has anything to do with devices or power. A device within a SoC or Super I/O chip that is turned off / powered down may still be there wrt MemoryRegions. It would be possible though to amend realize functionality by overriding realize for DeviceState or specific devices.
For block devices I thought the discussion had been that they would get a block-specific
open(Error**)method, called after initialization and setting the file name / URL, setting some bool opened state. Some block properties would then depend on "opened" rather than onobject_is_realized()and fail otherwise. Realize would still be the final construction of the object based on user-settable properties.A variation of this patch here would be to introduce bool realized while leaving the qdev state untouched. But that would be in the way of generalizing static properties to Object, which would mean for the block layer that any trivial property would need to be implemented through manually coded getters and setters.
Regards,
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 qom-next 1/7] qdev: Push state up to Object
In reply to Andreas FärberQuoted 34 lines · Andreas Färber
Am 11.06.2012 15:21, schrieb Anthony Liguori:
Quoted 23 lines · Kevin Wolf
Quoted 13 lines
Am 10.06.2012 19:38, schrieb Andreas Färber:
Quoted 12 lines
Am 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 11 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+typedef enum ObjectState { + OBJECT_STATE_INITIALIZED = 1, + OBJECT_STATE_REALIZED, +} ObjectState;I think using a bool would be better since it reduces the temptation to
add additional states.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
I would expect that
file_openedstate to remain internal to the block layer. Thought we discussed that on IRC?I think I still don't understand well enough what 'realized' is really supposed to mean.
Quoted 7 lines
realized is essentially the Vcc pin for the device.
When realized = true, it means power has been applied to the device (and the guest potentially is interacting with it).
When realized = false, it means that power is not applied to the device and the guest is not running.
That does not match my understanding of realize.
Quoted 7 lines
To me, realize is the second-stage (final) initialization of an object. It's purpose is to set up an object based on properties set after its initialization, so that it can be fully used.
Contrary to the initialization phase, where failure would lead to inability to run finalizers, realization can fail and leaves the object in a defined state so that it can either be realized again with changed properties or deleted, running any finalizers.
This is not the intention of realize. There's nothing final about realize either.
Realize attempts to give you a hook at the very last moment before you can no longer change a device. In X11, realize happens before a window is mapped to the visible screen. X11 has the same problem where there's a relationship between widgets and there's some work that requires that the parent widget is known. realize() provides that last possible hook where you can defer the work that requires the parent and children to be setup.
That's what realize achieves. And unrealize is just the opposite. It's called as soon as you unmap a window and can be used to undo the things you did in realize.
Regards,
Anthony Liguori
Quoted 29 lines
The main difference to qdev init is that we are working towards replacing the init-after-create pattern with late, central realization so that users have a chance to modify objects through QMP once initialized. (Which is what the don't-create-objects-in-realize and in-place initialization discussion is about.)
Thus I do not think this has anything to do with devices or power. A device within a SoC or Super I/O chip that is turned off / powered down may still be there wrt MemoryRegions. It would be possible though to amend realize functionality by overriding realize for DeviceState or specific devices.
For block devices I thought the discussion had been that they would get a block-specific
open(Error**)method, called after initialization and setting the file name / URL, setting some bool opened state. Some block properties would then depend on "opened" rather than onobject_is_realized()and fail otherwise. Realize would still be the final construction of the object based on user-settable properties.A variation of this patch here would be to introduce bool realized while leaving the qdev state untouched. But that would be in the way of generalizing static properties to Object, which would mean for the block layer that any trivial property would need to be implemented through manually coded getters and setters.
Regards,
Andreas
Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object
Am 11.06.2012 23:48, schrieb Anthony Liguori:
Quoted 43 lines · Andreas Färber
Quoted 34 lines
Am 11.06.2012 15:21, schrieb Anthony Liguori:
Quoted 23 lines · Kevin Wolf
Quoted 13 lines
Am 10.06.2012 19:38, schrieb Andreas Färber:
Quoted 12 lines
Am 10.06.2012 17:49, schrieb Paolo Bonzini:
Quoted 11 lines
Il 08/06/2012 03:19, Anthony Liguori ha scritto:
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+typedef enum ObjectState { + OBJECT_STATE_INITIALIZED = 1, + OBJECT_STATE_REALIZED, +} ObjectState;I think using a bool would be better since it reduces the temptation to
add additional states.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
In fact someone already discussed having a third state for block devices... :)
I would expect that
file_openedstate to remain internal to the block layer. Thought we discussed that on IRC?I think I still don't understand well enough what 'realized' is really supposed to mean.
Quoted 7 lines
realized is essentially the Vcc pin for the device.
When realized = true, it means power has been applied to the device (and the guest potentially is interacting with it).
When realized = false, it means that power is not applied to the device and the guest is not running.
That does not match my understanding of realize.
Quoted 7 lines
To me, realize is the second-stage (final) initialization of an object. It's purpose is to set up an object based on properties set after its initialization, so that it can be fully used.
Contrary to the initialization phase, where failure would lead to inability to run finalizers, realization can fail and leaves the object in a defined state so that it can either be realized again with changed properties or deleted, running any finalizers.
Quoted 2 lines
This is not the intention of realize. There's nothing final about realize either.
Final in the sense of second-stage of two stages: No further construction happens after realize because realize is being deferred to the latest point possible.
Quoted 11 lines
Realize attempts to give you a hook at the very last moment before you can no longer change a device. In X11, realize happens before a window is mapped to the visible screen. X11 has the same problem where there's a relationship between widgets and there's some work that requires that the parent widget is known.
realize()provides that last possible hook where you can defer the work that requires the parent and children to be setup.That's what realize achieves. And unrealize is just the opposite. It's called as soon as you unmap a window and can be used to undo the things you did in realize.
We don't seem to be in disagreement except that you say it's not the intention of realize...
Hook, function or constructor ... it basically does the same thing.
If you want to have differently named hooks doing roughly the same thing in different contexts, then what is your suggestion? The qdev init model doesn't fully translate to realize yet, so add DEVICE_STATE_REALIZED to the qdev state enum as third state?
Andreas
Quoted 33 lines
Regards,
Anthony Liguori
Quoted 28 lines
The main difference to qdev init is that we are working towards replacing the init-after-create pattern with late, central realization so that users have a chance to modify objects through QMP once initialized. (Which is what the don't-create-objects-in-realize and in-place initialization discussion is about.)
Thus I do not think this has anything to do with devices or power. A device within a SoC or Super I/O chip that is turned off / powered down may still be there wrt MemoryRegions. It would be possible though to amend realize functionality by overriding realize for DeviceState or specific devices.
For block devices I thought the discussion had been that they would get a block-specific
open(Error**)method, called after initialization and setting the file name / URL, setting some bool opened state. Some block properties would then depend on "opened" rather than onobject_is_realized()and fail otherwise. Realize would still be the final construction of the object based on user-settable properties.A variation of this patch here would be to introduce bool realized while leaving the qdev state untouched. But that would be in the way of generalizing static properties to Object, which would mean for the block layer that any trivial property would need to be implemented through manually coded getters and setters.
Regards,
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