qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 3/4] qdev: give all devices a canonical path


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 3/4] qdev: give all devices a canonical path
Date: Tue, 27 Mar 2012 16:12:07 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120310 Thunderbird/11.0

On 03/27/2012 11:38 AM, Paolo Bonzini wrote:
A strong limitation of QOM right now is that unconverted ports
(e.g. all...) do not give a canonical path to devices that are
part of the board.  This in turn makes it impossible to replace
PROP_PTR with a QOM link for example.

Signed-off-by: Paolo Bonzini<address@hidden>

Reviewed-by: Anthony Liguori <address@hidden>

Regards,

Anthony Liguori

---
  hw/qdev.c |   16 +++++++++++++---
  1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index ee21d90..f5c716e 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -113,14 +113,14 @@ DeviceState *qdev_create(BusState *bus, const char *name)
      return dev;
  }

-DeviceState *qdev_try_create(BusState *bus, const char *name)
+DeviceState *qdev_try_create(BusState *bus, const char *type)
  {
      DeviceState *dev;

-    if (object_class_by_name(name) == NULL) {
+    if (object_class_by_name(type) == NULL) {
          return NULL;
      }
-    dev = DEVICE(object_new(name));
+    dev = DEVICE(object_new(type));
      if (!dev) {
          return NULL;
      }
@@ -152,6 +152,16 @@ int qdev_init(DeviceState *dev)
          qdev_free(dev);
          return rc;
      }
+
+    if (!OBJECT(dev)->parent) {
+        static int unattached_count = 0;
+        gchar *name = g_strdup_printf("device[%d]", unattached_count++);
+
+        object_property_add_child(container_get("/unattached"), name,
+                                  OBJECT(dev), NULL);
+        g_free(name);
+    }
+
      if (qdev_get_vmsd(dev)) {
          vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
                                         dev->instance_id_alias,




reply via email to

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