From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYgmF-0007c1-Qa for qemu-devel@nongnu.org; Thu, 08 Dec 2011 11:24:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYgmB-0005se-Gm for qemu-devel@nongnu.org; Thu, 08 Dec 2011 11:24:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYgmB-0005sY-3z for qemu-devel@nongnu.org; Thu, 08 Dec 2011 11:24:51 -0500 Message-ID: <4EE0E578.10905@redhat.com> Date: Thu, 08 Dec 2011 17:27:36 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1322857256-14951-1-git-send-email-aliguori@us.ibm.com> <1322857256-14951-14-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1322857256-14951-14-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 13/18] dev: add an anonymous peripheral container List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , Stefan Hajnoczi , Jan Kiszka , qemu-devel@nongnu.org, Luiz Capitulino , Gerd Hoffman , Markus Armbruster Am 02.12.2011 21:20, schrieb Anthony Liguori: > Signed-off-by: Anthony Liguori > --- > hw/qdev.c | 21 ++++++++++++++++++++- > 1 files changed, 20 insertions(+), 1 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index af4c6a2..5348f26 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -240,6 +240,19 @@ static DeviceState *qdev_get_peripheral(void) > return dev; > } > > +static DeviceState *qdev_get_peripheral_anon(void) > +{ > + static DeviceState *dev; > + > + if (dev == NULL) { > + dev = qdev_create(NULL, "container"); > + qdev_property_add_child(qdev_get_root(), "peripheral-anon", dev, NULL); > + qdev_init_nofail(dev); > + } > + > + return dev; > +} > + > DeviceState *qdev_device_add(QemuOpts *opts) > { > const char *driver, *path, *id; > @@ -292,7 +305,13 @@ DeviceState *qdev_device_add(QemuOpts *opts) > if (id) { > qdev->id = id; > qdev_property_add_child(qdev_get_peripheral(), qdev->id, qdev, NULL); > - } > + } else { > + static int anon_count; > + gchar *name = g_strdup_printf("device[%d]", anon_count++); Does any code depend on this name? If not, I would suggest making it a bit more convenient for users: g_strdump_printf("%s[%d]", info->name, info->anon_count++) Kevin