From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCZQc-0008QE-Ly for qemu-devel@nongnu.org; Tue, 27 Mar 2012 12:39:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCZQT-00030D-HS for qemu-devel@nongnu.org; Tue, 27 Mar 2012 12:39:26 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:45017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCZQT-0002zC-9F for qemu-devel@nongnu.org; Tue, 27 Mar 2012 12:39:17 -0400 Received: by mail-pb0-f45.google.com with SMTP id uo5so523884pbc.4 for ; Tue, 27 Mar 2012 09:39:16 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 27 Mar 2012 18:38:47 +0200 Message-Id: <1332866328-25443-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1332866328-25443-1-git-send-email-pbonzini@redhat.com> References: <1332866328-25443-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/4] qdev: give all devices a canonical path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@linux.vnet.ibm.com, andreas.faerber@web.de 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 --- 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, -- 1.7.9.1