From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCdhT-0003mn-04 for qemu-devel@nongnu.org; Tue, 27 Mar 2012 17:13:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCdhR-00061p-6E for qemu-devel@nongnu.org; Tue, 27 Mar 2012 17:13:06 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:57769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCdhQ-00061b-Vt for qemu-devel@nongnu.org; Tue, 27 Mar 2012 17:13:05 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Mar 2012 15:13:00 -0600 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 10A58C9006D for ; Tue, 27 Mar 2012 17:12:57 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q2RLCtIs255120 for ; Tue, 27 Mar 2012 17:12:56 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q2RLCsZL015099 for ; Tue, 27 Mar 2012 18:12:54 -0300 Message-ID: <4F722D27.40909@us.ibm.com> Date: Tue, 27 Mar 2012 16:12:07 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1332866328-25443-1-git-send-email-pbonzini@redhat.com> <1332866328-25443-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1332866328-25443-4-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [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: Paolo Bonzini Cc: aliguori@linux.vnet.ibm.com, andreas.faerber@web.de, qemu-devel@nongnu.org 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 Reviewed-by: Anthony Liguori 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,