qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 03/14] qdev: add qdev_add_properties


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 03/14] qdev: add qdev_add_properties
Date: Tue, 01 May 2012 15:37:17 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1

On 05/01/2012 02:05 PM, Andreas Färber wrote:
Am 01.05.2012 20:18, schrieb Anthony Liguori:
This allows a base class to easily add properties.

Signed-off-by: Anthony Liguori<address@hidden>

Implementation looks okay but /me not so happy with it: This conflicts
with the move of the qdev static property infrastructure from
DeviceState to Object.

Consider rebasing this onto part of Paolo's series and call it
object_add_properties?

Eh? There's nothing object_ about these properties and there's no way I'm willing to put legacy properties in object...

So I'm not quite sure what you're suggesting.

Regards,

Anthony Liguori


Andreas

---
  hw/qdev.c |   25 ++++++++++++-------------
  hw/qdev.h |    2 ++
  2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 6a8f6bd..e17a9ab 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -76,22 +76,26 @@ bool qdev_exists(const char *name)
  static void qdev_property_add_legacy(DeviceState *dev, Property *prop,
                                       Error **errp);

-void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
+void qdev_add_properties(DeviceState *dev, Property *props)
  {
      Property *prop;

+    for (prop = props; prop&&  prop->name; prop++) {
+        qdev_property_add_legacy(dev, prop, NULL);
+        qdev_property_add_static(dev, prop, NULL);
+    }
+    qdev_prop_set_defaults(dev, props);
+}
+
+void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
+{
      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);
-    }
-    qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
+    qdev_add_properties(dev, dev->parent_bus->info->props);
  }

  /* Create a new device.  This only initializes the device state structure
@@ -633,13 +637,8 @@ 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);
-    }
-
+    qdev_add_properties(dev, qdev_get_props(dev));
      object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, 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 4e90119..ca8386a 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -360,4 +360,6 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus);

  extern int qdev_hotplug;

+void qdev_add_properties(DeviceState *dev, Property *props);
+
  #endif






reply via email to

[Prev in Thread] Current Thread [Next in Thread]