All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push!
@ 2012-04-03 11:15 Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent Paolo Bonzini
                   ` (24 more replies)
  0 siblings, 25 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

This is the final installment of the qdev property cleanup.  It
includes the following parts:

* various bits of state are moved from DeviceState to Object:
  state (aka realized), reset, static properties, and the simple
  "type" property

* bus properties are replaced with superclass properties

The series has many parts; they are logically separate, but because
of dependencies it would take too much time to submit them one by
one.  In fact, to avoid conflicts, and because his patchset does not
apply anymore, I took the liberty to include here Michael Roth's patches
for uint*_t and int*_t visitors.

Patches 1 to 5 are small preparatory changes in QOM.

Patches 6 and 7 are bonus bugfixes.

Patches 8 to 13 refactor bus properties.

Patches 14 to 18 are Michael's patches + two cleanups.

Patches 19 to 22 push static properties from qdev to Object.  As you
can see from the diffstat below, this has to touch a lot of files.

Patches 23 to 25 implement the realized property and reimplement
qdev's object lifecycle in terms of realize/unrealize.

Michael Roth (3):
  qapi: add Visitor interfaces for uint*_t and int*_t
  qdev: use int32_t container for devfn property
  qdev: switch property accessors to fixed-width visitor interfaces

Paolo Bonzini (22):
  qom: add object_class_get_parent
  qom: add object_child_foreach
  qom: add class_base_init
  qom: make Object a type
  qom: push type up to Object
  qdev: fix -device foo,?
  qdev: use object_property_print in info qtree
  qdev: remove qdev_prop_set_defaults
  qdev: move bus properties to a separate global
  qdev: do not propagate properties to subclasses
  qdev: pick global properties from superclasses
  qdev: factor setting of global properties
  qdev: replace bus properties with superclass properties
  qdev: remove PropertyInfo range checking
  qdev: remove qdev_prop_exists
  qom: push state up to Object
  qdev: generalize properties to Objects
  qdev: move bulk of qdev-properties.c to qom/object.c
  qom: push static properties to Object
  qom: add realized property
  qdev: implement qdev_init on top of realize
  qdev: split part of device_finalize to device_unrealize

 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_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                |    4 +-
 hw/hpet.c                     |    2 +-
 hw/i2c.c                      |   10 +-
 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                 |   16 +-
 hw/integratorcp.c             |    3 +-
 hw/intel-hda.c                |   12 +-
 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              |    9 +-
 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_piix.c                  |   12 +-
 hw/pc_sysfw.c                 |    2 +-
 hw/pci.c                      |   24 +-
 hw/pci.h                      |    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                |   26 +-
 hw/qdev-monitor.c             |   46 ++-
 hw/qdev-properties.c          |  683 ++++++-----------------------------------
 hw/qdev.c                     |  152 ++++-----
 hw/qdev.h                     |  109 +------
 hw/qxl.c                      |    4 +-
 hw/rtl8139.c                  |    2 +-
 hw/s390-virtio-bus.c          |   12 +-
 hw/sb16.c                     |    2 +-
 hw/scsi-bus.c                 |   16 +-
 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                |   10 +-
 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                  |   11 +-
 hw/usb/dev-audio.c            |    2 +-
 hw/usb/dev-network.c          |    2 +-
 hw/usb/dev-serial.c           |    4 +-
 hw/usb/dev-smartcard-reader.c |   12 +-
 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        |   12 +-
 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         |  182 ++++++++++-
 qapi/qapi-visit-core.c        |  139 +++++++++
 qapi/qapi-visit-core.h        |   16 +
 qom/object.c                  |  681 ++++++++++++++++++++++++++++++++++++++--
 147 files changed, 1427 insertions(+), 1102 deletions(-)

-- 
1.7.9.3

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 20:50   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 02/25] qom: add object_child_foreach Paolo Bonzini
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

This simple bit of functionality was missing and we'll need it soon,
so add it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/object.h |   14 ++++++++++++++
 qom/object.c          |   13 +++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/include/qemu/object.h b/include/qemu/object.h
index a675937..f814521 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -548,6 +548,14 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
                                        const char *typename);
 
 /**
+ * object_class_get_parent:
+ * @klass: The class to obtain the parent for.
+ *
+ * Returns: The parent for @klass.
+ */
+ObjectClass *object_class_get_parent(ObjectClass *klass);
+
+/**
  * object_class_get_name:
  * @klass: The class to obtain the QOM typename for.
  *
@@ -555,6 +563,12 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
  */
 const char *object_class_get_name(ObjectClass *klass);
 
+/**
+ * object_class_by_name:
+ * @typename: The QOM typename to obtain the class for.
+ *
+ * Returns: The class for @typename.
+ */
 ObjectClass *object_class_by_name(const char *typename);
 
 void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
diff --git a/qom/object.c b/qom/object.c
index e721fc2..3e9fed7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -545,6 +545,19 @@ ObjectClass *object_class_by_name(const char *typename)
     return type->class;
 }
 
+ObjectClass *object_class_get_parent(ObjectClass *class)
+{
+    TypeImpl *type = type_get_parent(class->type);
+
+    if (!type) {
+        return NULL;
+    }
+
+    type_initialize(type);
+
+    return type->class;
+}
+
 typedef struct OCFData
 {
     void (*fn)(ObjectClass *klass, void *opaque);
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 02/25] qom: add object_child_foreach
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 20:51   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 03/25] qom: add class_base_init Paolo Bonzini
                   ` (22 subsequent siblings)
  24 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

A utility function that will be used to implement hierarchical realization.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/object.h |   14 +++++++++++++-
 qom/object.c          |   17 +++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/include/qemu/object.h b/include/qemu/object.h
index f814521..470efe3 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -918,6 +918,19 @@ void object_property_add_str(Object *obj, const char *name,
                              struct Error **errp);
 
 /**
+ * object_child_foreach:
+ * @obj: the object whose children will be navigated
+ * @fn: the iterator function to be called
+ * @opaque: an opaque value that will be passed to the iterator
+ *
+ * Call @fn passing each child of @obj and @opaque to it, until @fn returns
+ * non-zero.  Return the last value returned by @fn, or 0 if there is no
+ * child.
+ */
+int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
+                         void *opaque);
+
+/**
  * container_get:
  * @path: path to the container
  *
@@ -928,5 +941,4 @@ void object_property_add_str(Object *obj, const char *name,
  */
 Object *container_get(const char *path);
 
-
 #endif
diff --git a/qom/object.c b/qom/object.c
index 3e9fed7..4975d93 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -597,6 +597,23 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
     g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
 }
 
+int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
+                         void *opaque)
+{
+    ObjectProperty *prop;
+    int ret = 0;
+
+    QTAILQ_FOREACH(prop, &obj->properties, node) {
+        if (strstart(prop->type, "child<", NULL)) {
+            ret = fn(prop->opaque, opaque);
+            if (ret != 0) {
+                break;
+            }
+        }
+    }
+    return ret;
+}
+
 static void object_class_get_list_tramp(ObjectClass *klass, void *opaque)
 {
     GSList **list = opaque;
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 03/25] qom: add class_base_init
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 02/25] qom: add object_child_foreach Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 20:51   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 04/25] qom: make Object a type Paolo Bonzini
                   ` (21 subsequent siblings)
  24 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

The class_base_init TypeInfo callback was present in one of the early
QOM versions but removed (on my request...) before committing.  We
will need it soon, add it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/object.h |   10 ++++++++--
 qom/object.c          |    9 +++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/qemu/object.h b/include/qemu/object.h
index 470efe3..ccaea7d 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -291,10 +291,15 @@ struct Object
  *   has occurred to allow a class to set its default virtual method pointers.
  *   This is also the function to use to override virtual methods from a parent
  *   class.
+ * @class_base_init: This function is called for all base classes after all
+ *   parent class initialization has occurred, but before the class itself
+ *   is initialized.  This is the function to use to undo the effects of
+ *   memcpy from the parent class to the descendents.
  * @class_finalize: This function is called during class destruction and is
  *   meant to release and dynamic parameters allocated by @class_init.
- * @class_data: Data to pass to the @class_init and @class_finalize functions.
- *   This can be useful when building dynamic classes.
+ * @class_data: Data to pass to the @class_init, @class_base_init and
+ *   @class_finalize functions.  This can be useful when building dynamic
+ *   classes.
  * @interfaces: The list of interfaces associated with this type.  This
  *   should point to a static array that's terminated with a zero filled
  *   element.
@@ -312,6 +317,7 @@ struct TypeInfo
     size_t class_size;
 
     void (*class_init)(ObjectClass *klass, void *data);
+    void (*class_base_init)(ObjectClass *klass, void *data);
     void (*class_finalize)(ObjectClass *klass, void *data);
     void *class_data;
 
diff --git a/qom/object.c b/qom/object.c
index 4975d93..6ff1c19 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -45,6 +45,7 @@ struct TypeImpl
     size_t instance_size;
 
     void (*class_init)(ObjectClass *klass, void *data);
+    void (*class_base_init)(ObjectClass *klass, void *data);
     void (*class_finalize)(ObjectClass *klass, void *data);
 
     void *class_data;
@@ -112,6 +113,7 @@ TypeImpl *type_register(const TypeInfo *info)
     ti->instance_size = info->instance_size;
 
     ti->class_init = info->class_init;
+    ti->class_base_init = info->class_base_init;
     ti->class_finalize = info->class_finalize;
     ti->class_data = info->class_data;
 
@@ -232,6 +234,13 @@ static void type_initialize(TypeImpl *ti)
         memcpy((void *)ti->class + sizeof(ObjectClass),
                (void *)parent->class + sizeof(ObjectClass),
                parent->class_size - sizeof(ObjectClass));
+
+        while (parent) {
+            if (parent->class_base_init) {
+                parent->class_base_init(ti->class, ti->class_data);
+            }
+            parent = type_get_parent(parent);
+        }
     }
 
     memset((void *)ti->class + class_size, 0, ti->class_size - class_size);
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 04/25] qom: make Object a type
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (2 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 03/25] qom: add class_base_init Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 12:30   ` Andreas Färber
  2012-04-03 20:52   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 05/25] qom: push type up to Object Paolo Bonzini
                   ` (20 subsequent siblings)
  24 siblings, 2 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Right now the base Object class has a special NULL type.  Change this so
that we will be able to add class_init and class_base_init callbacks.
To do this, remove some special casing of ObjectClass that is not really
necessary.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/object.h |    2 +-
 qom/object.c          |   59 +++++++++++++++++++++++++------------------------
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/include/qemu/object.h b/include/qemu/object.h
index ccaea7d..22f646d 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -33,7 +33,7 @@ typedef struct TypeInfo TypeInfo;
 typedef struct InterfaceClass InterfaceClass;
 typedef struct InterfaceInfo InterfaceInfo;
 
-#define TYPE_OBJECT NULL
+#define TYPE_OBJECT "object"
 
 /**
  * SECTION:object.h
diff --git a/qom/object.c b/qom/object.c
index 6ff1c19..585619d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -210,7 +210,7 @@ static void type_class_interface_init(TypeImpl *ti, InterfaceImpl *iface)
 
 static void type_initialize(TypeImpl *ti)
 {
-    size_t class_size = sizeof(ObjectClass);
+    TypeImpl *parent;
     int i;
 
     if (ti->class) {
@@ -221,30 +221,24 @@ static void type_initialize(TypeImpl *ti)
     ti->instance_size = type_object_get_size(ti);
 
     ti->class = g_malloc0(ti->class_size);
-    ti->class->type = ti;
-
-    if (type_has_parent(ti)) {
-        TypeImpl *parent = type_get_parent(ti);
 
+    parent = type_get_parent(ti);
+    if (parent) {
         type_initialize(parent);
 
-        class_size = parent->class_size;
         g_assert(parent->class_size <= ti->class_size);
+        memcpy(ti->class, parent->class, parent->class_size);
+    }
 
-        memcpy((void *)ti->class + sizeof(ObjectClass),
-               (void *)parent->class + sizeof(ObjectClass),
-               parent->class_size - sizeof(ObjectClass));
+    ti->class->type = ti;
 
-        while (parent) {
-            if (parent->class_base_init) {
-                parent->class_base_init(ti->class, ti->class_data);
-            }
-            parent = type_get_parent(parent);
+    while (parent) {
+        if (parent->class_base_init) {
+            parent->class_base_init(ti->class, ti->class_data);
         }
+        parent = type_get_parent(parent);
     }
 
-    memset((void *)ti->class + class_size, 0, ti->class_size - class_size);
-
     for (i = 0; i < ti->num_interfaces; i++) {
         type_class_interface_init(ti, &ti->interfaces[i]);
     }
@@ -467,19 +461,6 @@ Object *object_dynamic_cast(Object *obj, const char *typename)
 }
 
 
-static void register_types(void)
-{
-    static TypeInfo interface_info = {
-        .name = TYPE_INTERFACE,
-        .instance_size = sizeof(Interface),
-        .abstract = true,
-    };
-
-    type_interface = type_register_static(&interface_info);
-}
-
-type_init(register_types)
-
 Object *object_dynamic_cast_assert(Object *obj, const char *typename)
 {
     Object *inst;
@@ -1233,3 +1214,23 @@ void object_property_add_str(Object *obj, const char *name,
                         property_release_str,
                         prop, errp);
 }
+
+static void register_types(void)
+{
+    static TypeInfo interface_info = {
+        .name = TYPE_INTERFACE,
+        .instance_size = sizeof(Interface),
+        .abstract = true,
+    };
+
+    static TypeInfo object_info = {
+        .name = TYPE_OBJECT,
+        .instance_size = sizeof(Object),
+        .abstract = true,
+    };
+
+    type_interface = type_register_static(&interface_info);
+    type_register_static(&object_info);
+}
+
+type_init(register_types)
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 05/25] qom: push type up to Object
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (3 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 04/25] qom: make Object a type Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 12:33   ` Andreas Färber
  2012-04-03 20:55   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 06/25] qdev: fix -device foo,? Paolo Bonzini
                   ` (19 subsequent siblings)
  24 siblings, 2 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Now that Object is a type, add an instance_init function and push
the "type" property from qdev to there.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev.c    |    6 ------
 qom/object.c |   11 +++++++++++
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 0d3c0fc..bb6c1aa 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -510,11 +510,6 @@ char* qdev_get_fw_dev_path(DeviceState *dev)
     return strdup(path);
 }
 
-static char *qdev_get_type(Object *obj, Error **errp)
-{
-    return g_strdup(object_get_typename(obj));
-}
-
 /**
  * Legacy property handling
  */
@@ -630,7 +625,6 @@ static void device_initfn(Object *obj)
         qdev_property_add_static(dev, prop, NULL);
     }
 
-    object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL);
     qdev_prop_set_defaults(dev, qdev_get_props(dev));
 }
 
diff --git a/qom/object.c b/qom/object.c
index 585619d..f3ffaa6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1215,6 +1215,16 @@ void object_property_add_str(Object *obj, const char *name,
                         prop, errp);
 }
 
+static char *qdev_get_type(Object *obj, Error **errp)
+{
+    return g_strdup(object_get_typename(obj));
+}
+
+static void object_instance_init(Object *obj)
+{
+    object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
+}
+
 static void register_types(void)
 {
     static TypeInfo interface_info = {
@@ -1226,6 +1236,7 @@ static void register_types(void)
     static TypeInfo object_info = {
         .name = TYPE_OBJECT,
         .instance_size = sizeof(Object),
+        .instance_init = object_instance_init,
         .abstract = true,
     };
 
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 06/25] qdev: fix -device foo,?
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (4 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 05/25] qom: push type up to Object Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 20:59   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree Paolo Bonzini
                   ` (18 subsequent siblings)
  24 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, aliguori, Jan Kiszka, afaerber

Since most property types do not have a parse property now, this was
broken.  Fix it by looking at the setter instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-monitor.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 4783366..0acfc82 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -157,7 +157,7 @@ int qdev_device_help(QemuOpts *opts)
          * for removal.  This conditional should be removed along with
          * it.
          */
-        if (!prop->info->parse) {
+        if (!prop->info->set) {
             continue;           /* no way to set it, don't show */
         }
         error_printf("%s.%s=%s\n", driver, prop->name,
@@ -165,7 +165,7 @@ int qdev_device_help(QemuOpts *opts)
     }
     if (info->bus_info) {
         for (prop = info->bus_info->props; prop && prop->name; prop++) {
-            if (!prop->info->parse) {
+            if (!prop->info->set) {
                 continue;           /* no way to set it, don't show */
             }
             error_printf("%s.%s=%s\n", driver, prop->name,
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (5 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 06/25] qdev: fix -device foo,? Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 12:28   ` Jan Kiszka
  2012-04-03 21:06   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 08/25] qdev: remove qdev_prop_set_defaults Paolo Bonzini
                   ` (17 subsequent siblings)
  24 siblings, 2 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Jan Kiszka, afaerber

Otherwise, non-string properties without a legacy counterpart are missed.
Also fix error propagation in object_property_print itself, otherwise
pointer properties are printed as "<null>".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-monitor.c |    2 +-
 qom/object.c      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 0acfc82..07ac525 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -492,7 +492,7 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
         if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
             value = object_property_get_str(OBJECT(dev), legacy_name, &err);
         } else {
-            value = object_property_get_str(OBJECT(dev), props->name, &err);
+            value = object_property_print(OBJECT(dev), props->name, &err);
         }
         g_free(legacy_name);
 
diff --git a/qom/object.c b/qom/object.c
index f3ffaa6..ff36946 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -850,7 +850,7 @@ char *object_property_print(Object *obj, const char *name,
     char *string;
 
     mo = string_output_visitor_new();
-    object_property_get(obj, string_output_get_visitor(mo), name, NULL);
+    object_property_get(obj, string_output_get_visitor(mo), name, errp);
     string = string_output_get_string(mo);
     string_output_visitor_cleanup(mo);
     return string;
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 08/25] qdev: remove qdev_prop_set_defaults
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (6 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 21:09   ` Anthony Liguori
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 09/25] qdev: move bus properties to a separate global Paolo Bonzini
                   ` (16 subsequent siblings)
  24 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-properties.c |   22 ----------------------
 hw/qdev.c            |   28 +++++++++++++++++++++++-----
 hw/qdev.h            |    1 -
 3 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index bff9152..85897c7 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -1083,28 +1083,6 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
     *ptr = value;
 }
 
-void qdev_prop_set_defaults(DeviceState *dev, Property *props)
-{
-    Object *obj = OBJECT(dev);
-    if (!props)
-        return;
-    for (; props->name; props++) {
-        Error *errp = NULL;
-        if (props->qtype == QTYPE_NONE) {
-            continue;
-        }
-        if (props->qtype == QTYPE_QBOOL) {
-            object_property_set_bool(obj, props->defval, props->name, &errp);
-        } else if (props->info->enum_table) {
-            object_property_set_str(obj, props->info->enum_table[props->defval],
-                                    props->name, &errp);
-        } else if (props->qtype == QTYPE_QINT) {
-            object_property_set_int(obj, props->defval, props->name, &errp);
-        }
-        assert_no_error(errp);
-    }
-}
-
 static QTAILQ_HEAD(, GlobalProperty) global_props = QTAILQ_HEAD_INITIALIZER(global_props);
 
 static void qdev_prop_register_global(GlobalProperty *prop)
diff --git a/hw/qdev.c b/hw/qdev.c
index bb6c1aa..4ac5616 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -90,7 +90,6 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
         qdev_property_add_legacy(dev, prop, NULL);
         qdev_property_add_static(dev, prop, NULL);
     }
-    qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
 }
 
 /* Create a new device.  This only initializes the device state structure
@@ -592,6 +591,9 @@ void qdev_property_add_legacy(DeviceState *dev, Property *prop,
 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
@@ -601,10 +603,28 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
         return;
     }
 
-    object_property_add(OBJECT(dev), prop->name, prop->info->name,
+    object_property_add(obj, prop->name, prop->info->name,
                         prop->info->get, prop->info->set,
                         prop->info->release,
-                        prop, errp);
+                        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)
@@ -624,8 +644,6 @@ static void device_initfn(Object *obj)
         qdev_property_add_legacy(dev, prop, NULL);
         qdev_property_add_static(dev, prop, NULL);
     }
-
-    qdev_prop_set_defaults(dev, qdev_get_props(dev));
 }
 
 /* Unlink device from bus and free the structure.  */
diff --git a/hw/qdev.h b/hw/qdev.h
index a8df42f..12de112 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -308,7 +308,6 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 /* FIXME: Remove opaque pointer properties.  */
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
-void qdev_prop_set_defaults(DeviceState *dev, Property *props);
 
 void qdev_prop_register_global_list(GlobalProperty *props);
 void qdev_prop_set_globals(DeviceState *dev);
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 09/25] qdev: move bus properties to a separate global
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (7 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 08/25] qdev: remove qdev_prop_set_defaults Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 10/25] qdev: do not propagate properties to subclasses Paolo Bonzini
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Simple code movement in order to simplify future refactoring.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i2c.c                      |   10 ++++++----
 hw/ide/qdev.c                 |   10 ++++++----
 hw/intel-hda.c                |   10 ++++++----
 hw/pci.c                      |   22 ++++++++++++----------
 hw/scsi-bus.c                 |   14 ++++++++------
 hw/spapr_vio.c                |   10 ++++++----
 hw/usb/bus.c                  |   11 +++++++----
 hw/usb/dev-smartcard-reader.c |   10 ++++++----
 hw/virtio-serial-bus.c        |   12 +++++++-----
 9 files changed, 64 insertions(+), 45 deletions(-)

diff --git a/hw/i2c.c b/hw/i2c.c
index 23dfccb..cb10b1d 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -17,13 +17,15 @@ struct i2c_bus
     uint8_t saved_address;
 };
 
+static Property i2c_props[] = {
+    DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static struct BusInfo i2c_bus_info = {
     .name = "I2C",
     .size = sizeof(i2c_bus),
-    .props = (Property[]) {
-        DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0),
-        DEFINE_PROP_END_OF_LIST(),
-    }
+    .props = i2c_props,
 };
 
 static void i2c_bus_pre_save(void *opaque)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index f6a4896..4d372f8 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -27,14 +27,16 @@
 
 static char *idebus_get_fw_dev_path(DeviceState *dev);
 
+static Property ide_props[] = {
+    DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static struct BusInfo ide_bus_info = {
     .name  = "IDE",
     .size  = sizeof(IDEBus),
     .get_fw_dev_path = idebus_get_fw_dev_path,
-    .props = (Property[]) {
-        DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1),
-        DEFINE_PROP_END_OF_LIST(),
-    },
+    .props = ide_props,
 };
 
 void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id)
diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index bb11af2..0994f6b 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -29,13 +29,15 @@
 /* --------------------------------------------------------------------- */
 /* hda bus                                                               */
 
+static Property hda_props[] = {
+    DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1),
+    DEFINE_PROP_END_OF_LIST()
+};
+
 static struct BusInfo hda_codec_bus_info = {
     .name      = "HDA",
     .size      = sizeof(HDACodecBus),
-    .props     = (Property[]) {
-        DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1),
-        DEFINE_PROP_END_OF_LIST()
-    }
+    .props     = hda_props,
 };
 
 void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
diff --git a/hw/pci.c b/hw/pci.c
index ed8ec99..fff4c4a 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -44,6 +44,17 @@ static char *pcibus_get_dev_path(DeviceState *dev);
 static char *pcibus_get_fw_dev_path(DeviceState *dev);
 static int pcibus_reset(BusState *qbus);
 
+static Property pci_props[] = {
+    DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
+    DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
+    DEFINE_PROP_UINT32("rombar",  PCIDevice, rom_bar, 1),
+    DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
+                    QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
+    DEFINE_PROP_BIT("command_serr_enable", PCIDevice, cap_present,
+                    QEMU_PCI_CAP_SERR_BITNR, true),
+    DEFINE_PROP_END_OF_LIST()
+};
+
 struct BusInfo pci_bus_info = {
     .name       = "PCI",
     .size       = sizeof(PCIBus),
@@ -51,16 +62,7 @@ struct BusInfo pci_bus_info = {
     .get_dev_path = pcibus_get_dev_path,
     .get_fw_dev_path = pcibus_get_fw_dev_path,
     .reset      = pcibus_reset,
-    .props      = (Property[]) {
-        DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
-        DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
-        DEFINE_PROP_UINT32("rombar",  PCIDevice, rom_bar, 1),
-        DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
-                        QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
-        DEFINE_PROP_BIT("command_serr_enable", PCIDevice, cap_present,
-                        QEMU_PCI_CAP_SERR_BITNR, true),
-        DEFINE_PROP_END_OF_LIST()
-    }
+    .props      = pci_props,
 };
 
 static void pci_update_mappings(PCIDevice *d);
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 8e76c5d..0352c59 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -12,17 +12,19 @@ static char *scsibus_get_fw_dev_path(DeviceState *dev);
 static int scsi_req_parse(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf);
 static void scsi_req_dequeue(SCSIRequest *req);
 
+static Property scsi_props[] = {
+    DEFINE_PROP_UINT32("channel", SCSIDevice, channel, 0),
+    DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1),
+    DEFINE_PROP_UINT32("lun", SCSIDevice, lun, -1),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static struct BusInfo scsi_bus_info = {
     .name  = "SCSI",
     .size  = sizeof(SCSIBus),
     .get_dev_path = scsibus_get_dev_path,
     .get_fw_dev_path = scsibus_get_fw_dev_path,
-    .props = (Property[]) {
-        DEFINE_PROP_UINT32("channel", SCSIDevice, channel, 0),
-        DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1),
-        DEFINE_PROP_UINT32("lun", SCSIDevice, lun, -1),
-        DEFINE_PROP_END_OF_LIST(),
-    },
+    .props = scsi_props,
 };
 static int next_scsi_bus;
 
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index dbf5a90..941a013 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -49,13 +49,15 @@
     do { } while (0)
 #endif
 
+static Property spapr_vio_props[] = {
+    DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static struct BusInfo spapr_vio_bus_info = {
     .name       = "spapr-vio",
     .size       = sizeof(VIOsPAPRBus),
-    .props = (Property[]) {
-        DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
-        DEFINE_PROP_END_OF_LIST(),
-    },
+    .props      = spapr_vio_props,
 };
 
 VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index d3f8358..0271bc0 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -11,17 +11,20 @@ static char *usb_get_dev_path(DeviceState *dev);
 static char *usb_get_fw_dev_path(DeviceState *qdev);
 static int usb_qdev_exit(DeviceState *qdev);
 
+static Property usb_props[] = {
+    DEFINE_PROP_STRING("port", USBDevice, port_path),
+    DEFINE_PROP_END_OF_LIST()
+};
+
 static struct BusInfo usb_bus_info = {
     .name      = "USB",
     .size      = sizeof(USBBus),
     .print_dev = usb_bus_dev_print,
     .get_dev_path = usb_get_dev_path,
     .get_fw_dev_path = usb_get_fw_dev_path,
-    .props      = (Property[]) {
-        DEFINE_PROP_STRING("port", USBDevice, port_path),
-        DEFINE_PROP_END_OF_LIST()
-    },
+    .props     = usb_props,
 };
+
 static int next_usb_bus = 0;
 static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
 
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 8e66675..4a9cc16 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1055,13 +1055,15 @@ static Answer *ccid_peek_next_answer(USBCCIDState *s)
         : &s->pending_answers[s->pending_answers_start % PENDING_ANSWERS_NUM];
 }
 
+static Property ccid_props[] = {
+    DEFINE_PROP_UINT32("slot", struct CCIDCardState, slot, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static struct BusInfo ccid_bus_info = {
     .name = "ccid-bus",
     .size = sizeof(CCIDBus),
-    .props = (Property[]) {
-        DEFINE_PROP_UINT32("slot", struct CCIDCardState, slot, 0),
-        DEFINE_PROP_END_OF_LIST(),
-    }
+    .props = ccid_props,
 };
 
 void ccid_card_send_apdu_to_guest(CCIDCardState *card,
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index e22940e..703c08d 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -677,15 +677,17 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
 
 static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
 
+static Property virtser_props[] = {
+    DEFINE_PROP_UINT32("nr", VirtIOSerialPort, id, VIRTIO_CONSOLE_BAD_ID),
+    DEFINE_PROP_STRING("name", VirtIOSerialPort, name),
+    DEFINE_PROP_END_OF_LIST()
+};
+
 static struct BusInfo virtser_bus_info = {
     .name      = "virtio-serial-bus",
     .size      = sizeof(VirtIOSerialBus),
     .print_dev = virtser_bus_dev_print,
-    .props      = (Property[]) {
-        DEFINE_PROP_UINT32("nr", VirtIOSerialPort, id, VIRTIO_CONSOLE_BAD_ID),
-        DEFINE_PROP_STRING("name", VirtIOSerialPort, name),
-        DEFINE_PROP_END_OF_LIST()
-    }
+    .props     = virtser_props,
 };
 
 static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 10/25] qdev: do not propagate properties to subclasses
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (8 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 09/25] qdev: move bus properties to a separate global Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 11/25] qdev: pick global properties from superclasses Paolo Bonzini
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

As soon as we'll look up properties along the inheritance chain, we
will have duplicates if class A defines some properties and its
subclass B does not define any, because class_b->props will be
left equal to class_a->props.

The solution here is to reintroduce the class_base_init TypeInfo
callback, that was present in one of the early QOM versions but
removed (on my request...) before committing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/qdev.c b/hw/qdev.c
index 4ac5616..d2b0134 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -671,6 +671,16 @@ static void device_finalize(Object *obj)
     QTAILQ_REMOVE(&dev->parent_bus->children, dev, sibling);
 }
 
+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);
@@ -697,6 +707,7 @@ static TypeInfo device_type_info = {
     .instance_size = sizeof(DeviceState),
     .instance_init = device_initfn,
     .instance_finalize = device_finalize,
+    .class_base_init = device_class_base_init,
     .abstract = true,
     .class_size = sizeof(DeviceClass),
 };
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 11/25] qdev: pick global properties from superclasses
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (9 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 10/25] qdev: do not propagate properties to subclasses Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 12/25] qdev: factor setting of global properties Paolo Bonzini
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

In qdev, each bus in practice identified an abstract superclass, but
this was mostly hidden.  In QOM, instead, these abstract classes are
explicit so we can move bus properties there.

This patch moves global bus properties, an obscure feature when used
with the command-line which is actually useful and used when used by
backwards-compatible machine types.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/pc_piix.c         |   12 ++++++------
 hw/qdev-properties.c |   23 +++++++++++++----------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index fadca4c..8bd6482 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -460,7 +460,7 @@ static QEMUMachine pc_machine_v0_13 = {
             .property = "rombar",
             .value    = stringify(0),
         },{
-            .driver   = "PCI",
+            .driver   = TYPE_PCI_DEVICE,
             .property = "command_serr_enable",
             .value    = "off",
         },{
@@ -520,7 +520,7 @@ static QEMUMachine pc_machine_v0_12 = {
             .property = "rombar",
             .value    = stringify(0),
         },{
-            .driver   = "PCI",
+            .driver   = TYPE_PCI_DEVICE,
             .property = "command_serr_enable",
             .value    = "off",
         },{
@@ -584,11 +584,11 @@ static QEMUMachine pc_machine_v0_11 = {
             .property = "ver",
             .value    = "0.11",
         },{
-            .driver   = "PCI",
+            .driver   = TYPE_PCI_DEVICE,
             .property = "rombar",
             .value    = stringify(0),
         },{
-            .driver   = "PCI",
+            .driver   = TYPE_PCI_DEVICE,
             .property = "command_serr_enable",
             .value    = "off",
         },{
@@ -664,11 +664,11 @@ static QEMUMachine pc_machine_v0_10 = {
             .property = "ver",
             .value    = "0.10",
         },{
-            .driver   = "PCI",
+            .driver   = TYPE_PCI_DEVICE,
             .property = "rombar",
             .value    = stringify(0),
         },{
-            .driver   = "PCI",
+            .driver   = TYPE_PCI_DEVICE,
             .property = "command_serr_enable",
             .value    = "off",
         },{
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 85897c7..a9276f9 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -1101,17 +1101,20 @@ void qdev_prop_register_global_list(GlobalProperty *props)
 
 void qdev_prop_set_globals(DeviceState *dev)
 {
-    GlobalProperty *prop;
-
-    QTAILQ_FOREACH(prop, &global_props, next) {
-        if (strcmp(object_get_typename(OBJECT(dev)), prop->driver) != 0 &&
-            strcmp(qdev_get_bus_info(dev)->name, prop->driver) != 0) {
-            continue;
-        }
-        if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
-            exit(1);
+    ObjectClass *class = object_get_class(OBJECT(dev));
+
+    do {
+        GlobalProperty *prop;
+        QTAILQ_FOREACH(prop, &global_props, next) {
+            if (strcmp(object_class_get_name(class), prop->driver) != 0) {
+                continue;
+            }
+            if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
+                exit(1);
+            }
         }
-    }
+        class = object_class_get_parent(class);
+    } while (class);
 }
 
 static int qdev_add_one_global(QemuOpts *opts, void *opaque)
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 12/25] qdev: factor setting of global properties
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (10 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 11/25] qdev: pick global properties from superclasses Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 13/25] qdev: replace bus properties with superclass properties Paolo Bonzini
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Now that global properties do not depend on buses anymore, set
them directly in the device instance_init function.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-monitor.c |    1 -
 hw/qdev.c         |    2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 07ac525..3d95940 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -448,7 +448,6 @@ DeviceState *qdev_device_add(QemuOpts *opts)
     /* create device, set properties */
     qdev = DEVICE(object_new(driver));
     qdev_set_parent_bus(qdev, bus);
-    qdev_prop_set_globals(qdev);
 
     id = qemu_opts_id(opts);
     if (id) {
diff --git a/hw/qdev.c b/hw/qdev.c
index d2b0134..adef566 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -129,7 +129,6 @@ DeviceState *qdev_try_create(BusState *bus, const char *type)
     }
 
     qdev_set_parent_bus(dev, bus);
-    qdev_prop_set_globals(dev);
 
     return dev;
 }
@@ -644,6 +643,7 @@ static void device_initfn(Object *obj)
         qdev_property_add_legacy(dev, prop, NULL);
         qdev_property_add_static(dev, prop, NULL);
     }
+    qdev_prop_set_globals(dev);
 }
 
 /* Unlink device from bus and free the structure.  */
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 13/25] qdev: replace bus properties with superclass properties
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (11 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 12/25] qdev: factor setting of global properties Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 14/25] qapi: add Visitor interfaces for uint*_t and int*_t Paolo Bonzini
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

After the previous patch, this one changes all bus property walks to
look along the class hierarchy instead.  Bus properties are moved to
abstract classes.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i2c.c                      |    2 +-
 hw/ide/qdev.c                 |    2 +-
 hw/intel-hda.c                |    2 +-
 hw/pci.c                      |    2 +-
 hw/qdev-monitor.c             |   41 ++++++++++++++++++-----------------------
 hw/qdev-properties.c          |   17 +++++++++--------
 hw/qdev.c                     |   32 +++++++++-----------------------
 hw/qdev.h                     |    5 -----
 hw/scsi-bus.c                 |    2 +-
 hw/spapr_vio.c                |    2 +-
 hw/usb/bus.c                  |    2 +-
 hw/usb/dev-smartcard-reader.c |    2 +-
 hw/virtio-serial-bus.c        |    2 +-
 13 files changed, 45 insertions(+), 68 deletions(-)

diff --git a/hw/i2c.c b/hw/i2c.c
index cb10b1d..af5979e 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -25,7 +25,6 @@ static Property i2c_props[] = {
 static struct BusInfo i2c_bus_info = {
     .name = "I2C",
     .size = sizeof(i2c_bus),
-    .props = i2c_props,
 };
 
 static void i2c_bus_pre_save(void *opaque)
@@ -221,6 +220,7 @@ static void i2c_slave_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = i2c_slave_qdev_init;
     k->bus_info = &i2c_bus_info;
+    k->props = i2c_props;
 }
 
 static TypeInfo i2c_slave_type_info = {
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 4d372f8..27ff47c 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -36,7 +36,6 @@ static struct BusInfo ide_bus_info = {
     .name  = "IDE",
     .size  = sizeof(IDEBus),
     .get_fw_dev_path = idebus_get_fw_dev_path,
-    .props = ide_props,
 };
 
 void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id)
@@ -248,6 +247,7 @@ static void ide_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = ide_qdev_init;
     k->bus_info = &ide_bus_info;
+    k->props = ide_props;
 }
 
 static TypeInfo ide_device_type_info = {
diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index 0994f6b..e2bd41e 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -37,7 +37,6 @@ static Property hda_props[] = {
 static struct BusInfo hda_codec_bus_info = {
     .name      = "HDA",
     .size      = sizeof(HDACodecBus),
-    .props     = hda_props,
 };
 
 void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
@@ -1278,6 +1277,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_info = &hda_codec_bus_info;
+    k->props = hda_props;
 }
 
 static TypeInfo hda_codec_device_type_info = {
diff --git a/hw/pci.c b/hw/pci.c
index fff4c4a..4e8e726 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -62,7 +62,6 @@ struct BusInfo pci_bus_info = {
     .get_dev_path = pcibus_get_dev_path,
     .get_fw_dev_path = pcibus_get_fw_dev_path,
     .reset      = pcibus_reset,
-    .props      = pci_props,
 };
 
 static void pci_update_mappings(PCIDevice *d);
@@ -2004,6 +2003,7 @@ static void pci_device_class_init(ObjectClass *klass, void *data)
     k->unplug = pci_unplug_device;
     k->exit = pci_unregister_device;
     k->bus_info = &pci_bus_info;
+    k->props = pci_props;
 }
 
 static TypeInfo pci_device_type_info = {
diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 3d95940..d4fc843 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -122,7 +122,6 @@ int qdev_device_help(QemuOpts *opts)
     const char *driver;
     Property *prop;
     ObjectClass *klass;
-    DeviceClass *info;
 
     driver = qemu_opt_get(opts, "driver");
     if (driver && !strcmp(driver, "?")) {
@@ -148,30 +147,22 @@ int qdev_device_help(QemuOpts *opts)
     if (!klass) {
         return 0;
     }
-    info = DEVICE_CLASS(klass);
-
-    for (prop = info->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
-         * for removal.  This conditional should be removed along with
-         * it.
-         */
-        if (!prop->info->set) {
-            continue;           /* no way to set it, don't show */
-        }
-        error_printf("%s.%s=%s\n", driver, prop->name,
-                     prop->info->legacy_name ?: prop->info->name);
-    }
-    if (info->bus_info) {
-        for (prop = info->bus_info->props; prop && prop->name; prop++) {
+    do {
+        for (prop = DEVICE_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
+             * for removal.  This conditional should be removed along with
+             * it.
+             */
             if (!prop->info->set) {
                 continue;           /* no way to set it, don't show */
             }
             error_printf("%s.%s=%s\n", driver, prop->name,
                          prop->info->legacy_name ?: prop->info->name);
         }
-    }
+        klass = object_class_get_parent(klass);
+    } while (klass != object_class_by_name(TYPE_DEVICE));
     return 1;
 }
 
@@ -480,7 +471,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
 static void qbus_print(Monitor *mon, BusState *bus, int indent);
 
 static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
-                             const char *prefix, int indent)
+                             int indent)
 {
     if (!props)
         return;
@@ -499,7 +490,7 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
             error_free(err);
             continue;
         }
-        qdev_printf("%s-prop: %s = %s\n", prefix, props->name,
+        qdev_printf("%s = %s\n", props->name,
                     value && *value ? value : "<null>");
         g_free(value);
     }
@@ -507,6 +498,7 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
 
 static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
 {
+    ObjectClass *class;
     BusState *child;
     qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev)),
                 dev->id ? dev->id : "");
@@ -517,8 +509,11 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
     if (dev->num_gpio_out) {
         qdev_printf("gpio-out %d\n", dev->num_gpio_out);
     }
-    qdev_print_props(mon, dev, qdev_get_props(dev), "dev", indent);
-    qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent);
+    class = object_get_class(OBJECT(dev));
+    do {
+        qdev_print_props(mon, dev, DEVICE_CLASS(class)->props, indent);
+        class = object_class_get_parent(class);
+    } while (class != object_class_by_name(TYPE_DEVICE));
     if (dev->parent_bus->info->print_dev)
         dev->parent_bus->info->print_dev(mon, dev, indent);
     QLIST_FOREACH(child, &dev->child_bus, sibling) {
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index a9276f9..60fef9a 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -893,17 +893,18 @@ static Property *qdev_prop_walk(Property *props, const char *name)
 
 static Property *qdev_prop_find(DeviceState *dev, const char *name)
 {
+    ObjectClass *class;
     Property *prop;
 
     /* device properties */
-    prop = qdev_prop_walk(qdev_get_props(dev), name);
-    if (prop)
-        return prop;
-
-    /* bus properties */
-    prop = qdev_prop_walk(dev->parent_bus->info->props, name);
-    if (prop)
-        return prop;
+    class = object_get_class(OBJECT(dev));
+    do {
+        prop = qdev_prop_walk(DEVICE_CLASS(class)->props, name);
+        if (prop) {
+            return prop;
+        }
+        class = object_class_get_parent(class);
+    } while (class != object_class_by_name(TYPE_DEVICE));
 
     return NULL;
 }
diff --git a/hw/qdev.c b/hw/qdev.c
index adef566..aeebb86 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -44,18 +44,6 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
     return dc->vmsd;
 }
 
-BusInfo *qdev_get_bus_info(DeviceState *dev)
-{
-    DeviceClass *dc = DEVICE_GET_CLASS(dev);
-    return dc->bus_info;
-}
-
-Property *qdev_get_props(DeviceState *dev)
-{
-    DeviceClass *dc = DEVICE_GET_CLASS(dev);
-    return dc->props;
-}
-
 const char *qdev_fw_name(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
@@ -77,19 +65,12 @@ static void qdev_property_add_legacy(DeviceState *dev, Property *prop,
 
 void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
 {
-    Property *prop;
-
     if (qdev_hotplug) {
         assert(bus->allow_hotplug);
     }
 
     dev->parent_bus = bus;
     QTAILQ_INSERT_HEAD(&bus->children, dev, sibling);
-
-    for (prop = qdev_get_bus_info(dev)->props; prop && prop->name; prop++) {
-        qdev_property_add_legacy(dev, prop, NULL);
-        qdev_property_add_static(dev, prop, NULL);
-    }
 }
 
 /* Create a new device.  This only initializes the device state structure
@@ -629,6 +610,7 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
 static void device_initfn(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
+    ObjectClass *class;
     Property *prop;
 
     if (qdev_hotplug) {
@@ -639,10 +621,14 @@ static void device_initfn(Object *obj)
     dev->instance_id_alias = -1;
     dev->state = DEV_STATE_CREATED;
 
-    for (prop = qdev_get_props(dev); prop && prop->name; prop++) {
-        qdev_property_add_legacy(dev, prop, NULL);
-        qdev_property_add_static(dev, prop, NULL);
-    }
+    class = object_get_class(OBJECT(dev));
+    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);
+        }
+        class = object_class_get_parent(class);
+    } while (class != object_class_by_name(TYPE_DEVICE));
     qdev_prop_set_globals(dev);
 }
 
diff --git a/hw/qdev.h b/hw/qdev.h
index 12de112..aea53c8 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -95,7 +95,6 @@ struct BusInfo {
     bus_get_dev_path get_dev_path;
     bus_get_fw_dev_path get_fw_dev_path;
     qbus_resetfn *reset;
-    Property *props;
 };
 
 struct BusState {
@@ -344,10 +343,6 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 
 const char *qdev_fw_name(DeviceState *dev);
 
-BusInfo *qdev_get_bus_info(DeviceState *dev);
-
-Property *qdev_get_props(DeviceState *dev);
-
 Object *qdev_get_machine(void);
 
 /* FIXME: make this a link<> */
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 0352c59..10f9c63 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -24,7 +24,6 @@ static struct BusInfo scsi_bus_info = {
     .size  = sizeof(SCSIBus),
     .get_dev_path = scsibus_get_dev_path,
     .get_fw_dev_path = scsibus_get_fw_dev_path,
-    .props = scsi_props,
 };
 static int next_scsi_bus;
 
@@ -1575,6 +1574,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;
 }
 
 static TypeInfo scsi_device_type_info = {
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 941a013..897c057 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -57,7 +57,6 @@ static Property spapr_vio_props[] = {
 static struct BusInfo spapr_vio_bus_info = {
     .name       = "spapr-vio",
     .size       = sizeof(VIOsPAPRBus),
-    .props      = spapr_vio_props,
 };
 
 VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
@@ -769,6 +768,7 @@ static void vio_spapr_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = spapr_vio_busdev_init;
     k->bus_info = &spapr_vio_bus_info;
+    k->props = spapr_vio_props;
 }
 
 static TypeInfo spapr_vio_type_info = {
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 0271bc0..12d1be0 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -22,7 +22,6 @@ static struct BusInfo usb_bus_info = {
     .print_dev = usb_bus_dev_print,
     .get_dev_path = usb_get_dev_path,
     .get_fw_dev_path = usb_get_fw_dev_path,
-    .props     = usb_props,
 };
 
 static int next_usb_bus = 0;
@@ -568,6 +567,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;
 }
 
 static TypeInfo usb_device_type_info = {
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 4a9cc16..a38a948 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1063,7 +1063,6 @@ static Property ccid_props[] = {
 static struct BusInfo ccid_bus_info = {
     .name = "ccid-bus",
     .size = sizeof(CCIDBus),
-    .props = ccid_props,
 };
 
 void ccid_card_send_apdu_to_guest(CCIDCardState *card,
@@ -1346,6 +1345,7 @@ static void ccid_card_class_init(ObjectClass *klass, void *data)
     k->bus_info = &ccid_bus_info;
     k->init = ccid_card_init;
     k->exit = ccid_card_exit;
+    k->props = ccid_props;
 }
 
 static TypeInfo ccid_card_type_info = {
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 703c08d..6d49ad6 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -687,7 +687,6 @@ static struct BusInfo virtser_bus_info = {
     .name      = "virtio-serial-bus",
     .size      = sizeof(VirtIOSerialBus),
     .print_dev = virtser_bus_dev_print,
-    .props     = virtser_props,
 };
 
 static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
@@ -940,6 +939,7 @@ static void virtio_serial_port_class_init(ObjectClass *klass, void *data)
     k->bus_info = &virtser_bus_info;
     k->exit = virtser_port_qdev_exit;
     k->unplug = qdev_simple_unplug_cb;
+    k->props = virtser_props;
 }
 
 static TypeInfo virtio_serial_port_type_info = {
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 14/25] qapi: add Visitor interfaces for uint*_t and int*_t
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (12 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 13/25] qdev: replace bus properties with superclass properties Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 15/25] qdev: use int32_t container for devfn property Paolo Bonzini
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber, Michael Roth

From: Michael Roth <mdroth@linux.vnet.ibm.com>

This adds visitor interfaces for fixed-width integers types.
Implementing these in visitors is optional, otherwise we fall back to
visit_type_int() (int64_t) with some additional bounds checking to avoid
integer overflows for cases where the value fetched exceeds the bounds
of our target C type.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/mc146818rtc.c       |    7 ---
 qapi/qapi-visit-core.c |  139 ++++++++++++++++++++++++++++++++++++++++++++++++
 qapi/qapi-visit-core.h |   16 ++++++
 3 files changed, 155 insertions(+), 7 deletions(-)

diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 9c64e0a..3777f85 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -599,13 +599,6 @@ static const MemoryRegionOps cmos_ops = {
     .old_portio = cmos_portio
 };
 
-// FIXME add int32 visitor
-static void visit_type_int32(Visitor *v, int *value, const char *name, Error **errp)
-{
-    int64_t val = *value;
-    visit_type_int(v, &val, name, errp);
-}
-
 static void rtc_get_date(Object *obj, Visitor *v, void *opaque,
                          const char *name, Error **errp)
 {
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index a4e088c..9a29674 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -97,6 +97,145 @@ void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
     }
 }
 
+void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
+{
+    int64_t value;
+    if (!error_is_set(errp)) {
+        if (v->type_uint8) {
+            v->type_uint8(v, obj, name, errp);
+        } else {
+            value = *obj;
+            v->type_int(v, &value, name, errp);
+            if (value > UINT8_MAX) {
+                error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+                          "uint8_t");
+                return;
+            }
+            *obj = value;
+        }
+    }
+}
+
+void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp)
+{
+    int64_t value;
+    if (!error_is_set(errp)) {
+        if (v->type_uint16) {
+            v->type_uint16(v, obj, name, errp);
+        } else {
+            value = *obj;
+            v->type_int(v, &value, name, errp);
+            if (value > UINT16_MAX) {
+                error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+                          "uint16_t");
+                return;
+            }
+            *obj = value;
+        }
+    }
+}
+
+void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp)
+{
+    int64_t value;
+    if (!error_is_set(errp)) {
+        if (v->type_uint32) {
+            v->type_uint32(v, obj, name, errp);
+        } else {
+            value = *obj;
+            v->type_int(v, &value, name, errp);
+            if (value > UINT32_MAX) {
+                error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+                          "uint32_t");
+                return;
+            }
+            *obj = value;
+        }
+    }
+}
+
+void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
+{
+    int64_t value;
+    if (!error_is_set(errp)) {
+        if (v->type_uint64) {
+            v->type_uint64(v, obj, name, errp);
+        } else {
+            value = *obj;
+            v->type_int(v, &value, name, errp);
+            *obj = value;
+        }
+    }
+}
+
+void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
+{
+    int64_t value;
+    if (!error_is_set(errp)) {
+        if (v->type_int8) {
+            v->type_int8(v, obj, name, errp);
+        } else {
+            value = *obj;
+            v->type_int(v, &value, name, errp);
+            if (value < INT8_MIN || value > INT8_MAX) {
+                error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+                          "int8_t");
+                return;
+            }
+            *obj = value;
+        }
+    }
+}
+
+void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)
+{
+    int64_t value;
+    if (!error_is_set(errp)) {
+        if (v->type_int16) {
+            v->type_int16(v, obj, name, errp);
+        } else {
+            value = *obj;
+            v->type_int(v, &value, name, errp);
+            if (value < INT16_MIN || value > INT16_MAX) {
+                error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+                          "int16_t");
+                return;
+            }
+            *obj = value;
+        }
+    }
+}
+
+void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
+{
+    int64_t value;
+    if (!error_is_set(errp)) {
+        if (v->type_int32) {
+            v->type_int32(v, obj, name, errp);
+        } else {
+            value = *obj;
+            v->type_int(v, &value, name, errp);
+            if (value < INT32_MIN || value > INT32_MAX) {
+                error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+                          "int32_t");
+                return;
+            }
+            *obj = value;
+        }
+    }
+}
+
+void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)
+{
+    if (!error_is_set(errp)) {
+        if (v->type_int64) {
+            v->type_int64(v, obj, name, errp);
+        } else {
+            v->type_int(v, obj, name, errp);
+        }
+    }
+}
+
 void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
 {
     if (!error_is_set(errp)) {
diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h
index e850746..a19d70c 100644
--- a/qapi/qapi-visit-core.h
+++ b/qapi/qapi-visit-core.h
@@ -52,6 +52,14 @@ struct Visitor
     void (*start_handle)(Visitor *v, void **obj, const char *kind,
                          const char *name, Error **errp);
     void (*end_handle)(Visitor *v, Error **errp);
+    void (*type_uint8)(Visitor *v, uint8_t *obj, const char *name, Error **errp);
+    void (*type_uint16)(Visitor *v, uint16_t *obj, const char *name, Error **errp);
+    void (*type_uint32)(Visitor *v, uint32_t *obj, const char *name, Error **errp);
+    void (*type_uint64)(Visitor *v, uint64_t *obj, const char *name, Error **errp);
+    void (*type_int8)(Visitor *v, int8_t *obj, const char *name, Error **errp);
+    void (*type_int16)(Visitor *v, int16_t *obj, const char *name, Error **errp);
+    void (*type_int32)(Visitor *v, int32_t *obj, const char *name, Error **errp);
+    void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error **errp);
 };
 
 void visit_start_handle(Visitor *v, void **obj, const char *kind,
@@ -69,6 +77,14 @@ void visit_end_optional(Visitor *v, Error **errp);
 void visit_type_enum(Visitor *v, int *obj, const char *strings[],
                      const char *kind, const char *name, Error **errp);
 void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp);
+void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp);
+void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp);
+void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp);
+void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp);
+void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp);
+void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp);
+void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp);
+void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp);
 void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
 void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
 void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 15/25] qdev: use int32_t container for devfn property
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (13 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 14/25] qapi: add Visitor interfaces for uint*_t and int*_t Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 16/25] qdev: switch property accessors to fixed-width visitor interfaces Paolo Bonzini
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber, Michael Roth

From: Michael Roth <mdroth@linux.vnet.ibm.com>

Valid range for devfn is -1 to 255 (-1 for automatic assignment). We do
not currently validate this due to devfn being stored as a uint32_t.
This can lead to segfaults and other strange behavior.

We could technically just cast it to int32_t to implement the checking,
but this will not work for visitor-based setting where we may do additional
bounds-checking based on target container type, which is int32_t for this
case.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/pci.c             |    2 +-
 hw/pci.h             |    2 +-
 hw/qdev-properties.c |   11 ++++-------
 hw/qdev.h            |    2 +-
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 4e8e726..6910fac 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1539,7 +1539,7 @@ PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
     DeviceState *dev;
 
     dev = qdev_create(&bus->qbus, name);
-    qdev_prop_set_uint32(dev, "addr", devfn);
+    qdev_prop_set_int32(dev, "addr", devfn);
     qdev_prop_set_bit(dev, "multifunction", multifunction);
     return PCI_DEVICE(dev);
 }
diff --git a/hw/pci.h b/hw/pci.h
index 4f19fdb..3edf38a 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -188,7 +188,7 @@ struct PCIDevice {
 
     /* the following fields are read only */
     PCIBus *bus;
-    uint32_t devfn;
+    int32_t devfn;
     char name[64];
     PCIIORegion io_regions[PCI_NUM_REGIONS];
 
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 60fef9a..af7c00a 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -822,7 +822,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
     unsigned int slot, fn, n;
     Error *local_err = NULL;
     char *str = (char *)"";
@@ -855,7 +855,7 @@ invalid:
 
 static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest, size_t len)
 {
-    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
 
     if (*ptr == -1) {
         return snprintf(dest, len, "<unset>");
@@ -870,11 +870,8 @@ PropertyInfo qdev_prop_pci_devfn = {
     .print = print_pci_devfn,
     .get   = get_int32,
     .set   = set_pci_devfn,
-    /* FIXME: this should be -1...255, but the address is stored
-     * into an uint32_t rather than int32_t.
-     */
-    .min   = 0,
-    .max   = 0xFFFFFFFFULL,
+    .min   = -1,
+    .max   = 255,
 };
 
 /* --- public helpers --- */
diff --git a/hw/qdev.h b/hw/qdev.h
index aea53c8..fc18387 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -264,7 +264,7 @@ extern PropertyInfo qdev_prop_pci_devfn;
 #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, uint32_t)
+    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*)
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 16/25] qdev: switch property accessors to fixed-width visitor interfaces
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (14 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 15/25] qdev: use int32_t container for devfn property Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 17/25] qdev: remove PropertyInfo range checking Paolo Bonzini
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber, Michael Roth

From: Michael Roth <mdroth@linux.vnet.ibm.com>

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-addr.c       |    4 +-
 hw/qdev-properties.c |  140 ++++++++++++++++++++++++++++++--------------------
 2 files changed, 87 insertions(+), 57 deletions(-)

diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c
index 0bb16c7..b711b6b 100644
--- a/hw/qdev-addr.c
+++ b/hw/qdev-addr.c
@@ -27,7 +27,7 @@ static void get_taddr(Object *obj, Visitor *v, void *opaque,
     int64_t value;
 
     value = *ptr;
-    visit_type_int(v, &value, name, errp);
+    visit_type_int64(v, &value, name, errp);
 }
 
 static void set_taddr(Object *obj, Visitor *v, void *opaque,
@@ -44,7 +44,7 @@ static void set_taddr(Object *obj, Visitor *v, void *opaque,
         return;
     }
 
-    visit_type_int(v, &value, name, &local_err);
+    visit_type_int64(v, &value, name, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index af7c00a..85d8a11 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -76,33 +76,30 @@ PropertyInfo qdev_prop_bit = {
 
 /* --- 8bit integer --- */
 
-static void get_int8(Object *obj, Visitor *v, void *opaque,
-                     const char *name, Error **errp)
+static void get_uint8(Object *obj, Visitor *v, void *opaque,
+                      const char *name, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int8_t *ptr = qdev_get_prop_ptr(dev, prop);
-    int64_t value;
+    uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
 
-    value = *ptr;
-    visit_type_int(v, &value, name, errp);
+    visit_type_uint8(v, ptr, name, errp);
 }
 
-static void set_int8(Object *obj, Visitor *v, void *opaque,
-                     const char *name, Error **errp)
+static void set_uint8(Object *obj, Visitor *v, void *opaque,
+                      const char *name, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int8_t *ptr = qdev_get_prop_ptr(dev, prop);
+    uint8_t value, *ptr = qdev_get_prop_ptr(dev, prop);
     Error *local_err = NULL;
-    int64_t value;
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_int(v, &value, name, &local_err);
+    visit_type_uint8(v, &value, name, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -111,15 +108,15 @@ static void set_int8(Object *obj, Visitor *v, void *opaque,
         *ptr = value;
     } else {
         error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, value, prop->info->min,
+                  dev->id?:"", name, (int64_t)value, prop->info->min,
                   prop->info->max);
     }
 }
 
 PropertyInfo qdev_prop_uint8 = {
     .name  = "uint8",
-    .get   = get_int8,
-    .set   = set_int8,
+    .get   = get_uint8,
+    .set   = set_uint8,
     .min   = 0,
     .max   = 255,
 };
@@ -154,41 +151,38 @@ PropertyInfo qdev_prop_hex8 = {
     .legacy_name  = "hex8",
     .parse = parse_hex8,
     .print = print_hex8,
-    .get   = get_int8,
-    .set   = set_int8,
+    .get   = get_uint8,
+    .set   = set_uint8,
     .min   = 0,
     .max   = 255,
 };
 
 /* --- 16bit integer --- */
 
-static void get_int16(Object *obj, Visitor *v, void *opaque,
-                      const char *name, Error **errp)
+static void get_uint16(Object *obj, Visitor *v, void *opaque,
+                       const char *name, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int16_t *ptr = qdev_get_prop_ptr(dev, prop);
-    int64_t value;
+    uint16_t *ptr = qdev_get_prop_ptr(dev, prop);
 
-    value = *ptr;
-    visit_type_int(v, &value, name, errp);
+    visit_type_uint16(v, ptr, name, errp);
 }
 
-static void set_int16(Object *obj, Visitor *v, void *opaque,
-                      const char *name, Error **errp)
+static void set_uint16(Object *obj, Visitor *v, void *opaque,
+                       const char *name, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int16_t *ptr = qdev_get_prop_ptr(dev, prop);
+    uint16_t value, *ptr = qdev_get_prop_ptr(dev, prop);
     Error *local_err = NULL;
-    int64_t value;
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_int(v, &value, name, &local_err);
+    visit_type_uint16(v, &value, name, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -197,31 +191,68 @@ static void set_int16(Object *obj, Visitor *v, void *opaque,
         *ptr = value;
     } else {
         error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, value, prop->info->min,
+                  dev->id?:"", name, (int64_t)value, prop->info->min,
                   prop->info->max);
     }
 }
 
 PropertyInfo qdev_prop_uint16 = {
     .name  = "uint16",
-    .get   = get_int16,
-    .set   = set_int16,
+    .get   = get_uint16,
+    .set   = set_uint16,
     .min   = 0,
     .max   = 65535,
 };
 
 /* --- 32bit integer --- */
 
+static void get_uint32(Object *obj, Visitor *v, void *opaque,
+                       const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    uint32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+
+    value = *ptr;
+    visit_type_uint32(v, &value, name, errp);
+}
+
+static void set_uint32(Object *obj, Visitor *v, void *opaque,
+                       const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    uint32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+
+    if (dev->state != DEV_STATE_CREATED) {
+        error_set(errp, QERR_PERMISSION_DENIED);
+        return;
+    }
+
+    visit_type_uint32(v, &value, name, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    if (value >= prop->info->min && value <= prop->info->max) {
+        *ptr = value;
+    } else {
+        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
+                  dev->id?:"", name, (int64_t)value, prop->info->min,
+                  prop->info->max);
+    }
+}
+
 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);
-    int64_t value;
+    int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
 
     value = *ptr;
-    visit_type_int(v, &value, name, errp);
+    visit_type_int32(v, &value, name, errp);
 }
 
 static void set_int32(Object *obj, Visitor *v, void *opaque,
@@ -229,16 +260,15 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+    int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
     Error *local_err = NULL;
-    int64_t value;
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_int(v, &value, name, &local_err);
+    visit_type_int32(v, &value, name, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -247,15 +277,15 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
         *ptr = value;
     } else {
         error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, value, prop->info->min,
+                  dev->id?:"", name, (int64_t)value, prop->info->min,
                   prop->info->max);
     }
 }
 
 PropertyInfo qdev_prop_uint32 = {
     .name  = "uint32",
-    .get   = get_int32,
-    .set   = set_int32,
+    .get   = get_uint32,
+    .set   = set_uint32,
     .min   = 0,
     .max   = 0xFFFFFFFFULL,
 };
@@ -298,43 +328,43 @@ PropertyInfo qdev_prop_hex32 = {
     .legacy_name  = "hex32",
     .parse = parse_hex32,
     .print = print_hex32,
-    .get   = get_int32,
-    .set   = set_int32,
+    .get   = get_uint32,
+    .set   = set_uint32,
     .min   = 0,
     .max   = 0xFFFFFFFFULL,
 };
 
 /* --- 64bit integer --- */
 
-static void get_int64(Object *obj, Visitor *v, void *opaque,
-                      const char *name, Error **errp)
+static void get_uint64(Object *obj, Visitor *v, void *opaque,
+                       const char *name, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+    uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
 
-    visit_type_int(v, ptr, name, errp);
+    visit_type_uint64(v, ptr, name, errp);
 }
 
-static void set_int64(Object *obj, Visitor *v, void *opaque,
-                      const char *name, Error **errp)
+static void set_uint64(Object *obj, Visitor *v, void *opaque,
+                       const char *name, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+    uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_int(v, ptr, name, errp);
+    visit_type_uint64(v, ptr, name, errp);
 }
 
 PropertyInfo qdev_prop_uint64 = {
     .name  = "uint64",
-    .get   = get_int64,
-    .set   = set_int64,
+    .get   = get_uint64,
+    .set   = set_uint64,
 };
 
 /* --- 64bit hex value --- */
@@ -367,8 +397,8 @@ PropertyInfo qdev_prop_hex64 = {
     .legacy_name  = "hex64",
     .parse = parse_hex64,
     .print = print_hex64,
-    .get   = get_int64,
-    .set   = set_int64,
+    .get   = get_uint64,
+    .set   = set_uint64,
 };
 
 /* --- string --- */
@@ -645,7 +675,7 @@ static void get_vlan(Object *obj, Visitor *v, void *opaque,
     int64_t id;
 
     id = *ptr ? (*ptr)->id : -1;
-    visit_type_int(v, &id, name, errp);
+    visit_type_int64(v, &id, name, errp);
 }
 
 static void set_vlan(Object *obj, Visitor *v, void *opaque,
@@ -663,7 +693,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
         return;
     }
 
-    visit_type_int(v, &id, name, &local_err);
+    visit_type_int64(v, &id, name, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 17/25] qdev: remove PropertyInfo range checking
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (15 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 16/25] qdev: switch property accessors to fixed-width visitor interfaces Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 18/25] qdev: remove qdev_prop_exists Paolo Bonzini
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Range checking in PropertyInfo is now used only for pci_devfn
properties.  Move it there, and remove all code that implements
it in the various property types.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-properties.c |  102 ++++++++++++--------------------------------------
 hw/qdev.h            |    2 -
 2 files changed, 24 insertions(+), 80 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 85d8a11..ace81cf 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -91,34 +91,20 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    uint8_t value, *ptr = qdev_get_prop_ptr(dev, prop);
-    Error *local_err = NULL;
+    uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_uint8(v, &value, name, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        return;
-    }
-    if (value >= prop->info->min && value <= prop->info->max) {
-        *ptr = value;
-    } else {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, (int64_t)value, prop->info->min,
-                  prop->info->max);
-    }
+    visit_type_uint8(v, ptr, name, errp);
 }
 
 PropertyInfo qdev_prop_uint8 = {
     .name  = "uint8",
     .get   = get_uint8,
     .set   = set_uint8,
-    .min   = 0,
-    .max   = 255,
 };
 
 /* --- 8bit hex value --- */
@@ -153,8 +139,6 @@ PropertyInfo qdev_prop_hex8 = {
     .print = print_hex8,
     .get   = get_uint8,
     .set   = set_uint8,
-    .min   = 0,
-    .max   = 255,
 };
 
 /* --- 16bit integer --- */
@@ -174,34 +158,20 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    uint16_t value, *ptr = qdev_get_prop_ptr(dev, prop);
-    Error *local_err = NULL;
+    uint16_t *ptr = qdev_get_prop_ptr(dev, prop);
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_uint16(v, &value, name, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        return;
-    }
-    if (value >= prop->info->min && value <= prop->info->max) {
-        *ptr = value;
-    } else {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, (int64_t)value, prop->info->min,
-                  prop->info->max);
-    }
+    visit_type_uint16(v, ptr, name, errp);
 }
 
 PropertyInfo qdev_prop_uint16 = {
     .name  = "uint16",
     .get   = get_uint16,
     .set   = set_uint16,
-    .min   = 0,
-    .max   = 65535,
 };
 
 /* --- 32bit integer --- */
@@ -211,10 +181,9 @@ static void get_uint32(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    uint32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
 
-    value = *ptr;
-    visit_type_uint32(v, &value, name, errp);
+    visit_type_uint32(v, ptr, name, errp);
 }
 
 static void set_uint32(Object *obj, Visitor *v, void *opaque,
@@ -222,26 +191,14 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    uint32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
-    Error *local_err = NULL;
+    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_uint32(v, &value, name, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        return;
-    }
-    if (value >= prop->info->min && value <= prop->info->max) {
-        *ptr = value;
-    } else {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, (int64_t)value, prop->info->min,
-                  prop->info->max);
-    }
+    visit_type_uint32(v, ptr, name, errp);
 }
 
 static void get_int32(Object *obj, Visitor *v, void *opaque,
@@ -249,10 +206,9 @@ static void get_int32(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
 
-    value = *ptr;
-    visit_type_int32(v, &value, name, errp);
+    visit_type_int32(v, ptr, name, errp);
 }
 
 static void set_int32(Object *obj, Visitor *v, void *opaque,
@@ -260,42 +216,26 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
-    Error *local_err = NULL;
+    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
 
     if (dev->state != DEV_STATE_CREATED) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
 
-    visit_type_int32(v, &value, name, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        return;
-    }
-    if (value >= prop->info->min && value <= prop->info->max) {
-        *ptr = value;
-    } else {
-        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
-                  dev->id?:"", name, (int64_t)value, prop->info->min,
-                  prop->info->max);
-    }
+    visit_type_int32(v, ptr, name, errp);
 }
 
 PropertyInfo qdev_prop_uint32 = {
     .name  = "uint32",
     .get   = get_uint32,
     .set   = set_uint32,
-    .min   = 0,
-    .max   = 0xFFFFFFFFULL,
 };
 
 PropertyInfo qdev_prop_int32 = {
     .name  = "int32",
     .get   = get_int32,
     .set   = set_int32,
-    .min   = -0x80000000LL,
-    .max   = 0x7FFFFFFFLL,
 };
 
 /* --- 32bit hex value --- */
@@ -330,8 +270,6 @@ PropertyInfo qdev_prop_hex32 = {
     .print = print_hex32,
     .get   = get_uint32,
     .set   = set_uint32,
-    .min   = 0,
-    .max   = 0xFFFFFFFFULL,
 };
 
 /* --- 64bit integer --- */
@@ -852,7 +790,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
 {
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+    int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
     unsigned int slot, fn, n;
     Error *local_err = NULL;
     char *str = (char *)"";
@@ -864,7 +802,17 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
 
     visit_type_str(v, &str, name, &local_err);
     if (local_err) {
-        return set_int32(obj, v, opaque, name, errp);
+        local_err = NULL;
+        visit_type_int32(v, &value, name, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+        } else if (value < -1 || value > 255) {
+            error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+                      "pci_devfn");
+        } else {
+            *ptr = value;
+        }
+        return;
     }
 
     if (sscanf(str, "%x.%x%n", &slot, &fn, &n) != 2) {
@@ -900,8 +848,6 @@ PropertyInfo qdev_prop_pci_devfn = {
     .print = print_pci_devfn,
     .get   = get_int32,
     .set   = set_pci_devfn,
-    .min   = -1,
-    .max   = 255,
 };
 
 /* --- public helpers --- */
diff --git a/hw/qdev.h b/hw/qdev.h
index fc18387..dfff93a 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -120,8 +120,6 @@ struct PropertyInfo {
     const char *name;
     const char *legacy_name;
     const char **enum_table;
-    int64_t min;
-    int64_t max;
     int (*parse)(DeviceState *dev, Property *prop, const char *str);
     int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
     ObjectPropertyAccessor *get;
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 18/25] qdev: remove qdev_prop_exists
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (16 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 17/25] qdev: remove PropertyInfo range checking Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 19/25] qom: push state up to Object Paolo Bonzini
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Can be replaced everywhere with object_property_find.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-properties.c  |    5 -----
 hw/qdev.c             |    2 +-
 hw/qdev.h             |    1 -
 hw/scsi-bus.c         |    2 +-
 include/qemu/object.h |    9 +++++++++
 qom/object.c          |    2 +-
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index ace81cf..ffd601a 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -882,11 +882,6 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
     return NULL;
 }
 
-int qdev_prop_exists(DeviceState *dev, const char *name)
-{
-    return qdev_prop_find(dev, name) ? true : false;
-}
-
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
                                     Property *prop, const char *value)
 {
diff --git a/hw/qdev.c b/hw/qdev.c
index aeebb86..9e7a4b7 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -295,7 +295,7 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
     if (nd->netdev)
         qdev_prop_set_netdev(dev, "netdev", nd->netdev);
     if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
-        qdev_prop_exists(dev, "vectors")) {
+        object_property_find(OBJECT(dev), "vectors")) {
         qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
     }
     nd->instantiated = 1;
diff --git a/hw/qdev.h b/hw/qdev.h
index dfff93a..a159b94 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -287,7 +287,6 @@ extern PropertyInfo qdev_prop_pci_devfn;
 
 /* Set properties between creation and init.  */
 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
-int qdev_prop_exists(DeviceState *dev, const char *name);
 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);
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 10f9c63..2777566 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -206,7 +206,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
     if (bootindex >= 0) {
         qdev_prop_set_int32(dev, "bootindex", bootindex);
     }
-    if (qdev_prop_exists(dev, "removable")) {
+    if (object_property_find(OBJECT(dev), "removable")) {
         qdev_prop_set_bit(dev, "removable", removable);
     }
     if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
diff --git a/include/qemu/object.h b/include/qemu/object.h
index 22f646d..80f2bf3 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -637,6 +637,15 @@ void object_property_add(Object *obj, const char *name, const char *type,
 
 void object_property_del(Object *obj, const char *name, struct Error **errp);
 
+/**
+ * object_property_find:
+ * @obj: the object
+ * @name: the name of the property
+ *
+ * Look up a property for an object and return its #ObjectProperty if found.
+ */
+ObjectProperty *object_property_find(Object *obj, const char *name);
+
 void object_unparent(Object *obj);
 
 /**
diff --git a/qom/object.c b/qom/object.c
index ff36946..488047c 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -656,7 +656,7 @@ void object_property_add(Object *obj, const char *name, const char *type,
     QTAILQ_INSERT_TAIL(&obj->properties, prop, node);
 }
 
-static ObjectProperty *object_property_find(Object *obj, const char *name)
+ObjectProperty *object_property_find(Object *obj, const char *name)
 {
     ObjectProperty *prop;
 
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 19/25] qom: push state up to Object
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (17 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 18/25] qdev: remove qdev_prop_exists Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 20/25] qdev: generalize properties to Objects Paolo Bonzini
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

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 <pbonzini@redhat.com>
---
 hw/qdev-addr.c        |    3 ++-
 hw/qdev-properties.c  |   24 ++++++++++++------------
 hw/qdev.c             |   11 +++++------
 hw/qdev.h             |    6 ------
 include/qemu/object.h |   14 ++++++++++++++
 qom/object.c          |    6 ++++++
 6 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c
index b711b6b..a3796bd 100644
--- a/hw/qdev-addr.c
+++ b/hw/qdev-addr.c
@@ -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;
     }
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index ffd601a..282cf68 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -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;
     }
@@ -764,7 +764,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;
     }
@@ -795,7 +795,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
     Error *local_err = NULL;
     char *str = (char *)"";
 
-    if (dev->state != DEV_STATE_CREATED) {
+    if (object_is_realized(obj)) {
         error_set(errp, QERR_PERMISSION_DENIED);
         return;
     }
diff --git a/hw/qdev.c b/hw/qdev.c
index 9e7a4b7..12752e9 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -124,7 +124,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) {
@@ -146,7 +146,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);
     }
@@ -156,7 +156,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;
 }
@@ -515,7 +515,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;
     }
@@ -619,7 +619,6 @@ static void device_initfn(Object *obj)
     }
 
     dev->instance_id_alias = -1;
-    dev->state = DEV_STATE_CREATED;
 
     class = object_get_class(OBJECT(dev));
     do {
@@ -639,7 +638,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);
diff --git a/hw/qdev.h b/hw/qdev.h
index a159b94..a21633b 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -18,11 +18,6 @@ typedef struct BusState BusState;
 
 typedef struct BusInfo BusInfo;
 
-enum DevState {
-    DEV_STATE_CREATED = 1,
-    DEV_STATE_INITIALIZED,
-};
-
 enum {
     DEV_NVECTORS_UNSPECIFIED = -1,
 };
@@ -63,7 +58,6 @@ struct DeviceState {
     Object parent_obj;
 
     const char *id;
-    enum DevState state;
     QemuOpts *opts;
     int hotplugged;
     BusState *parent_bus;
diff --git a/include/qemu/object.h b/include/qemu/object.h
index 80f2bf3..a7e5fc2 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -241,6 +241,11 @@ struct ObjectClass
     Type type;
 };
 
+typedef enum ObjectState {
+    OBJECT_STATE_CREATED = 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
diff --git a/qom/object.c b/qom/object.c
index 488047c..65eaa84 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1220,9 +1220,15 @@ 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);
+    obj->state = OBJECT_STATE_CREATED;
 }
 
 static void register_types(void)
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 20/25] qdev: generalize properties to Objects
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (18 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 19/25] qom: push state up to Object Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 21/25] qdev: move bulk of qdev-properties.c to qom/object.c Paolo Bonzini
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

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 <pbonzini@redhat.com>
---
 hw/qdev-addr.c       |   19 +++---
 hw/qdev-properties.c |  173 +++++++++++++++++++++-----------------------------
 hw/qdev.c            |    8 +--
 hw/qdev.h            |   10 +--
 4 files changed, 90 insertions(+), 120 deletions(-)

diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c
index a3796bd..99ca116 100644
--- a/hw/qdev-addr.c
+++ b/hw/qdev-addr.c
@@ -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");
     }
 }
 
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 282cf68..59b9615 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -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 len
 static 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 ? print(*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;
@@ -724,7 +702,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);
 }
 
 PropertyInfo qdev_prop_macaddr = {
@@ -749,9 +727,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);
@@ -760,9 +737,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);
@@ -788,9 +764,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 = (char *)"";
@@ -828,12 +803,12 @@ 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);
 }
 
-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>");
@@ -864,13 +839,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) {
@@ -882,22 +857,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_typename(OBJECT(dev)), prop->name, value);
+                  object_get_typename(obj), prop->name, value);
         break;
     default:
     case -EINVAL:
         error_set(errp, QERR_PROPERTY_VALUE_BAD,
-                  object_get_typename(OBJECT(dev)), prop->name, value);
+                  object_get_typename(obj), prop->name, value);
         break;
     case -ENOENT:
         error_set(errp, QERR_PROPERTY_VALUE_NOT_FOUND,
-                  object_get_typename(OBJECT(dev)), prop->name, value);
+                  object_get_typename(obj), prop->name, value);
         break;
     case 0:
         break;
@@ -1035,7 +1010,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);
@@ -1046,9 +1021,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;
 }
 
diff --git a/hw/qdev.c b/hw/qdev.c
index 12752e9..86162fc 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -496,20 +496,18 @@ char* qdev_get_fw_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->print(dev, prop, buffer, sizeof(buffer));
+    prop->info->print(obj, prop, buffer, 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;
@@ -526,8 +524,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);
 }
 
diff --git a/hw/qdev.h b/hw/qdev.h
index a21633b..eb421af 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -114,8 +114,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;
@@ -280,7 +280,7 @@ extern PropertyInfo qdev_prop_pci_devfn;
     {}
 
 /* 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);
@@ -301,8 +301,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);
 
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 21/25] qdev: move bulk of qdev-properties.c to qom/object.c
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (19 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 20/25] qdev: generalize properties to Objects Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 22/25] qom: push static properties to Object Paolo Bonzini
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-properties.c  |  476 ++++---------------------------------------------
 hw/qdev.c             |   47 +----
 hw/qdev.h             |   87 ---------
 include/qemu/object.h |   98 ++++++++++
 qom/object.c          |  459 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 594 insertions(+), 573 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 59b9615..bea57e9 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -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_typename(obj), prop->name, value);
+        break;
+    default:
+    case -EINVAL:
+        error_set(errp, QERR_PROPERTY_VALUE_BAD,
+                  object_get_typename(obj), prop->name, value);
+        break;
+    case -ENOENT:
+        error_set(errp, QERR_PROPERTY_VALUE_NOT_FOUND,
+                  object_get_typename(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 --- */
 
 /*
@@ -711,6 +339,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 --- */
 
@@ -724,40 +358,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"
  */
@@ -821,7 +439,7 @@ 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,
 };
 
@@ -857,28 +475,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_typename(obj), prop->name, value);
-        break;
-    default:
-    case -EINVAL:
-        error_set(errp, QERR_PROPERTY_VALUE_BAD,
-                  object_get_typename(obj), prop->name, value);
-        break;
-    case -ENOENT:
-        error_set(errp, QERR_PROPERTY_VALUE_NOT_FOUND,
-                  object_get_typename(obj), prop->name, value);
-        break;
-    case 0:
-        break;
-    }
-}
-
 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
 {
     char *legacy_name;
diff --git a/hw/qdev.c b/hw/qdev.c
index 86162fc..813f27e 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -560,51 +560,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);
@@ -622,7 +577,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));
diff --git a/hw/qdev.h b/hw/qdev.h
index eb421af..d2596fe 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -8,10 +8,6 @@
 #include "qapi/qapi-visit-core.h"
 #include "qemu/object.h"
 
-typedef struct Property Property;
-
-typedef struct PropertyInfo PropertyInfo;
-
 typedef struct CompatProperty CompatProperty;
 
 typedef struct BusState BusState;
@@ -101,26 +97,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;
@@ -196,16 +172,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;
@@ -215,55 +181,12 @@ extern PropertyInfo qdev_prop_netdev;
 extern PropertyInfo qdev_prop_vlan;
 extern PropertyInfo qdev_prop_pci_devfn;
 
-#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)             \
@@ -276,11 +199,7 @@ extern PropertyInfo qdev_prop_pci_devfn;
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
                         LostTickPolicy)
 
-#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);
@@ -310,12 +229,6 @@ char *qdev_get_fw_dev_path(DeviceState *dev);
 extern struct BusInfo system_bus_info;
 
 /**
- * @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
diff --git a/include/qemu/object.h b/include/qemu/object.h
index a7e5fc2..f60b6b6 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -970,4 +970,102 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
  */
 Object *container_get(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);
+
+/**
+ * qdev_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 a device referencing a field in a struct.
+ */
+void object_property_add_static(Object *obj, Property *prop,
+                                struct Error **errp);
+
 #endif
diff --git a/qom/object.c b/qom/object.c
index 65eaa84..28186d7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1251,3 +1251,462 @@ static void register_types(void)
 }
 
 type_init(register_types)
+\f

+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);
+}
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 22/25] qom: push static properties to Object
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (20 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 21/25] qdev: move bulk of qdev-properties.c to qom/object.c Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 23/25] qom: add realized property Paolo Bonzini
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

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 <pbonzini@redhat.com>
---
 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_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                |    4 ++--
 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/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         |    9 ++++++---
 qom/object.c                  |   20 ++++++++++++++++++++
 142 files changed, 202 insertions(+), 227 deletions(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index b8220ab..83e1495 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -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;
 }
 
diff --git a/hw/a15mpcore.c b/hw/a15mpcore.c
index 71142e5..ed5b663 100644
--- a/hw/a15mpcore.c
+++ b/hw/a15mpcore.c
@@ -81,10 +81,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 outside the common GIC state */
 }
 
diff --git a/hw/a9mpcore.c b/hw/a9mpcore.c
index 03b128c..45eaa74 100644
--- a/hw/a9mpcore.c
+++ b/hw/a9mpcore.c
@@ -226,7 +226,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;
 }
diff --git a/hw/ac97.c b/hw/ac97.c
index c0fd019..d994924 100644
--- a/hw/ac97.c
+++ b/hw/ac97.c
@@ -1362,7 +1362,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 = {
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 797ed24..74fa6b0 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -412,7 +412,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 = {
diff --git a/hw/apic_common.c b/hw/apic_common.c
index 60b8259..9774cf6 100644
--- a/hw/apic_common.c
+++ b/hw/apic_common.c
@@ -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;
 }
 
diff --git a/hw/applesmc.c b/hw/applesmc.c
index 8bedaad..b8f1855 100644
--- a/hw/applesmc.c
+++ b/hw/applesmc.c
@@ -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 = {
diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
index ba6a89d..ad68817 100644
--- a/hw/arm11mpcore.c
+++ b/hw/arm11mpcore.c
@@ -206,11 +206,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 = {
@@ -236,11 +235,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 = {
diff --git a/hw/arm_l2x0.c b/hw/arm_l2x0.c
index 09f290c..1e5fed9 100644
--- a/hw/arm_l2x0.c
+++ b/hw/arm_l2x0.c
@@ -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;
 }
 
diff --git a/hw/arm_mptimer.c b/hw/arm_mptimer.c
index df7fb4c..c55d06f 100644
--- a/hw/arm_mptimer.c
+++ b/hw/arm_mptimer.c
@@ -323,7 +323,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 = {
diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c
index 5f1237b..7aa449c 100644
--- a/hw/arm_sysctl.c
+++ b/hw/arm_sysctl.c
@@ -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 = {
diff --git a/hw/arm_timer.c b/hw/arm_timer.c
index e3ecce2..d14166a 100644
--- a/hw/arm_timer.c
+++ b/hw/arm_timer.c
@@ -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 = {
diff --git a/hw/armv7m.c b/hw/armv7m.c
index 4aac076..784e2ff 100644
--- a/hw/armv7m.c
+++ b/hw/armv7m.c
@@ -252,11 +252,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 = {
diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c
index 3210129..b054d3f 100644
--- a/hw/armv7m_nvic.c
+++ b/hw/armv7m_nvic.c
@@ -407,7 +407,7 @@ static void armv7m_nvic_class_init(ObjectClass *klass, void *data)
 
     sdc->init = armv7m_nvic_init;
     dc->vmsd  = &vmstate_nvic;
-    dc->props = armv7m_nvic_properties;
+    klass->props = armv7m_nvic_properties;
 }
 
 static TypeInfo armv7m_nvic_info = {
diff --git a/hw/cadence_gem.c b/hw/cadence_gem.c
index e2140ae..a065168 100644
--- a/hw/cadence_gem.c
+++ b/hw/cadence_gem.c
@@ -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;
 }
diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c
index f4a6da4..db27ec5 100644
--- a/hw/ccid-card-emulated.c
+++ b/hw/ccid-card-emulated.c
@@ -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 = {
diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c
index bd6c777..856ee19 100644
--- a/hw/ccid-card-passthru.c
+++ b/hw/ccid-card-passthru.c
@@ -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 = {
diff --git a/hw/cs4231.c b/hw/cs4231.c
index cfec1d9..06467cd 100644
--- a/hw/cs4231.c
+++ b/hw/cs4231.c
@@ -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 = {
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index e07b9d6..7e4d03c 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -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 = {
diff --git a/hw/debugcon.c b/hw/debugcon.c
index 14ab326..4dffebd 100644
--- a/hw/debugcon.c
+++ b/hw/debugcon.c
@@ -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 = {
diff --git a/hw/ds1225y.c b/hw/ds1225y.c
index 2cd355b..d3d349c 100644
--- a/hw/ds1225y.c
+++ b/hw/ds1225y.c
@@ -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 = {
diff --git a/hw/e1000.c b/hw/e1000.c
index 7babc0b..7315698 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1217,7 +1217,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 = {
diff --git a/hw/eccmemctl.c b/hw/eccmemctl.c
index fe1cd90..82e4a4d 100644
--- a/hw/eccmemctl.c
+++ b/hw/eccmemctl.c
@@ -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 = {
diff --git a/hw/eepro100.c b/hw/eepro100.c
index e3ba719..0690654 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -2076,7 +2076,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;
diff --git a/hw/escc.c b/hw/escc.c
index 4d8a8e8..16ef823 100644
--- a/hw/escc.c
+++ b/hw/escc.c
@@ -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 = {
diff --git a/hw/esp.c b/hw/esp.c
index 8d73e56..b20d6a3 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -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 = {
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index 16a0637..30ad08e 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -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 = {
diff --git a/hw/etraxfs_pic.c b/hw/etraxfs_pic.c
index dc27f88..ad8c537 100644
--- a/hw/etraxfs_pic.c
+++ b/hw/etraxfs_pic.c
@@ -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 = {
diff --git a/hw/exynos4210_combiner.c b/hw/exynos4210_combiner.c
index 6110c19..a16c35d 100644
--- a/hw/exynos4210_combiner.c
+++ b/hw/exynos4210_combiner.c
@@ -450,7 +450,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;
 }
 
diff --git a/hw/exynos4210_gic.c b/hw/exynos4210_gic.c
index ec13140..7297dbc 100644
--- a/hw/exynos4210_gic.c
+++ b/hw/exynos4210_gic.c
@@ -333,11 +333,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 = {
diff --git a/hw/exynos4210_uart.c b/hw/exynos4210_uart.c
index 73a9c18..791f1c5 100644
--- a/hw/exynos4210_uart.c
+++ b/hw/exynos4210_uart.c
@@ -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;
 }
 
diff --git a/hw/fdc.c b/hw/fdc.c
index a0236b7..146dcab 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -2064,7 +2064,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 = {
@@ -2098,7 +2098,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 = {
@@ -2121,7 +2121,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 = {
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 7b3b576..5c3a388 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -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 = {
diff --git a/hw/g364fb.c b/hw/g364fb.c
index 3a0b68f..597f004 100644
--- a/hw/g364fb.c
+++ b/hw/g364fb.c
@@ -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 = {
diff --git a/hw/grlib_apbuart.c b/hw/grlib_apbuart.c
index 73fc989..f64747d 100644
--- a/hw/grlib_apbuart.c
+++ b/hw/grlib_apbuart.c
@@ -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 = {
diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c
index 41770a9..c44b1fd 100644
--- a/hw/grlib_gptimer.c
+++ b/hw/grlib_gptimer.c
@@ -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 = {
diff --git a/hw/grlib_irqmp.c b/hw/grlib_irqmp.c
index 0f6e65c..3bbfcec 100644
--- a/hw/grlib_irqmp.c
+++ b/hw/grlib_irqmp.c
@@ -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 = {
diff --git a/hw/gus.c b/hw/gus.c
index 840d098..1bc81a9 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -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 = {
diff --git a/hw/hda-audio.c b/hw/hda-audio.c
index 8995519..de33422 100644
--- a/hw/hda-audio.c
+++ b/hw/hda-audio.c
@@ -917,7 +917,7 @@ static void hda_audio_output_class_init(ObjectClass *klass, void *data)
     k->stream = hda_audio_stream;
     dc->desc = "HDA Audio Codec, output-only";
     dc->vmsd = &vmstate_hda_audio;
-    dc->props = hda_audio_properties;
+    klass->props = hda_audio_properties;
 }
 
 static TypeInfo hda_audio_output_info = {
@@ -938,7 +938,7 @@ static void hda_audio_duplex_class_init(ObjectClass *klass, void *data)
     k->stream = hda_audio_stream;
     dc->desc = "HDA Audio Codec, duplex";
     dc->vmsd = &vmstate_hda_audio;
-    dc->props = hda_audio_properties;
+    klass->props = hda_audio_properties;
 }
 
 static TypeInfo hda_audio_duplex_info = {
diff --git a/hw/hpet.c b/hw/hpet.c
index fd3ddca..126e78b 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -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 = {
diff --git a/hw/i2c.c b/hw/i2c.c
index af5979e..5b3d9a0 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -220,7 +220,7 @@ static void i2c_slave_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = i2c_slave_qdev_init;
     k->bus_info = &i2c_bus_info;
-    k->props = i2c_props;
+    klass->props = i2c_props;
 }
 
 static TypeInfo i2c_slave_type_info = {
diff --git a/hw/i82374.c b/hw/i82374.c
index 67298a3..99daf34 100644
--- a/hw/i82374.c
+++ b/hw/i82374.c
@@ -147,7 +147,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 = {
diff --git a/hw/i82378.c b/hw/i82378.c
index faad1a3..aa6f275 100644
--- a/hw/i82378.c
+++ b/hw/i82378.c
@@ -259,7 +259,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 = {
diff --git a/hw/i8254.c b/hw/i8254.c
index 77bd5e8..9be9dbc 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -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 = {
diff --git a/hw/i8259_common.c b/hw/i8259_common.c
index ab3d98b..a91d1e5 100644
--- a/hw/i8259_common.c
+++ b/hw/i8259_common.c
@@ -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;
 }
 
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index a883a92..dc87c34 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -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 = {
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index bf8ece4..ab4cfdd 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -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 = {
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 8ab2718..c2faba9 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -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 = {
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 27ff47c..87ff2fe 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -188,7 +188,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 = {
@@ -210,7 +210,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 = {
@@ -232,7 +232,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 = {
@@ -247,7 +247,7 @@ static void ide_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = ide_qdev_init;
     k->bus_info = &ide_bus_info;
-    k->props = ide_props;
+    klass->props = ide_props;
 }
 
 static TypeInfo ide_device_type_info = {
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 9bdb9e6..3dd8661 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -524,11 +524,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 = {
diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index e2bd41e..f343603 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -1261,7 +1261,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 = {
@@ -1277,7 +1277,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_info = &hda_codec_bus_info;
-    k->props = hda_props;
+    klass->props = hda_props;
 }
 
 static TypeInfo hda_codec_device_type_info = {
diff --git a/hw/ioh3420.c b/hw/ioh3420.c
index 1632d31..cfb8507 100644
--- a/hw/ioh3420.c
+++ b/hw/ioh3420.c
@@ -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 = {
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index 64e1cd9..3aecbe2 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -788,7 +788,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 = {
diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c
index bb5fe07..9e7dba9 100644
--- a/hw/kvm/i8254.c
+++ b/hw/kvm/i8254.c
@@ -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 = {
diff --git a/hw/kvm/ioapic.c b/hw/kvm/ioapic.c
index 3ae3175..d57b11b 100644
--- a/hw/kvm/ioapic.c
+++ b/hw/kvm/ioapic.c
@@ -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 = {
diff --git a/hw/lan9118.c b/hw/lan9118.c
index 7b4fe87..dbefefb 100644
--- a/hw/lan9118.c
+++ b/hw/lan9118.c
@@ -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;
 }
 
diff --git a/hw/lance.c b/hw/lance.c
index ce3d46c..a7e3dca 100644
--- a/hw/lance.c
+++ b/hw/lance.c
@@ -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 = {
diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c
index bbe03c4..99fef79 100644
--- a/hw/lm32_sys.c
+++ b/hw/lm32_sys.c
@@ -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 = {
diff --git a/hw/lm32_timer.c b/hw/lm32_timer.c
index e9450a0..f3a20ff 100644
--- a/hw/lm32_timer.c
+++ b/hw/lm32_timer.c
@@ -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 = {
diff --git a/hw/m48t59.c b/hw/m48t59.c
index 60bbb00..3f368f2 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -734,7 +734,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 = {
@@ -758,7 +758,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 = {
diff --git a/hw/marvell_88w8618_audio.c b/hw/marvell_88w8618_audio.c
index f6f1937..9cb70f2 100644
--- a/hw/marvell_88w8618_audio.c
+++ b/hw/marvell_88w8618_audio.c
@@ -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 = {
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 3777f85..9c9b23c 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -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 = {
diff --git a/hw/milkymist-minimac2.c b/hw/milkymist-minimac2.c
index 70bf336..5bdb5e5 100644
--- a/hw/milkymist-minimac2.c
+++ b/hw/milkymist-minimac2.c
@@ -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 = {
diff --git a/hw/milkymist-softusb.c b/hw/milkymist-softusb.c
index ecc2be9..e44d007 100644
--- a/hw/milkymist-softusb.c
+++ b/hw/milkymist-softusb.c
@@ -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 = {
diff --git a/hw/milkymist-sysctl.c b/hw/milkymist-sysctl.c
index 8878d2b..6caabd9 100644
--- a/hw/milkymist-sysctl.c
+++ b/hw/milkymist-sysctl.c
@@ -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 = {
diff --git a/hw/milkymist-vgafb.c b/hw/milkymist-vgafb.c
index cd4365d..7cf00ef 100644
--- a/hw/milkymist-vgafb.c
+++ b/hw/milkymist-vgafb.c
@@ -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 = {
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index 3107246..50876bc 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -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 = {
diff --git a/hw/musicpal.c b/hw/musicpal.c
index c9f845a..7f186a9 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -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 = {
diff --git a/hw/nand.c b/hw/nand.c
index e9501ae..460f2fe 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -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 = {
diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
index a4a783a..a38da68 100644
--- a/hw/ne2000-isa.c
+++ b/hw/ne2000-isa.c
@@ -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 = {
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 71452e1..7bb83da 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -795,7 +795,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 = {
diff --git a/hw/omap_gpio.c b/hw/omap_gpio.c
index 201ff77..b4fba0b 100644
--- a/hw/omap_gpio.c
+++ b/hw/omap_gpio.c
@@ -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 = {
diff --git a/hw/omap_i2c.c b/hw/omap_i2c.c
index 20bc82e..280c622 100644
--- a/hw/omap_i2c.c
+++ b/hw/omap_i2c.c
@@ -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;
 }
 
diff --git a/hw/omap_intc.c b/hw/omap_intc.c
index 5076e07..7f98a3e 100644
--- a/hw/omap_intc.c
+++ b/hw/omap_intc.c
@@ -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 = {
diff --git a/hw/onenand.c b/hw/onenand.c
index db6af68..05126dc 100644
--- a/hw/onenand.c
+++ b/hw/onenand.c
@@ -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 = {
diff --git a/hw/opencores_eth.c b/hw/opencores_eth.c
index 4c76969..bf26bf8 100644
--- a/hw/opencores_eth.c
+++ b/hw/opencores_eth.c
@@ -740,7 +740,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 = {
diff --git a/hw/parallel.c b/hw/parallel.c
index 219f384..f3fdbdb 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -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 = {
diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index abf9004..7bad61e 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -235,7 +235,7 @@ static void pcsysfw_class_init (ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS (klass);
 
     dc->desc = "PC System Firmware";
-    dc->props = pcsysfw_properties;
+    klass->props = pcsysfw_properties;
 }
 
 static TypeInfo pcsysfw_info = {
diff --git a/hw/pci.c b/hw/pci.c
index 6910fac..1679d40 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -2003,7 +2003,7 @@ static void pci_device_class_init(ObjectClass *klass, void *data)
     k->unplug = pci_unplug_device;
     k->exit = pci_unregister_device;
     k->bus_info = &pci_bus_info;
-    k->props = pci_props;
+    klass->props = pci_props;
 }
 
 static TypeInfo pci_device_type_info = {
diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c
index 34d73aa..a322046 100644
--- a/hw/pcnet-pci.c
+++ b/hw/pcnet-pci.c
@@ -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 = {
diff --git a/hw/pcspk.c b/hw/pcspk.c
index e430324..f33eac2 100644
--- a/hw/pcspk.c
+++ b/hw/pcspk.c
@@ -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 = {
diff --git a/hw/pl041.c b/hw/pl041.c
index b6723be..5a035e1 100644
--- a/hw/pl041.c
+++ b/hw/pl041.c
@@ -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 = {
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index ddaa846..6fd0b26 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -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 = {
diff --git a/hw/pxa2xx_dma.c b/hw/pxa2xx_dma.c
index 0310154..aef039f 100644
--- a/hw/pxa2xx_dma.c
+++ b/hw/pxa2xx_dma.c
@@ -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 = {
diff --git a/hw/pxa2xx_gpio.c b/hw/pxa2xx_gpio.c
index 09a408b..c98454e 100644
--- a/hw/pxa2xx_gpio.c
+++ b/hw/pxa2xx_gpio.c
@@ -330,7 +330,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 = {
diff --git a/hw/pxa2xx_timer.c b/hw/pxa2xx_timer.c
index 77b033b..db2ebe2 100644
--- a/hw/pxa2xx_timer.c
+++ b/hw/pxa2xx_timer.c
@@ -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 = {
diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index d4fc843..2161a36 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -148,7 +148,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
@@ -511,7 +511,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));
     if (dev->parent_bus->info->print_dev)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index bea57e9..6e518d8 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -465,7 +465,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;
         }
diff --git a/hw/qdev.c b/hw/qdev.c
index 813f27e..d9f811f 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -575,9 +575,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));
@@ -609,16 +608,6 @@ static void device_finalize(Object *obj)
     QTAILQ_REMOVE(&dev->parent_bus->children, dev, sibling);
 }
 
-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);
@@ -645,7 +634,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,
     .abstract = true,
     .class_size = sizeof(DeviceClass),
 };
diff --git a/hw/qdev.h b/hw/qdev.h
index d2596fe..3c35acf 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -32,7 +32,6 @@ typedef struct DeviceClass {
 
     const char *fw_name;
     const char *desc;
-    Property *props;
     int no_user;
 
     /* callbacks */
diff --git a/hw/qxl.c b/hw/qxl.c
index 47a162e..08cab5b 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1978,7 +1978,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 = {
@@ -2000,7 +2000,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 = {
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 05b8e1e..b9b2354 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3513,7 +3513,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 = {
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index be1f5f1..1980e38 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -361,11 +361,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 = {
@@ -383,11 +382,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 = {
@@ -405,11 +403,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 = {
@@ -452,11 +449,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 = {
diff --git a/hw/sb16.c b/hw/sb16.c
index c81455d..5e8ef6e 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -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 = {
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 2777566..e64d2c5 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -1574,7 +1574,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 = {
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 9949786..5fe0627 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1844,7 +1844,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;
 }
 
@@ -1872,7 +1872,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;
 }
 
@@ -1900,7 +1900,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;
 }
 
@@ -1930,7 +1930,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;
 }
 
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index d856d23..c3a50a3 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -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;
 }
 
diff --git a/hw/serial.c b/hw/serial.c
index a421d1e..1a76e91 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -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 = {
diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c
index 97edebb..62ceece 100644
--- a/hw/slavio_timer.c
+++ b/hw/slavio_timer.c
@@ -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 = {
diff --git a/hw/smbus_eeprom.c b/hw/smbus_eeprom.c
index 11adab0..47e8a8a 100644
--- a/hw/smbus_eeprom.c
+++ b/hw/smbus_eeprom.c
@@ -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 = {
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index 1a5213f..20a15ce 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -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 = {
diff --git a/hw/spapr_llan.c b/hw/spapr_llan.c
index cfc7778..38058e3 100644
--- a/hw/spapr_llan.c
+++ b/hw/spapr_llan.c
@@ -482,7 +482,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;
@@ -491,7 +490,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 = {
diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c
index e7ef551..3080eb4 100644
--- a/hw/spapr_pci.c
+++ b/hw/spapr_pci.c
@@ -298,10 +298,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);
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 897c057..d742b4d 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -768,7 +768,7 @@ static void vio_spapr_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = spapr_vio_busdev_init;
     k->bus_info = &spapr_vio_bus_info;
-    k->props = spapr_vio_props;
+    klass->props = spapr_vio_props;
 }
 
 static TypeInfo spapr_vio_type_info = {
diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
index 2167017..7e9ea95 100644
--- a/hw/spapr_vscsi.c
+++ b/hw/spapr_vscsi.c
@@ -954,7 +954,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;
@@ -963,7 +962,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 = {
diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
index 60e22b1..2fc58d8 100644
--- a/hw/spapr_vty.c
+++ b/hw/spapr_vty.c
@@ -143,14 +143,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 = {
diff --git a/hw/sparc32_dma.c b/hw/sparc32_dma.c
index 1dbf69e..95b8a61 100644
--- a/hw/sparc32_dma.c
+++ b/hw/sparc32_dma.c
@@ -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 = {
diff --git a/hw/spitz.c b/hw/spitz.c
index 1d6d2b0..8ff9b5b 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -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 = {
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index fbe99cb..6ef99c0 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -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 = {
diff --git a/hw/strongarm.c b/hw/strongarm.c
index 1b15f39..8ce2f25 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -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 = {
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 7bcbf37..a68e19e 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -728,11 +728,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 = {
@@ -792,11 +791,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 = {
diff --git a/hw/sun4m_iommu.c b/hw/sun4m_iommu.c
index ebefa91..485eee3 100644
--- a/hw/sun4m_iommu.c
+++ b/hw/sun4m_iommu.c
@@ -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 = {
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 237e20c..c49308d 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -665,11 +665,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 = {
@@ -722,11 +721,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 = {
diff --git a/hw/tcx.c b/hw/tcx.c
index ac7dcb4..5b64296 100644
--- a/hw/tcx.c
+++ b/hw/tcx.c
@@ -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 = {
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 12d1be0..b42469e 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -567,7 +567,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 = {
diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c
index 426b95c..04b52df 100644
--- a/hw/usb/dev-audio.c
+++ b/hw/usb/dev-audio.c
@@ -687,7 +687,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;
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index cff55f2..fbc24df 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1404,7 +1404,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 = {
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 8dcac8b..595b40e 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -588,7 +588,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 = {
@@ -616,7 +616,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 = {
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index a38a948..b60a963 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1329,7 +1329,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 = {
@@ -1345,7 +1345,7 @@ static void ccid_card_class_init(ObjectClass *klass, void *data)
     k->bus_info = &ccid_bus_info;
     k->init = ccid_card_init;
     k->exit = ccid_card_exit;
-    k->props = ccid_props;
+    klass->props = ccid_props;
 }
 
 static TypeInfo ccid_card_type_info = {
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index bdbe7bd..be58c4f 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -658,7 +658,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 = {
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 60f9f5b..202398c 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2227,7 +2227,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 = {
@@ -2248,7 +2248,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 = {
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 1a1cc88..b547381 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -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 = {
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index e55dad9..e50b38b 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1248,7 +1248,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 = {
@@ -1270,7 +1270,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 = {
@@ -1292,7 +1292,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 = {
@@ -1313,7 +1313,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 = {
@@ -1334,7 +1334,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 = {
@@ -1355,7 +1355,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 = {
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 73b0c7f..9ec5cc4 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -2900,7 +2900,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;
diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c
index 90919c2..dc32566 100644
--- a/hw/usb/host-linux.c
+++ b/hw/usb/host-linux.c
@@ -1434,7 +1434,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 = {
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 8e9f175..ad40809 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1467,7 +1467,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 = {
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index cffee3d..212544a 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -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 = {
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index a0fb7c1..cf43fd8 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -829,7 +829,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 = {
@@ -863,7 +863,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 = {
@@ -894,7 +894,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 = {
@@ -921,7 +921,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
     k->revision = VIRTIO_PCI_ABI_VERSION;
     k->class_id = PCI_CLASS_MEMORY_RAM;
     dc->reset = virtio_pci_reset;
-    dc->props = virtio_balloon_properties;
+    klass->props = virtio_balloon_properties;
 }
 
 static TypeInfo virtio_balloon_info = {
@@ -975,7 +975,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 = {
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 6d49ad6..f0fa45c 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -939,7 +939,7 @@ static void virtio_serial_port_class_init(ObjectClass *klass, void *data)
     k->bus_info = &virtser_bus_info;
     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 = {
diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index 6338efa..0fb7064 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -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 = {
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 6fb7950..59d1f0f 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -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 = {
diff --git a/hw/xgmac.c b/hw/xgmac.c
index dd4bdc4..70ce403 100644
--- a/hw/xgmac.c
+++ b/hw/xgmac.c
@@ -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 = {
diff --git a/hw/xilinx_axidma.c b/hw/xilinx_axidma.c
index 85dfcbf..710c2ca 100644
--- a/hw/xilinx_axidma.c
+++ b/hw/xilinx_axidma.c
@@ -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 = {
diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c
index 7526273..326ce0c 100644
--- a/hw/xilinx_axienet.c
+++ b/hw/xilinx_axienet.c
@@ -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 = {
diff --git a/hw/xilinx_ethlite.c b/hw/xilinx_ethlite.c
index 857b33d..7164891 100644
--- a/hw/xilinx_ethlite.c
+++ b/hw/xilinx_ethlite.c
@@ -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 = {
diff --git a/hw/xilinx_intc.c b/hw/xilinx_intc.c
index 553f848..8acda8f 100644
--- a/hw/xilinx_intc.c
+++ b/hw/xilinx_intc.c
@@ -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 = {
diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c
index 3ab2f2b..2e441b4 100644
--- a/hw/xilinx_timer.c
+++ b/hw/xilinx_timer.c
@@ -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 = {
diff --git a/hw/xio3130_downstream.c b/hw/xio3130_downstream.c
index 319624f..6528af0 100644
--- a/hw/xio3130_downstream.c
+++ b/hw/xio3130_downstream.c
@@ -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 = {
diff --git a/hw/xio3130_upstream.c b/hw/xio3130_upstream.c
index 34a99bb..4ff5e4c 100644
--- a/hw/xio3130_upstream.c
+++ b/hw/xio3130_upstream.c
@@ -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 = {
diff --git a/hw/zaurus.c b/hw/zaurus.c
index 72838ec..4aca57c 100644
--- a/hw/zaurus.c
+++ b/hw/zaurus.c
@@ -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 = {
diff --git a/include/qemu/object.h b/include/qemu/object.h
index f60b6b6..6db376d 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -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"
 
 /**
@@ -239,6 +242,9 @@ struct ObjectClass
 {
     /*< private >*/
     Type type;
+
+    /*< public >*/
+    Property *props;
 };
 
 typedef enum ObjectState {
@@ -970,9 +976,6 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
  */
 Object *container_get(const char *path);
 
-typedef struct Property Property;
-typedef struct PropertyInfo PropertyInfo;
-
 struct Property {
     const char   *name;
     PropertyInfo *info;
diff --git a/qom/object.c b/qom/object.c
index 28186d7..3a6b37b 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1225,10 +1225,29 @@ 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);
     obj->state = OBJECT_STATE_CREATED;
+
+    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 register_types(void)
@@ -1242,6 +1261,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,
         .abstract = true,
     };
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (21 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 22/25] qom: push static properties to Object Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 12:11   ` Andreas Färber
  2012-05-09 20:01   ` Igor Mammedov
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 24/25] qdev: implement qdev_init on top of realize Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 25/25] qdev: split part of device_finalize to device_unrealize Paolo Bonzini
  24 siblings, 2 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

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.

Unrealize is also called by object_deinit, as a separate step before
finalization.

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.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/object.h |   20 +++++++++++
 qom/object.c          |   93 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)

diff --git a/include/qemu/object.h b/include/qemu/object.h
index 6db376d..6bded2a 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -245,6 +245,10 @@ struct ObjectClass
 
     /*< public >*/
     Property *props;
+    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 {
@@ -463,6 +467,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.
diff --git a/qom/object.c b/qom/object.c
index 3a6b37b..2a3753a 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -259,6 +259,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_CREATED && klass->unrealize) {
+        klass->unrealize(obj);
+    }
+    obj->state = OBJECT_STATE_CREATED;
+}
+
+static int object_unrealize_1(Object *obj, void *unused)
+{
+    object_unrealize(obj);
+    return 0;
+}
+
+void object_unrealize_children(Object *obj)
+{
+    object_child_foreach(obj, object_unrealize_1, 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_1(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_1, 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;
@@ -337,6 +418,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);
     }
@@ -1239,7 +1322,10 @@ static void object_instance_init(Object *obj)
     Property *prop;
 
     object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
+
     obj->state = OBJECT_STATE_CREATED;
+    object_property_add(obj, "realized", "bool", object_get_realized,
+                        object_set_realized, NULL, NULL, NULL);
 
     class = object_get_class(obj);
     do {
@@ -1250,6 +1336,12 @@ static void object_instance_init(Object *obj)
     } while (class != object_class_by_name(TYPE_OBJECT));
 }
 
+static void object_class_init(ObjectClass *klass, void *class_data)
+{
+    klass->realize_children = object_realize_children;
+    klass->unrealize_children = object_unrealize_children;
+}
+
 static void register_types(void)
 {
     static TypeInfo interface_info = {
@@ -1262,6 +1354,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,
         .abstract = true,
     };
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 24/25] qdev: implement qdev_init on top of realize
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (22 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 23/25] qom: add realized property Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 25/25] qdev: split part of device_finalize to device_unrealize Paolo Bonzini
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Switch the qdev_init function to simply set the "realized"
property to true.  The old contents of qdev_init become the
realize and realize_children methods.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev.c |   36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index d9f811f..e674248 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -119,17 +119,17 @@ DeviceState *qdev_try_create(BusState *bus, const char *type)
    calling this function.
    On failure, destroy the device and return negative value.
    Return 0 on success.  */
-int qdev_init(DeviceState *dev)
+static void device_realize(Object *obj, Error **errp)
 {
+    DeviceState *dev = DEVICE(obj);
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
     int rc;
 
-    assert(!object_is_realized(OBJECT(dev)));
-
     rc = dc->init(dev);
     if (rc < 0) {
         qdev_free(dev);
-        return rc;
+        error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
+        return;
     }
 
     if (!OBJECT(dev)->parent) {
@@ -146,11 +146,28 @@ int qdev_init(DeviceState *dev)
                                        dev->instance_id_alias,
                                        dev->alias_required_for_version);
     }
-    OBJECT(dev)->state = OBJECT_STATE_REALIZED;
+}
+
+static void device_realize_children(Object *obj, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Error *err = NULL;
+
+    object_realize_children(OBJECT(dev), &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
     if (dev->hotplugged) {
         device_reset(dev);
     }
-    return 0;
+}
+
+int qdev_init(DeviceState *dev)
+{
+    Error *err = NULL;
+    object_property_set_bool(OBJECT(dev), true, "realized", &err);
+    return err ? -EINVAL : 0;
 }
 
 void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
@@ -628,6 +645,12 @@ Object *qdev_get_machine(void)
     return dev;
 }
 
+static void device_class_init(ObjectClass *klass, void *data)
+{
+    klass->realize = device_realize;
+    klass->realize_children = device_realize_children;
+}
+
 static TypeInfo device_type_info = {
     .name = TYPE_DEVICE,
     .parent = TYPE_OBJECT,
@@ -636,6 +659,7 @@ static TypeInfo device_type_info = {
     .instance_finalize = device_finalize,
     .abstract = true,
     .class_size = sizeof(DeviceClass),
+    .class_init = device_class_init,
 };
 
 static void qdev_register_types(void)
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [Qemu-devel] [PATCH 25/25] qdev: split part of device_finalize to device_unrealize
  2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
                   ` (23 preceding siblings ...)
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 24/25] qdev: implement qdev_init on top of realize Paolo Bonzini
@ 2012-04-03 11:15 ` Paolo Bonzini
  24 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 11:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, afaerber

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev.c |   35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index e674248..45f1133 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -601,27 +601,31 @@ static void device_initfn(Object *obj)
 }
 
 /* Unlink device from bus and free the structure.  */
-static void device_finalize(Object *obj)
+static void device_unrealize(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
     BusState *bus;
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
 
-    if (object_is_realized(obj)) {
-        while (dev->num_child_bus) {
-            bus = QLIST_FIRST(&dev->child_bus);
-            qbus_free(bus);
-        }
-        if (qdev_get_vmsd(dev)) {
-            vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
-        }
-        if (dc->exit) {
-            dc->exit(dev);
-        }
-        if (dev->opts) {
-            qemu_opts_del(dev->opts);
-        }
+    while (dev->num_child_bus) {
+        bus = QLIST_FIRST(&dev->child_bus);
+        qbus_free(bus);
+    }
+    if (qdev_get_vmsd(dev)) {
+        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
     }
+    if (dc->exit) {
+        dc->exit(dev);
+    }
+    if (dev->opts) {
+        qemu_opts_del(dev->opts);
+    }
+}
+
+static void device_finalize(Object *obj)
+{
+    DeviceState *dev = DEVICE(obj);
+
     QTAILQ_REMOVE(&dev->parent_bus->children, dev, sibling);
 }
 
@@ -649,6 +653,7 @@ static void device_class_init(ObjectClass *klass, void *data)
 {
     klass->realize = device_realize;
     klass->realize_children = device_realize_children;
+    klass->unrealize = device_unrealize;
 }
 
 static TypeInfo device_type_info = {
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 23/25] qom: add realized property Paolo Bonzini
@ 2012-04-03 12:11   ` Andreas Färber
  2012-04-03 13:03     ` Paolo Bonzini
  2012-05-09 20:01   ` Igor Mammedov
  1 sibling, 1 reply; 57+ messages in thread
From: Andreas Färber @ 2012-04-03 12:11 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel

Paolo,

Am 03.04.2012 13:15, schrieb Paolo Bonzini:
> 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.
> 
> Unrealize is also called by object_deinit, as a separate step before
> finalization.
> 
> 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.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Since this patch is clearly an extended version of my realize patch
http://patchwork.ozlabs.org/patch/148752/, it should carry my SoB, as
reminded last night. If you don't want my SoB on the parts I didn't do -
namely unrealize and *_childen - then feel free to split the patch in
two. Simply dropping attribution in both cover letter and commit just
because I didn't get around yet to sending a v2 with those requests
addressed is not nice!

Patch 24/25 was done differently (calling realized = true from init
rather than the other way around) so this comment only applies to 23/25.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree Paolo Bonzini
@ 2012-04-03 12:28   ` Jan Kiszka
  2012-04-03 13:05     ` Paolo Bonzini
  2012-04-03 21:06   ` Anthony Liguori
  1 sibling, 1 reply; 57+ messages in thread
From: Jan Kiszka @ 2012-04-03 12:28 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

On 2012-04-03 13:15, Paolo Bonzini wrote:
> Otherwise, non-string properties without a legacy counterpart are missed.
> Also fix error propagation in object_property_print itself, otherwise
> pointer properties are printed as "<null>".
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/qdev-monitor.c |    2 +-
>  qom/object.c      |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
> index 0acfc82..07ac525 100644
> --- a/hw/qdev-monitor.c
> +++ b/hw/qdev-monitor.c
> @@ -492,7 +492,7 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
>          if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
>              value = object_property_get_str(OBJECT(dev), legacy_name, &err);

This is not a criticism on this patch, but I'd like to underline that
the line above only works because legacy props also define print
handlers.

[qdev_property_add_legacy]
    object_property_add(OBJECT(dev), name, type,
                        prop->info->print ? qdev_get_legacy_property : prop->info->get,
                        prop->info->parse ? qdev_set_legacy_property : prop->info->set,
                        NULL,
                        prop, errp);

But this statement above is still inconsistent. We should either
assert(print && parse) or handle their non-existence properly.

>          } else {
> -            value = object_property_get_str(OBJECT(dev), props->name, &err);
> +            value = object_property_print(OBJECT(dev), props->name, &err);
>          }
>          g_free(legacy_name);
>  
> diff --git a/qom/object.c b/qom/object.c
> index f3ffaa6..ff36946 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -850,7 +850,7 @@ char *object_property_print(Object *obj, const char *name,
>      char *string;
>  
>      mo = string_output_visitor_new();
> -    object_property_get(obj, string_output_get_visitor(mo), name, NULL);
> +    object_property_get(obj, string_output_get_visitor(mo), name, errp);
>      string = string_output_get_string(mo);
>      string_output_visitor_cleanup(mo);
>      return string;

Patch works for me.

Thanks,
Jan
-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 04/25] qom: make Object a type
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 04/25] qom: make Object a type Paolo Bonzini
@ 2012-04-03 12:30   ` Andreas Färber
  2012-04-03 13:06     ` Paolo Bonzini
  2012-04-03 20:52   ` Anthony Liguori
  1 sibling, 1 reply; 57+ messages in thread
From: Andreas Färber @ 2012-04-03 12:30 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel

Am 03.04.2012 13:15, schrieb Paolo Bonzini:
> Right now the base Object class has a special NULL type.  Change this so
> that we will be able to add class_init and class_base_init callbacks.
> To do this, remove some special casing of ObjectClass that is not really
> necessary.

While the patch itself looks good, we should be aware that this changes
semantics: Before this patch, lack of .parent is identical to .parent =
TYPE_OBJECT; with this patch that would become another base class.
Should be mentioned in the commit message and all TypeInfos need to be
reviewed. I don't think accidentally growing base classes is a good
idea. Maybe whitelist valid base classes in type_register_static() and
abort otherwise? Then at least we'd catch it by just running the
executables.

> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu/object.h |    2 +-
>  qom/object.c          |   59 +++++++++++++++++++++++++------------------------
>  2 files changed, 31 insertions(+), 30 deletions(-)
> 
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index ccaea7d..22f646d 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -33,7 +33,7 @@ typedef struct TypeInfo TypeInfo;
>  typedef struct InterfaceClass InterfaceClass;
>  typedef struct InterfaceInfo InterfaceInfo;
>  
> -#define TYPE_OBJECT NULL
> +#define TYPE_OBJECT "object"
>  
>  /**
>   * SECTION:object.h
> diff --git a/qom/object.c b/qom/object.c
> index 6ff1c19..585619d 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -210,7 +210,7 @@ static void type_class_interface_init(TypeImpl *ti, InterfaceImpl *iface)
>  
>  static void type_initialize(TypeImpl *ti)
>  {
> -    size_t class_size = sizeof(ObjectClass);
> +    TypeImpl *parent;
>      int i;
>  
>      if (ti->class) {
> @@ -221,30 +221,24 @@ static void type_initialize(TypeImpl *ti)
>      ti->instance_size = type_object_get_size(ti);
>  
>      ti->class = g_malloc0(ti->class_size);
> -    ti->class->type = ti;
> -
> -    if (type_has_parent(ti)) {
> -        TypeImpl *parent = type_get_parent(ti);
>  
> +    parent = type_get_parent(ti);
> +    if (parent) {
>          type_initialize(parent);
>  
> -        class_size = parent->class_size;
>          g_assert(parent->class_size <= ti->class_size);
> +        memcpy(ti->class, parent->class, parent->class_size);
> +    }
>  
> -        memcpy((void *)ti->class + sizeof(ObjectClass),
> -               (void *)parent->class + sizeof(ObjectClass),
> -               parent->class_size - sizeof(ObjectClass));

Is this really safe? Before we would only copy the contents of derived
classes. Missing some explanations IMO.

> +    ti->class->type = ti;
>  
> -        while (parent) {
> -            if (parent->class_base_init) {
> -                parent->class_base_init(ti->class, ti->class_data);
> -            }
> -            parent = type_get_parent(parent);
> +    while (parent) {
> +        if (parent->class_base_init) {
> +            parent->class_base_init(ti->class, ti->class_data);
>          }
> +        parent = type_get_parent(parent);
>      }
>  
> -    memset((void *)ti->class + class_size, 0, ti->class_size - class_size);
> -
>      for (i = 0; i < ti->num_interfaces; i++) {
>          type_class_interface_init(ti, &ti->interfaces[i]);
>      }
> @@ -467,19 +461,6 @@ Object *object_dynamic_cast(Object *obj, const char *typename)
>  }
>  
>  
> -static void register_types(void)
> -{
> -    static TypeInfo interface_info = {
> -        .name = TYPE_INTERFACE,
> -        .instance_size = sizeof(Interface),
> -        .abstract = true,
> -    };
> -
> -    type_interface = type_register_static(&interface_info);
> -}
> -
> -type_init(register_types)
> -
>  Object *object_dynamic_cast_assert(Object *obj, const char *typename)
>  {
>      Object *inst;
> @@ -1233,3 +1214,23 @@ void object_property_add_str(Object *obj, const char *name,
>                          property_release_str,
>                          prop, errp);
>  }
> +
> +static void register_types(void)
> +{
> +    static TypeInfo interface_info = {
> +        .name = TYPE_INTERFACE,
> +        .instance_size = sizeof(Interface),
> +        .abstract = true,
> +    };
> +
> +    static TypeInfo object_info = {
> +        .name = TYPE_OBJECT,
> +        .instance_size = sizeof(Object),
> +        .abstract = true,
> +    };
> +
> +    type_interface = type_register_static(&interface_info);
> +    type_register_static(&object_info);
> +}
> +
> +type_init(register_types)

Thanks for moving these down.

Is there a reason not to make them static const just before
register_types()?

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 05/25] qom: push type up to Object
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 05/25] qom: push type up to Object Paolo Bonzini
@ 2012-04-03 12:33   ` Andreas Färber
  2012-04-03 20:55   ` Anthony Liguori
  1 sibling, 0 replies; 57+ messages in thread
From: Andreas Färber @ 2012-04-03 12:33 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel

Am 03.04.2012 13:15, schrieb Paolo Bonzini:
> Now that Object is a type, add an instance_init function and push
> the "type" property from qdev to there.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

But please change the subject to 'qom: Push "type" property up to
Object', otherwise it's confusing. ;)

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-03 12:11   ` Andreas Färber
@ 2012-04-03 13:03     ` Paolo Bonzini
  2012-04-05 12:04       ` Andreas Färber
  0 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 13:03 UTC (permalink / raw)
  To: Andreas Färber; +Cc: aliguori, qemu-devel

Il 03/04/2012 14:11, Andreas Färber ha scritto:
> Since this patch is clearly an extended version of my realize patch
> http://patchwork.ozlabs.org/patch/148752/, it should carry my SoB, as
> reminded last night. If you don't want my SoB on the parts I didn't do -
> namely unrealize and *_childen - then feel free to split the patch in
> two. Simply dropping attribution in both cover letter and commit just
> because I didn't get around yet to sending a v2 with those requests
> addressed is not nice!

Technically it's not, because I redid it from scratch (I never even had
time to really look at your patches beyond reading the commit message,
and I did this part while I didn't even have network access).

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-04-03 12:28   ` Jan Kiszka
@ 2012-04-03 13:05     ` Paolo Bonzini
  2012-05-11 14:10       ` Andreas Färber
  0 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 13:05 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: aliguori, qemu-devel, afaerber

Il 03/04/2012 14:28, Jan Kiszka ha scritto:
>> >          if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
>> >              value = object_property_get_str(OBJECT(dev), legacy_name, &err);
> This is not a criticism on this patch, but I'd like to underline that
> the line above only works because legacy props also define print
                                                 ^^^^

You mean always, I guess.

> But this statement above is still inconsistent. We should either
> assert(print && parse) or handle their non-existence properly.

Yes, asserting that print/parse are always present in pairs (if at all)
would be good.

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 04/25] qom: make Object a type
  2012-04-03 12:30   ` Andreas Färber
@ 2012-04-03 13:06     ` Paolo Bonzini
  0 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 13:06 UTC (permalink / raw)
  To: Andreas Färber; +Cc: aliguori, qemu-devel

Il 03/04/2012 14:30, Andreas Färber ha scritto:
>> > Right now the base Object class has a special NULL type.  Change this so
>> > that we will be able to add class_init and class_base_init callbacks.
>> > To do this, remove some special casing of ObjectClass that is not really
>> > necessary.
> While the patch itself looks good, we should be aware that this changes
> semantics: Before this patch, lack of .parent is identical to .parent =
> TYPE_OBJECT; with this patch that would become another base class.
> Should be mentioned in the commit message and all TypeInfos need to be
> reviewed. I don't think accidentally growing base classes is a good
> idea. Maybe whitelist valid base classes in type_register_static() and
> abort otherwise? Then at least we'd catch it by just running the
> executables.
> 

Good idea.

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent Paolo Bonzini
@ 2012-04-03 20:50   ` Anthony Liguori
  0 siblings, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 20:50 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> This simple bit of functionality was missing and we'll need it soon,
> so add it.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   include/qemu/object.h |   14 ++++++++++++++
>   qom/object.c          |   13 +++++++++++++
>   2 files changed, 27 insertions(+)
>
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index a675937..f814521 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -548,6 +548,14 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
>                                          const char *typename);
>
>   /**
> + * object_class_get_parent:
> + * @klass: The class to obtain the parent for.
> + *
> + * Returns: The parent for @klass.
> + */
> +ObjectClass *object_class_get_parent(ObjectClass *klass);
> +
> +/**
>    * object_class_get_name:
>    * @klass: The class to obtain the QOM typename for.
>    *
> @@ -555,6 +563,12 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
>    */
>   const char *object_class_get_name(ObjectClass *klass);
>
> +/**
> + * object_class_by_name:
> + * @typename: The QOM typename to obtain the class for.
> + *
> + * Returns: The class for @typename.
> + */
>   ObjectClass *object_class_by_name(const char *typename);
>
>   void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
> diff --git a/qom/object.c b/qom/object.c
> index e721fc2..3e9fed7 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -545,6 +545,19 @@ ObjectClass *object_class_by_name(const char *typename)
>       return type->class;
>   }
>
> +ObjectClass *object_class_get_parent(ObjectClass *class)
> +{
> +    TypeImpl *type = type_get_parent(class->type);
> +
> +    if (!type) {
> +        return NULL;
> +    }
> +
> +    type_initialize(type);
> +
> +    return type->class;
> +}
> +
>   typedef struct OCFData
>   {
>       void (*fn)(ObjectClass *klass, void *opaque);

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 02/25] qom: add object_child_foreach
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 02/25] qom: add object_child_foreach Paolo Bonzini
@ 2012-04-03 20:51   ` Anthony Liguori
  0 siblings, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 20:51 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> A utility function that will be used to implement hierarchical realization.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   include/qemu/object.h |   14 +++++++++++++-
>   qom/object.c          |   17 +++++++++++++++++
>   2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index f814521..470efe3 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -918,6 +918,19 @@ void object_property_add_str(Object *obj, const char *name,
>                                struct Error **errp);
>
>   /**
> + * object_child_foreach:
> + * @obj: the object whose children will be navigated
> + * @fn: the iterator function to be called
> + * @opaque: an opaque value that will be passed to the iterator
> + *
> + * Call @fn passing each child of @obj and @opaque to it, until @fn returns
> + * non-zero.  Return the last value returned by @fn, or 0 if there is no
> + * child.
> + */
> +int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
> +                         void *opaque);
> +
> +/**
>    * container_get:
>    * @path: path to the container
>    *
> @@ -928,5 +941,4 @@ void object_property_add_str(Object *obj, const char *name,
>    */
>   Object *container_get(const char *path);
>
> -
>   #endif
> diff --git a/qom/object.c b/qom/object.c
> index 3e9fed7..4975d93 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -597,6 +597,23 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
>       g_hash_table_foreach(type_table_get(), object_class_foreach_tramp,&data);
>   }
>
> +int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
> +                         void *opaque)
> +{
> +    ObjectProperty *prop;
> +    int ret = 0;
> +
> +    QTAILQ_FOREACH(prop,&obj->properties, node) {
> +        if (strstart(prop->type, "child<", NULL)) {
> +            ret = fn(prop->opaque, opaque);
> +            if (ret != 0) {
> +                break;
> +            }
> +        }
> +    }
> +    return ret;
> +}
> +
>   static void object_class_get_list_tramp(ObjectClass *klass, void *opaque)
>   {
>       GSList **list = opaque;

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 03/25] qom: add class_base_init
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 03/25] qom: add class_base_init Paolo Bonzini
@ 2012-04-03 20:51   ` Anthony Liguori
  0 siblings, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 20:51 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> The class_base_init TypeInfo callback was present in one of the early
> QOM versions but removed (on my request...) before committing.  We
> will need it soon, add it.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Heh, funny how that worked out :-)

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   include/qemu/object.h |   10 ++++++++--
>   qom/object.c          |    9 +++++++++
>   2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index 470efe3..ccaea7d 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -291,10 +291,15 @@ struct Object
>    *   has occurred to allow a class to set its default virtual method pointers.
>    *   This is also the function to use to override virtual methods from a parent
>    *   class.
> + * @class_base_init: This function is called for all base classes after all
> + *   parent class initialization has occurred, but before the class itself
> + *   is initialized.  This is the function to use to undo the effects of
> + *   memcpy from the parent class to the descendents.
>    * @class_finalize: This function is called during class destruction and is
>    *   meant to release and dynamic parameters allocated by @class_init.
> - * @class_data: Data to pass to the @class_init and @class_finalize functions.
> - *   This can be useful when building dynamic classes.
> + * @class_data: Data to pass to the @class_init, @class_base_init and
> + *   @class_finalize functions.  This can be useful when building dynamic
> + *   classes.
>    * @interfaces: The list of interfaces associated with this type.  This
>    *   should point to a static array that's terminated with a zero filled
>    *   element.
> @@ -312,6 +317,7 @@ struct TypeInfo
>       size_t class_size;
>
>       void (*class_init)(ObjectClass *klass, void *data);
> +    void (*class_base_init)(ObjectClass *klass, void *data);
>       void (*class_finalize)(ObjectClass *klass, void *data);
>       void *class_data;
>
> diff --git a/qom/object.c b/qom/object.c
> index 4975d93..6ff1c19 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -45,6 +45,7 @@ struct TypeImpl
>       size_t instance_size;
>
>       void (*class_init)(ObjectClass *klass, void *data);
> +    void (*class_base_init)(ObjectClass *klass, void *data);
>       void (*class_finalize)(ObjectClass *klass, void *data);
>
>       void *class_data;
> @@ -112,6 +113,7 @@ TypeImpl *type_register(const TypeInfo *info)
>       ti->instance_size = info->instance_size;
>
>       ti->class_init = info->class_init;
> +    ti->class_base_init = info->class_base_init;
>       ti->class_finalize = info->class_finalize;
>       ti->class_data = info->class_data;
>
> @@ -232,6 +234,13 @@ static void type_initialize(TypeImpl *ti)
>           memcpy((void *)ti->class + sizeof(ObjectClass),
>                  (void *)parent->class + sizeof(ObjectClass),
>                  parent->class_size - sizeof(ObjectClass));
> +
> +        while (parent) {
> +            if (parent->class_base_init) {
> +                parent->class_base_init(ti->class, ti->class_data);
> +            }
> +            parent = type_get_parent(parent);
> +        }
>       }
>
>       memset((void *)ti->class + class_size, 0, ti->class_size - class_size);

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 04/25] qom: make Object a type
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 04/25] qom: make Object a type Paolo Bonzini
  2012-04-03 12:30   ` Andreas Färber
@ 2012-04-03 20:52   ` Anthony Liguori
  1 sibling, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 20:52 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> Right now the base Object class has a special NULL type.  Change this so
> that we will be able to add class_init and class_base_init callbacks.
> To do this, remove some special casing of ObjectClass that is not really
> necessary.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori


> ---
>   include/qemu/object.h |    2 +-
>   qom/object.c          |   59 +++++++++++++++++++++++++------------------------
>   2 files changed, 31 insertions(+), 30 deletions(-)
>
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index ccaea7d..22f646d 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -33,7 +33,7 @@ typedef struct TypeInfo TypeInfo;
>   typedef struct InterfaceClass InterfaceClass;
>   typedef struct InterfaceInfo InterfaceInfo;
>
> -#define TYPE_OBJECT NULL
> +#define TYPE_OBJECT "object"
>
>   /**
>    * SECTION:object.h
> diff --git a/qom/object.c b/qom/object.c
> index 6ff1c19..585619d 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -210,7 +210,7 @@ static void type_class_interface_init(TypeImpl *ti, InterfaceImpl *iface)
>
>   static void type_initialize(TypeImpl *ti)
>   {
> -    size_t class_size = sizeof(ObjectClass);
> +    TypeImpl *parent;
>       int i;
>
>       if (ti->class) {
> @@ -221,30 +221,24 @@ static void type_initialize(TypeImpl *ti)
>       ti->instance_size = type_object_get_size(ti);
>
>       ti->class = g_malloc0(ti->class_size);
> -    ti->class->type = ti;
> -
> -    if (type_has_parent(ti)) {
> -        TypeImpl *parent = type_get_parent(ti);
>
> +    parent = type_get_parent(ti);
> +    if (parent) {
>           type_initialize(parent);
>
> -        class_size = parent->class_size;
>           g_assert(parent->class_size<= ti->class_size);
> +        memcpy(ti->class, parent->class, parent->class_size);
> +    }
>
> -        memcpy((void *)ti->class + sizeof(ObjectClass),
> -               (void *)parent->class + sizeof(ObjectClass),
> -               parent->class_size - sizeof(ObjectClass));
> +    ti->class->type = ti;
>
> -        while (parent) {
> -            if (parent->class_base_init) {
> -                parent->class_base_init(ti->class, ti->class_data);
> -            }
> -            parent = type_get_parent(parent);
> +    while (parent) {
> +        if (parent->class_base_init) {
> +            parent->class_base_init(ti->class, ti->class_data);
>           }
> +        parent = type_get_parent(parent);
>       }
>
> -    memset((void *)ti->class + class_size, 0, ti->class_size - class_size);
> -
>       for (i = 0; i<  ti->num_interfaces; i++) {
>           type_class_interface_init(ti,&ti->interfaces[i]);
>       }
> @@ -467,19 +461,6 @@ Object *object_dynamic_cast(Object *obj, const char *typename)
>   }
>
>
> -static void register_types(void)
> -{
> -    static TypeInfo interface_info = {
> -        .name = TYPE_INTERFACE,
> -        .instance_size = sizeof(Interface),
> -        .abstract = true,
> -    };
> -
> -    type_interface = type_register_static(&interface_info);
> -}
> -
> -type_init(register_types)
> -
>   Object *object_dynamic_cast_assert(Object *obj, const char *typename)
>   {
>       Object *inst;
> @@ -1233,3 +1214,23 @@ void object_property_add_str(Object *obj, const char *name,
>                           property_release_str,
>                           prop, errp);
>   }
> +
> +static void register_types(void)
> +{
> +    static TypeInfo interface_info = {
> +        .name = TYPE_INTERFACE,
> +        .instance_size = sizeof(Interface),
> +        .abstract = true,
> +    };
> +
> +    static TypeInfo object_info = {
> +        .name = TYPE_OBJECT,
> +        .instance_size = sizeof(Object),
> +        .abstract = true,
> +    };
> +
> +    type_interface = type_register_static(&interface_info);
> +    type_register_static(&object_info);
> +}
> +
> +type_init(register_types)

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 05/25] qom: push type up to Object
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 05/25] qom: push type up to Object Paolo Bonzini
  2012-04-03 12:33   ` Andreas Färber
@ 2012-04-03 20:55   ` Anthony Liguori
  1 sibling, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 20:55 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> Now that Object is a type, add an instance_init function and push
> the "type" property from qdev to there.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   hw/qdev.c    |    6 ------
>   qom/object.c |   11 +++++++++++
>   2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 0d3c0fc..bb6c1aa 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -510,11 +510,6 @@ char* qdev_get_fw_dev_path(DeviceState *dev)
>       return strdup(path);
>   }
>
> -static char *qdev_get_type(Object *obj, Error **errp)
> -{
> -    return g_strdup(object_get_typename(obj));
> -}
> -
>   /**
>    * Legacy property handling
>    */
> @@ -630,7 +625,6 @@ static void device_initfn(Object *obj)
>           qdev_property_add_static(dev, prop, NULL);
>       }
>
> -    object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL);
>       qdev_prop_set_defaults(dev, qdev_get_props(dev));
>   }
>
> diff --git a/qom/object.c b/qom/object.c
> index 585619d..f3ffaa6 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1215,6 +1215,16 @@ void object_property_add_str(Object *obj, const char *name,
>                           prop, errp);
>   }
>
> +static char *qdev_get_type(Object *obj, Error **errp)
> +{
> +    return g_strdup(object_get_typename(obj));
> +}
> +
> +static void object_instance_init(Object *obj)
> +{
> +    object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
> +}
> +
>   static void register_types(void)
>   {
>       static TypeInfo interface_info = {
> @@ -1226,6 +1236,7 @@ static void register_types(void)
>       static TypeInfo object_info = {
>           .name = TYPE_OBJECT,
>           .instance_size = sizeof(Object),
> +        .instance_init = object_instance_init,
>           .abstract = true,
>       };
>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 06/25] qdev: fix -device foo,?
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 06/25] qdev: fix -device foo,? Paolo Bonzini
@ 2012-04-03 20:59   ` Anthony Liguori
  0 siblings, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 20:59 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Peter Maydell, aliguori, Jan Kiszka, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> Since most property types do not have a parse property now, this was
> broken.  Fix it by looking at the setter instead.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   hw/qdev-monitor.c |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
> index 4783366..0acfc82 100644
> --- a/hw/qdev-monitor.c
> +++ b/hw/qdev-monitor.c
> @@ -157,7 +157,7 @@ int qdev_device_help(QemuOpts *opts)
>            * for removal.  This conditional should be removed along with
>            * it.
>            */
> -        if (!prop->info->parse) {
> +        if (!prop->info->set) {
>               continue;           /* no way to set it, don't show */
>           }
>           error_printf("%s.%s=%s\n", driver, prop->name,
> @@ -165,7 +165,7 @@ int qdev_device_help(QemuOpts *opts)
>       }
>       if (info->bus_info) {
>           for (prop = info->bus_info->props; prop&&  prop->name; prop++) {
> -            if (!prop->info->parse) {
> +            if (!prop->info->set) {
>                   continue;           /* no way to set it, don't show */
>               }
>               error_printf("%s.%s=%s\n", driver, prop->name,

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree Paolo Bonzini
  2012-04-03 12:28   ` Jan Kiszka
@ 2012-04-03 21:06   ` Anthony Liguori
  2012-05-10 20:58     ` Jan Kiszka
  1 sibling, 1 reply; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 21:06 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, Jan Kiszka, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> Otherwise, non-string properties without a legacy counterpart are missed.
> Also fix error propagation in object_property_print itself, otherwise
> pointer properties are printed as "<null>".
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   hw/qdev-monitor.c |    2 +-
>   qom/object.c      |    2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
> index 0acfc82..07ac525 100644
> --- a/hw/qdev-monitor.c
> +++ b/hw/qdev-monitor.c
> @@ -492,7 +492,7 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
>           if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
>               value = object_property_get_str(OBJECT(dev), legacy_name,&err);
>           } else {
> -            value = object_property_get_str(OBJECT(dev), props->name,&err);
> +            value = object_property_print(OBJECT(dev), props->name,&err);
>           }
>           g_free(legacy_name);
>
> diff --git a/qom/object.c b/qom/object.c
> index f3ffaa6..ff36946 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -850,7 +850,7 @@ char *object_property_print(Object *obj, const char *name,
>       char *string;
>
>       mo = string_output_visitor_new();
> -    object_property_get(obj, string_output_get_visitor(mo), name, NULL);
> +    object_property_get(obj, string_output_get_visitor(mo), name, errp);
>       string = string_output_get_string(mo);
>       string_output_visitor_cleanup(mo);
>       return string;

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 08/25] qdev: remove qdev_prop_set_defaults
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 08/25] qdev: remove qdev_prop_set_defaults Paolo Bonzini
@ 2012-04-03 21:09   ` Anthony Liguori
  2012-04-03 21:43     ` Paolo Bonzini
  0 siblings, 1 reply; 57+ messages in thread
From: Anthony Liguori @ 2012-04-03 21:09 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>


> ---
>   hw/qdev-properties.c |   22 ----------------------
>   hw/qdev.c            |   28 +++++++++++++++++++++++-----
>   hw/qdev.h            |    1 -
>   3 files changed, 23 insertions(+), 28 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index bff9152..85897c7 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -1083,28 +1083,6 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
>       *ptr = value;
>   }
>
> -void qdev_prop_set_defaults(DeviceState *dev, Property *props)
> -{
> -    Object *obj = OBJECT(dev);
> -    if (!props)
> -        return;
> -    for (; props->name; props++) {
> -        Error *errp = NULL;
> -        if (props->qtype == QTYPE_NONE) {
> -            continue;
> -        }
> -        if (props->qtype == QTYPE_QBOOL) {
> -            object_property_set_bool(obj, props->defval, props->name,&errp);
> -        } else if (props->info->enum_table) {
> -            object_property_set_str(obj, props->info->enum_table[props->defval],
> -                                    props->name,&errp);
> -        } else if (props->qtype == QTYPE_QINT) {
> -            object_property_set_int(obj, props->defval, props->name,&errp);
> -        }
> -        assert_no_error(errp);
> -    }
> -}
> -
>   static QTAILQ_HEAD(, GlobalProperty) global_props = QTAILQ_HEAD_INITIALIZER(global_props);
>
>   static void qdev_prop_register_global(GlobalProperty *prop)
> diff --git a/hw/qdev.c b/hw/qdev.c
> index bb6c1aa..4ac5616 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -90,7 +90,6 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
>           qdev_property_add_legacy(dev, prop, NULL);
>           qdev_property_add_static(dev, prop, NULL);
>       }
> -    qdev_prop_set_defaults(dev, dev->parent_bus->info->props);

Does this break bisectability?

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 08/25] qdev: remove qdev_prop_set_defaults
  2012-04-03 21:09   ` Anthony Liguori
@ 2012-04-03 21:43     ` Paolo Bonzini
  0 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-03 21:43 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: aliguori, qemu-devel, afaerber

Il 03/04/2012 23:09, Anthony Liguori ha scritto:
> On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
>> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> 
> 
>> ---
>>   hw/qdev-properties.c |   22 ----------------------
>>   hw/qdev.c            |   28 +++++++++++++++++++++++-----
>>   hw/qdev.h            |    1 -
>>   3 files changed, 23 insertions(+), 28 deletions(-)
>>
>> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
>> index bff9152..85897c7 100644
>> --- a/hw/qdev-properties.c
>> +++ b/hw/qdev-properties.c
>> @@ -1083,28 +1083,6 @@ void qdev_prop_set_ptr(DeviceState *dev, const
>> char *name, void *value)
>>       *ptr = value;
>>   }
>>
>> -void qdev_prop_set_defaults(DeviceState *dev, Property *props)
>> -{
>> -    Object *obj = OBJECT(dev);
>> -    if (!props)
>> -        return;
>> -    for (; props->name; props++) {
>> -        Error *errp = NULL;
>> -        if (props->qtype == QTYPE_NONE) {
>> -            continue;
>> -        }
>> -        if (props->qtype == QTYPE_QBOOL) {
>> -            object_property_set_bool(obj, props->defval,
>> props->name,&errp);
>> -        } else if (props->info->enum_table) {
>> -            object_property_set_str(obj,
>> props->info->enum_table[props->defval],
>> -                                    props->name,&errp);
>> -        } else if (props->qtype == QTYPE_QINT) {
>> -            object_property_set_int(obj, props->defval,
>> props->name,&errp);
>> -        }
>> -        assert_no_error(errp);
>> -    }
>> -}
>> -
>>   static QTAILQ_HEAD(, GlobalProperty) global_props =
>> QTAILQ_HEAD_INITIALIZER(global_props);
>>
>>   static void qdev_prop_register_global(GlobalProperty *prop)
>> diff --git a/hw/qdev.c b/hw/qdev.c
>> index bb6c1aa..4ac5616 100644
>> --- a/hw/qdev.c
>> +++ b/hw/qdev.c
>> @@ -90,7 +90,6 @@ void qdev_set_parent_bus(DeviceState *dev, BusState
>> *bus)
>>           qdev_property_add_legacy(dev, prop, NULL);
>>           qdev_property_add_static(dev, prop, NULL);
>>       }
>> -    qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
> 
> Does this break bisectability?

Hmm, here it does.  It must be moved later.

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-03 13:03     ` Paolo Bonzini
@ 2012-04-05 12:04       ` Andreas Färber
  2012-04-05 12:36         ` Paolo Bonzini
  0 siblings, 1 reply; 57+ messages in thread
From: Andreas Färber @ 2012-04-05 12:04 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, Anthony Liguori

Am 03.04.2012 15:03, schrieb Paolo Bonzini:
> Il 03/04/2012 14:11, Andreas Färber ha scritto:
>> Since this patch is clearly an extended version of my realize patch
>> http://patchwork.ozlabs.org/patch/148752/, it should carry my SoB, as
>> reminded last night. If you don't want my SoB on the parts I didn't do -
>> namely unrealize and *_childen - then feel free to split the patch in
>> two. Simply dropping attribution in both cover letter and commit just
>> because I didn't get around yet to sending a v2 with those requests
>> addressed is not nice!
> 
> Technically it's not, because I redid it from scratch (I never even had
> time to really look at your patches beyond reading the commit message,
> and I did this part while I didn't even have network access).

That's just as lame an accuse as Fabrice's when he "redid" a patch of
rth back in CVS days. You were around on IRC on March 23rd when I
offered to aliguori to put together a patch for realize (which I am
using in my qom-cpu-sh4 series). Had you volunteered back then, I
wouldn't have invested time and we wouldn't be having this discussion.
But if there's something I hate more than political extremism, it's
having my time wasted.

I was fair to cc you and Anthony on it, to avoid clashes between those
of us working on QOM, you commented on my series, so you have read part
of it; yet you announce the day before your series that you are going to
send realize and ignore my request to not forget my SoB if you do. That
makes me think that you're deliberately trying to keep my code
contribution out of the picture there, whereas Anthony has stated in the
context of unicore32 that rewriting someone's contribution to get that
person's authorship out of the way were not acceptable.

Apart from the personal disrespect this implies here, it's also about me
wanting to prove my bosses that I don't just sit in an arm chair or
write useless crap. My patch is available under GPLv2+ allowing anyone
to freely modify and reuse that code but doing so without copyright and
authorship attribution is in violation of the license. I respect
people's contributions and am all in favor of documenting people's
effort with Reported-by, Tested-by, Reviewed-by, and I expect that
others respect mine too.

You had me write a trivial follow-up to your series, which I did now, so
you should consider living to the same standard and following up on mine.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-05 12:04       ` Andreas Färber
@ 2012-04-05 12:36         ` Paolo Bonzini
  2012-04-05 13:31           ` Andreas Färber
  0 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-05 12:36 UTC (permalink / raw)
  To: Andreas Färber; +Cc: aliguori, qemu-devel, Anthony Liguori

Il 05/04/2012 14:04, Andreas Färber ha scritto:
> Am 03.04.2012 15:03, schrieb Paolo Bonzini:
>> Il 03/04/2012 14:11, Andreas Färber ha scritto:
>>> Since this patch is clearly an extended version of my realize patch
>>> http://patchwork.ozlabs.org/patch/148752/, it should carry my SoB, as
>>> reminded last night. If you don't want my SoB on the parts I didn't do -
>>> namely unrealize and *_childen - then feel free to split the patch in
>>> two. Simply dropping attribution in both cover letter and commit just
>>> because I didn't get around yet to sending a v2 with those requests
>>> addressed is not nice!
>>
>> Technically it's not, because I redid it from scratch (I never even had
>> time to really look at your patches beyond reading the commit message,
>> and I did this part while I didn't even have network access).
> 
> That's just as lame an accuse

(Did you mean excuse?)  It's a fact, not an excuse.  Do I need to show
the two patches side-by-side?  That would be even more ridiculous.

But I can very well add a SoB on v2.

> as Fabrice's when he "redid" a patch of rth back in CVS days.

Wasn't there, sorry.

> You were around on IRC on March 23rd when I
> offered to aliguori to put together a patch for realize (which I am
> using in my qom-cpu-sh4 series).

Well, I'm always around, that doesn't mean I always have time to read it.

> I was fair to cc you and Anthony on it, to avoid clashes between those
> of us working on QOM, you commented on my series, so you have read part
> of it; yet you announce the day before your series that you are going to
> send realize and ignore my request to not forget my SoB if you do.
> That makes me think that you're deliberately trying to keep my code 
> contribution out of the picture there, whereas Anthony has stated in
> the context of unicore32 that rewriting someone's contribution to get
> that person's authorship out of the way were not acceptable.

You're assuming I read your patches, which is not the case beyond seeing
that the realize didn't propagate.  There's really nothing deliberate,
and it's quite surprising to me to hear tones escalating so quickly.

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-05 12:36         ` Paolo Bonzini
@ 2012-04-05 13:31           ` Andreas Färber
  2012-04-05 14:16             ` Paolo Bonzini
  0 siblings, 1 reply; 57+ messages in thread
From: Andreas Färber @ 2012-04-05 13:31 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Peter Maydell, aliguori, qemu-devel, Anthony Liguori

Am 05.04.2012 14:36, schrieb Paolo Bonzini:
> Il 05/04/2012 14:04, Andreas Färber ha scritto:
>> Am 03.04.2012 15:03, schrieb Paolo Bonzini:
>>> Il 03/04/2012 14:11, Andreas Färber ha scritto:
>>>> Since this patch is clearly an extended version of my realize patch
>>>> http://patchwork.ozlabs.org/patch/148752/, it should carry my SoB, as
>>>> reminded last night. If you don't want my SoB on the parts I didn't do -
>>>> namely unrealize and *_childen - then feel free to split the patch in
>>>> two. Simply dropping attribution in both cover letter and commit just
>>>> because I didn't get around yet to sending a v2 with those requests
>>>> addressed is not nice!
>>>
>>> Technically it's not, because I redid it from scratch (I never even had
>>> time to really look at your patches beyond reading the commit message,
>>> and I did this part while I didn't even have network access).
>>
>> That's just as lame an accuse
> 
> (Did you mean excuse?)

Yes.

>  It's a fact, not an excuse.  Do I need to show
> the two patches side-by-side?  That would be even more ridiculous.

Here's how I see it:

* You add a realize callback to ObjectClass like I did, you add the
Error** parameter that was requested as feedback to mine.
* You add a static object_realize() method that clashes with my
introducing it as a public wrapper function.
* You introduce a function object_get_realized() like I did, only you
defer your implementation to object_is_realized() which I didn't have
and used a new bool realized instead of a state enum (since I left qdev
unmodified).
* You introduce a function object_set_realized() like I did, only you
change the logic to also do unrealize.
* You introduce additional stuff that I don't particularly care about.

So my point is, whether you've read some patch or not, I just can't
understand why you couldn't wait a week for me to resend the updated
version and rush it so much that you ignore existing patches that were
actually coordinated with Anthony
(https://github.com/afaerber/qemu-cpu/commit/bc78ab1c0e4ba375bc5942447644323281184a31
on qom-cpu-sh4 branch already incorporates pm215's wish of a dedicated
QERR, f.ex.).

While having unrealize and propagation is certainly nice, the most
serious issue with yours I see is that it doesn't offer me a way to
actually make use of it outside qdev, so that *I* am left with no
benefit from your patch!

Some practical thoughts on how to align both approaches would be helpful
here. For starters, should I name my function object_realize_nofail()
instead? And could you prefer _one over _1 in your patch please?

If your problem is Signed-off-by specifically, feel free to invent some
inofficial tag such as Inspired-by or Derived-from-commit-message-by or
resort to a textual reference.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-05 13:31           ` Andreas Färber
@ 2012-04-05 14:16             ` Paolo Bonzini
  2012-04-05 15:13               ` Anthony Liguori
  0 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-04-05 14:16 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Peter Maydell, aliguori, qemu-devel, Anthony Liguori

Il 05/04/2012 15:31, Andreas Färber ha scritto:
> Here's how I see it:
> 
> * You add a realize callback to ObjectClass like I did, you add the
> Error** parameter that was requested as feedback to mine.
> * You add a static object_realize() method that clashes with my
> introducing it as a public wrapper function.
> * You introduce a function object_get_realized() like I did, only you
> defer your implementation to object_is_realized() which I didn't have
> and used a new bool realized instead of a state enum (since I left qdev
> unmodified).
> * You introduce a function object_set_realized() like I did, only you
> change the logic to also do unrealize.
> * You introduce additional stuff that I don't particularly care about.

Since we're nitpicking, I also do correct error propagation.

> So my point is, whether you've read some patch or not, I just can't
> understand why you couldn't wait a week for me to resend the updated
> version

Because a week is a long time 10 days before the feature freeze, and
(via object_is_realized and a few other small bits) the whole series
depends on the implementation of realized.

> While having unrealize and propagation is certainly nice, the most
> serious issue with yours I see is that it doesn't offer me a way to
> actually make use of it outside qdev, so that *I* am left with no
> benefit from your patch!

Can you explain?  I definitely would need to fix this.

> Some practical thoughts on how to align both approaches would be helpful
> here. For starters, should I name my function object_realize_nofail()
> instead?

Yes, that would be an idea.  I would hope that long-term there would be
only one object_realize call during in initial machine creation (i.e.
except for hot-plug), but it would be fine as a start.

> And could you prefer _one over _1 in your patch please?

Yes.

> If your problem is Signed-off-by specifically, feel free to invent some
> inofficial tag such as Inspired-by or Derived-from-commit-message-by or
> resort to a textual reference.

I can add the SoB, no problem.

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-05 14:16             ` Paolo Bonzini
@ 2012-04-05 15:13               ` Anthony Liguori
  0 siblings, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-04-05 15:13 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Peter Maydell, aliguori, qemu-devel, Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 2705 bytes --]

Hi,

I'm about to board a plane but I at least want to comment that we should
all give each other the benefit of the doubt in a situation like this.
Everyone on this thread is a long term contributer to QEMU that has more
than earned the right not to be accussed of impropriety.  Let's all take a
deep breathe and tone down this discussion in this thread by assuming that
noone is intentionally doing anything wrong
On Apr 5, 2012 9:17 AM, "Paolo Bonzini" <pbonzini@redhat.com> wrote:

> Il 05/04/2012 15:31, Andreas Färber ha scritto:
> > Here's how I see it:
> >
> > * You add a realize callback to ObjectClass like I did, you add the
> > Error** parameter that was requested as feedback to mine.
> > * You add a static object_realize() method that clashes with my
> > introducing it as a public wrapper function.
> > * You introduce a function object_get_realized() like I did, only you
> > defer your implementation to object_is_realized() which I didn't have
> > and used a new bool realized instead of a state enum (since I left qdev
> > unmodified).
> > * You introduce a function object_set_realized() like I did, only you
> > change the logic to also do unrealize.
> > * You introduce additional stuff that I don't particularly care about.
>
> Since we're nitpicking, I also do correct error propagation.
>
> > So my point is, whether you've read some patch or not, I just can't
> > understand why you couldn't wait a week for me to resend the updated
> > version
>
> Because a week is a long time 10 days before the feature freeze, and
> (via object_is_realized and a few other small bits) the whole series
> depends on the implementation of realized.
>
> > While having unrealize and propagation is certainly nice, the most
> > serious issue with yours I see is that it doesn't offer me a way to
> > actually make use of it outside qdev, so that *I* am left with no
> > benefit from your patch!
>
> Can you explain?  I definitely would need to fix this.
>
> > Some practical thoughts on how to align both approaches would be helpful
> > here. For starters, should I name my function object_realize_nofail()
> > instead?
>
> Yes, that would be an idea.  I would hope that long-term there would be
> only one object_realize call during in initial machine creation (i.e.
> except for hot-plug), but it would be fine as a start.
>
> > And could you prefer _one over _1 in your patch please?
>
> Yes.
>
> > If your problem is Signed-off-by specifically, feel free to invent some
> > inofficial tag such as Inspired-by or Derived-from-commit-message-by or
> > resort to a textual reference.
>
> I can add the SoB, no problem.
>
> Paolo
>

[-- Attachment #2: Type: text/html, Size: 3173 bytes --]

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-04-03 11:15 ` [Qemu-devel] [PATCH 23/25] qom: add realized property Paolo Bonzini
  2012-04-03 12:11   ` Andreas Färber
@ 2012-05-09 20:01   ` Igor Mammedov
  2012-05-10  7:05     ` Paolo Bonzini
  1 sibling, 1 reply; 57+ messages in thread
From: Igor Mammedov @ 2012-05-09 20:01 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: aliguori, qemu-devel, afaerber

Hi Paolo,

Are you plannig to respin this and related patches?
If yes, when?

On Tue, Apr 03, 2012 at 01:15:51PM +0200, Paolo Bonzini wrote:
> 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.
> 
> Unrealize is also called by object_deinit, as a separate step before
> finalization.
> 
> 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.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu/object.h |   20 +++++++++++
>  qom/object.c          |   93 +++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 113 insertions(+)
> 
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index 6db376d..6bded2a 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -245,6 +245,10 @@ struct ObjectClass
>  
>      /*< public >*/
>      Property *props;
> +    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 {
> @@ -463,6 +467,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.
> diff --git a/qom/object.c b/qom/object.c
> index 3a6b37b..2a3753a 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -259,6 +259,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_CREATED && klass->unrealize) {
> +        klass->unrealize(obj);
> +    }
> +    obj->state = OBJECT_STATE_CREATED;
> +}
> +
> +static int object_unrealize_1(Object *obj, void *unused)
> +{
> +    object_unrealize(obj);
> +    return 0;
> +}
> +
> +void object_unrealize_children(Object *obj)
> +{
> +    object_child_foreach(obj, object_unrealize_1, 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_1(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_1, 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;
> @@ -337,6 +418,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);
>      }
> @@ -1239,7 +1322,10 @@ static void object_instance_init(Object *obj)
>      Property *prop;
>  
>      object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
> +
>      obj->state = OBJECT_STATE_CREATED;
> +    object_property_add(obj, "realized", "bool", object_get_realized,
> +                        object_set_realized, NULL, NULL, NULL);
>  
>      class = object_get_class(obj);
>      do {
> @@ -1250,6 +1336,12 @@ static void object_instance_init(Object *obj)
>      } while (class != object_class_by_name(TYPE_OBJECT));
>  }
>  
> +static void object_class_init(ObjectClass *klass, void *class_data)
> +{
> +    klass->realize_children = object_realize_children;
> +    klass->unrealize_children = object_unrealize_children;
> +}
> +
>  static void register_types(void)
>  {
>      static TypeInfo interface_info = {
> @@ -1262,6 +1354,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,
>          .abstract = true,
>      };
> -- 
> 1.7.9.3
> 

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-05-09 20:01   ` Igor Mammedov
@ 2012-05-10  7:05     ` Paolo Bonzini
  2012-05-10 10:01       ` Andreas Färber
  0 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-05-10  7:05 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: aliguori, qemu-devel, afaerber

Il 09/05/2012 22:01, Igor Mammedov ha scritto:
> Hi Paolo,
> 
> Are you plannig to respin this and related patches?
> If yes, when?

After the first part goes in (21 patches including Anthony's bus
series).  A reviewed-by from Andreas or Anthony would help, so that I
can make Andreas's suggested documentation changes and send a pull
request to someone.

Andreas, would you object to being honorary maintainer of qom-next for
this month?

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-05-10  7:05     ` Paolo Bonzini
@ 2012-05-10 10:01       ` Andreas Färber
  2012-05-10 12:19         ` Anthony Liguori
  0 siblings, 1 reply; 57+ messages in thread
From: Andreas Färber @ 2012-05-10 10:01 UTC (permalink / raw)
  To: Paolo Bonzini, aliguori; +Cc: Igor Mammedov, qemu-devel

Am 10.05.2012 09:05, schrieb Paolo Bonzini:
> Il 09/05/2012 22:01, Igor Mammedov ha scritto:
>> Hi Paolo,
>>
>> Are you plannig to respin this and related patches?
>> If yes, when?
> 
> After the first part goes in (21 patches including Anthony's bus
> series).  A reviewed-by from Andreas or Anthony would help, so that I
> can make Andreas's suggested documentation changes and send a pull
> request to someone.
> 
> Andreas, would you object to being honorary maintainer of qom-next for
> this month?

Sometimes there's so many trees that one doesn't see the forrest... I
brought that topic up in
http://lists.gnu.org/archive/html/qemu-devel/2012-05/msg00926.html:

> there's more and more colliding patch series on the list -
> fixed-width visitors, realize, QBus, VMState, AREG0, CPU - for which we
> need a strategy to coordinate our ongoing development and post-1.1
> merging. Someone needs to rebase on someone else, question is whom.

If Anthony is okay with me maintaining a qom-next branch then I'd
happily do that! It doesn't relieve us of reviewing and acking each
other's patches though. And in particular we need to figure out how to
proceed with your and Anthony's series - I have stated opinions on some
parts, but it's Anthony's baby.

Also, I still think there's at least one patch in your series that
should go into 1.1 (the -device fix thingy).

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 23/25] qom: add realized property
  2012-05-10 10:01       ` Andreas Färber
@ 2012-05-10 12:19         ` Anthony Liguori
  0 siblings, 0 replies; 57+ messages in thread
From: Anthony Liguori @ 2012-05-10 12:19 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Paolo Bonzini, aliguori, qemu-devel, Igor Mammedov

On 05/10/2012 05:01 AM, Andreas Färber wrote:
> Am 10.05.2012 09:05, schrieb Paolo Bonzini:
>> Il 09/05/2012 22:01, Igor Mammedov ha scritto:
>>> Hi Paolo,
>>>
>>> Are you plannig to respin this and related patches?
>>> If yes, when?
>>
>> After the first part goes in (21 patches including Anthony's bus
>> series).  A reviewed-by from Andreas or Anthony would help, so that I
>> can make Andreas's suggested documentation changes and send a pull
>> request to someone.
>>
>> Andreas, would you object to being honorary maintainer of qom-next for
>> this month?
>
> Sometimes there's so many trees that one doesn't see the forrest... I
> brought that topic up in
> http://lists.gnu.org/archive/html/qemu-devel/2012-05/msg00926.html:
>
>> there's more and more colliding patch series on the list -
>> fixed-width visitors, realize, QBus, VMState, AREG0, CPU - for which we
>> need a strategy to coordinate our ongoing development and post-1.1
>> merging. Someone needs to rebase on someone else, question is whom.
>
> If Anthony is okay with me maintaining a qom-next branch then I'd
> happily do that! It doesn't relieve us of reviewing and acking each
> other's patches though. And in particular we need to figure out how to
> proceed with your and Anthony's series - I have stated opinions on some
> parts, but it's Anthony's baby.

Yeah, I'd be more than happy with you maintaining a qom-next tree.

Regards,

Anthony Liguori

>
> Also, I still think there's at least one patch in your series that
> should go into 1.1 (the -device fix thingy).
>
> Andreas
>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-04-03 21:06   ` Anthony Liguori
@ 2012-05-10 20:58     ` Jan Kiszka
  2012-05-11 11:28       ` Paolo Bonzini
  0 siblings, 1 reply; 57+ messages in thread
From: Jan Kiszka @ 2012-05-10 20:58 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Paolo Bonzini, aliguori, qemu-devel, afaerber

On 2012-04-03 18:06, Anthony Liguori wrote:
> On 04/03/2012 06:15 AM, Paolo Bonzini wrote:
>> Otherwise, non-string properties without a legacy counterpart are missed.
>> Also fix error propagation in object_property_print itself, otherwise
>> pointer properties are printed as "<null>".
>>
>> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> 
> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
> 

The bug that this fixes is still present in current 1.1-rc. Any chance
that the patch makes it into the release?

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-05-10 20:58     ` Jan Kiszka
@ 2012-05-11 11:28       ` Paolo Bonzini
  2012-05-11 11:38         ` Andreas Färber
  0 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-05-11 11:28 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: aliguori, qemu-devel, Anthony Liguori, afaerber

Il 10/05/2012 22:58, Jan Kiszka ha scritto:
>>> >> Otherwise, non-string properties without a legacy counterpart are missed.
>>> >> Also fix error propagation in object_property_print itself, otherwise
>>> >> pointer properties are printed as "<null>".
>>> >>
>>> >> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
>> > 
>> > Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
>> > 
> The bug that this fixes is still present in current 1.1-rc. Any chance
> that the patch makes it into the release?

Andreas, are you queueing this patch and 6/25 for 1.1-rc2?

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-05-11 11:28       ` Paolo Bonzini
@ 2012-05-11 11:38         ` Andreas Färber
  0 siblings, 0 replies; 57+ messages in thread
From: Andreas Färber @ 2012-05-11 11:38 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Jan Kiszka, aliguori, qemu-devel, Anthony Liguori

Am 11.05.2012 13:28, schrieb Paolo Bonzini:
> Il 10/05/2012 22:58, Jan Kiszka ha scritto:
>>>>>> Otherwise, non-string properties without a legacy counterpart are missed.
>>>>>> Also fix error propagation in object_property_print itself, otherwise
>>>>>> pointer properties are printed as "<null>".
>>>>>>
>>>>>> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
>>>>
>>>> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
>>>>
>> The bug that this fixes is still present in current 1.1-rc. Any chance
>> that the patch makes it into the release?
> 
> Andreas, are you queueing this patch and 6/25 for 1.1-rc2?

I need to review it first and I try to pick the latest one (which would
presumable be in the QBus series), but yes, this and one other of yours
(the one with the prop->set or so check) is on my radar for 1.1-rc2.

I think I'll start a qom-1.1 branch to make this more transparent.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-04-03 13:05     ` Paolo Bonzini
@ 2012-05-11 14:10       ` Andreas Färber
  2012-05-16  7:40         ` Paolo Bonzini
  0 siblings, 1 reply; 57+ messages in thread
From: Andreas Färber @ 2012-05-11 14:10 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Jan Kiszka, aliguori, qemu-devel

Am 03.04.2012 15:05, schrieb Paolo Bonzini:
> Il 03/04/2012 14:28, Jan Kiszka ha scritto:
>>>>          if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
>>>>              value = object_property_get_str(OBJECT(dev), legacy_name, &err);
>> This is not a criticism on this patch, but I'd like to underline that
>> the line above only works because legacy props also define print
>                                                  ^^^^
> 
> You mean always, I guess.
> 
>> But this statement above is still inconsistent. We should either
>> assert(print && parse) or handle their non-existence properly.
> 
> Yes, asserting that print/parse are always present in pairs (if at all)
> would be good.

Paolo, has this issue been addressed somewhere?

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-05-11 14:10       ` Andreas Färber
@ 2012-05-16  7:40         ` Paolo Bonzini
  2012-05-16  7:43           ` Paolo Bonzini
  0 siblings, 1 reply; 57+ messages in thread
From: Paolo Bonzini @ 2012-05-16  7:40 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Jan Kiszka, aliguori, qemu-devel

> Am 03.04.2012 15:05, schrieb Paolo Bonzini:
> > Il 03/04/2012 14:28, Jan Kiszka ha scritto:
> >>>>          if (object_property_get_type(OBJECT(dev), legacy_name,
> >>>>          NULL)) {
> >>>>              value = object_property_get_str(OBJECT(dev),
> >>>>              legacy_name, &err);
> >> [...] We should either
> >> assert(print && parse) or handle their non-existence properly.
> > 
> > Yes, asserting that print/parse are always present in pairs (if at
> > all) would be good.
> 
> Paolo, has this issue been addressed somewhere?

No, but it's a simple assertion.  It doesn't look like 1.1 material.
I should send and rebase the bus series today, I'll include it.

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
  2012-05-16  7:40         ` Paolo Bonzini
@ 2012-05-16  7:43           ` Paolo Bonzini
  0 siblings, 0 replies; 57+ messages in thread
From: Paolo Bonzini @ 2012-05-16  7:43 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Jan Kiszka, aliguori, qemu-devel



----- Messaggio originale -----
> Da: "Paolo Bonzini" <pbonzini@redhat.com>
> A: "Andreas Färber" <afaerber@suse.de>
> Cc: "Jan Kiszka" <jan.kiszka@siemens.com>, aliguori@us.ibm.com, qemu-devel@nongnu.org
> Inviato: Mercoledì, 16 maggio 2012 9:40:12
> Oggetto: Re: [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree
>
> > Am 03.04.2012 15:05, schrieb Paolo Bonzini:
> > > Il 03/04/2012 14:28, Jan Kiszka ha scritto:
> > >>>>          if (object_property_get_type(OBJECT(dev),
> > >>>>          legacy_name,
> > >>>>          NULL)) {
> > >>>>              value = object_property_get_str(OBJECT(dev),
> > >>>>              legacy_name, &err);
> > >> [...] We should either
> > >> assert(print && parse) or handle their non-existence properly.
> > >
> > > Yes, asserting that print/parse are always present in pairs (if
> > > at
> > > all) would be good.
> >
> > Paolo, has this issue been addressed somewhere?
>
> No, but it's a simple assertion.  It doesn't look like 1.1 material.
> I should send and rebase the bus series today, I'll include it.

Doh, it was handled by

commit 68ee356941801d0a17fdc43b11ac3e6b72fcd597
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Thu Feb 2 10:17:19 2012 +0100

    qdev: allow reusing get/set for legacy property

print/parse do not have to be present in pairs anymore.

Paolo

^ permalink raw reply	[flat|nested] 57+ messages in thread

end of thread, other threads:[~2012-05-16  7:43 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-03 11:15 [Qemu-devel] [PATCH 00/25] qdev properties final installment: push, push! Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent Paolo Bonzini
2012-04-03 20:50   ` Anthony Liguori
2012-04-03 11:15 ` [Qemu-devel] [PATCH 02/25] qom: add object_child_foreach Paolo Bonzini
2012-04-03 20:51   ` Anthony Liguori
2012-04-03 11:15 ` [Qemu-devel] [PATCH 03/25] qom: add class_base_init Paolo Bonzini
2012-04-03 20:51   ` Anthony Liguori
2012-04-03 11:15 ` [Qemu-devel] [PATCH 04/25] qom: make Object a type Paolo Bonzini
2012-04-03 12:30   ` Andreas Färber
2012-04-03 13:06     ` Paolo Bonzini
2012-04-03 20:52   ` Anthony Liguori
2012-04-03 11:15 ` [Qemu-devel] [PATCH 05/25] qom: push type up to Object Paolo Bonzini
2012-04-03 12:33   ` Andreas Färber
2012-04-03 20:55   ` Anthony Liguori
2012-04-03 11:15 ` [Qemu-devel] [PATCH 06/25] qdev: fix -device foo,? Paolo Bonzini
2012-04-03 20:59   ` Anthony Liguori
2012-04-03 11:15 ` [Qemu-devel] [PATCH 07/25] qdev: use object_property_print in info qtree Paolo Bonzini
2012-04-03 12:28   ` Jan Kiszka
2012-04-03 13:05     ` Paolo Bonzini
2012-05-11 14:10       ` Andreas Färber
2012-05-16  7:40         ` Paolo Bonzini
2012-05-16  7:43           ` Paolo Bonzini
2012-04-03 21:06   ` Anthony Liguori
2012-05-10 20:58     ` Jan Kiszka
2012-05-11 11:28       ` Paolo Bonzini
2012-05-11 11:38         ` Andreas Färber
2012-04-03 11:15 ` [Qemu-devel] [PATCH 08/25] qdev: remove qdev_prop_set_defaults Paolo Bonzini
2012-04-03 21:09   ` Anthony Liguori
2012-04-03 21:43     ` Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 09/25] qdev: move bus properties to a separate global Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 10/25] qdev: do not propagate properties to subclasses Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 11/25] qdev: pick global properties from superclasses Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 12/25] qdev: factor setting of global properties Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 13/25] qdev: replace bus properties with superclass properties Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 14/25] qapi: add Visitor interfaces for uint*_t and int*_t Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 15/25] qdev: use int32_t container for devfn property Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 16/25] qdev: switch property accessors to fixed-width visitor interfaces Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 17/25] qdev: remove PropertyInfo range checking Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 18/25] qdev: remove qdev_prop_exists Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 19/25] qom: push state up to Object Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 20/25] qdev: generalize properties to Objects Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 21/25] qdev: move bulk of qdev-properties.c to qom/object.c Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 22/25] qom: push static properties to Object Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 23/25] qom: add realized property Paolo Bonzini
2012-04-03 12:11   ` Andreas Färber
2012-04-03 13:03     ` Paolo Bonzini
2012-04-05 12:04       ` Andreas Färber
2012-04-05 12:36         ` Paolo Bonzini
2012-04-05 13:31           ` Andreas Färber
2012-04-05 14:16             ` Paolo Bonzini
2012-04-05 15:13               ` Anthony Liguori
2012-05-09 20:01   ` Igor Mammedov
2012-05-10  7:05     ` Paolo Bonzini
2012-05-10 10:01       ` Andreas Färber
2012-05-10 12:19         ` Anthony Liguori
2012-04-03 11:15 ` [Qemu-devel] [PATCH 24/25] qdev: implement qdev_init on top of realize Paolo Bonzini
2012-04-03 11:15 ` [Qemu-devel] [PATCH 25/25] qdev: split part of device_finalize to device_unrealize Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.