From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXX80-00049U-M4 for qemu-devel@nongnu.org; Thu, 03 Sep 2015 12:12:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXX7w-0006d1-Oh for qemu-devel@nongnu.org; Thu, 03 Sep 2015 12:12:44 -0400 Received: from mail-qg0-x234.google.com ([2607:f8b0:400d:c04::234]:33124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXX7w-0006cp-Jg for qemu-devel@nongnu.org; Thu, 03 Sep 2015 12:12:40 -0400 Received: by qgev79 with SMTP id v79so32358745qge.0 for ; Thu, 03 Sep 2015 09:12:40 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/alternative; boundary=Apple-Mail-4--866909438 From: Programmingkid In-Reply-To: <20150903144309.GB19447@localhost.localdomain> Date: Thu, 3 Sep 2015 12:12:38 -0400 Message-Id: <58EAC71D-E839-40E7-97B7-28C7400536D1@gmail.com> References: <29C62C49-06A5-4F99-8062-7269A28C29A3@gmail.com> <8737z7o85i.fsf@blackfin.pond.sub.org> <441C227A-2CF0-43AE-AC7F-B066708CEABD@gmail.com> <87fv36j9j6.fsf@blackfin.pond.sub.org> <117F603F-1907-4D9A-B5F9-4164A76FBBAF@gmail.com> <20150903144309.GB19447@localhost.localdomain> Subject: [Qemu-devel] [PATCH v3] qdev-monitor.c: Add device id generation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: Kevin Wolf , Peter Maydell , Markus Armbruster , qemu-devel qemu-devel , Paolo Bonzini , =?iso-8859-1?Q?Andreas_F=E4rber?= --Apple-Mail-4--866909438 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Give an automatically generated ID to a device that wasn't given one by the user.=20 Signed-off-by: John Arbuckle --- Replaced my original ID generation code with Jeff Cody's id_generate() function. qdev-monitor.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index f9e2d62..a9c54bd 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -574,18 +574,12 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error = **errp) id =3D qemu_opts_id(opts); if (id) { dev->id =3D id; + } else { + dev->id =3D id_generate(ID_QDEV); } =20 - if (dev->id) { - object_property_add_child(qdev_get_peripheral(), dev->id, - OBJECT(dev), NULL); - } else { - static int anon_count; - gchar *name =3D g_strdup_printf("device[%d]", anon_count++); - object_property_add_child(qdev_get_peripheral_anon(), name, + object_property_add_child(qdev_get_peripheral(), dev->id, OBJECT(dev), NULL); - g_free(name); - } =20 /* set properties */ if (qemu_opt_foreach(opts, set_property, dev, &err)) { --=20 1.7.5.4 --Apple-Mail-4--866909438 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Give an automatically generated ID to = a device that wasn't given one
by the user. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>= ;

---
Replaced my original ID = generation code with Jeff Cody's id_generate()

 qdev-monitor.c |   = 12 +++---------
 1 files changed, 3 insertions(+), 9 = deletions(-)

diff --git a/qdev-monitor.c = b/qdev-monitor.c
index f9e2d62..a9c54bd 100644
--- = a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -574,18 +574,12 @@ = DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
         = dev->id =3D id;
+    } else {
     }

 

-        = object_property_add_child(qdev_get_peripheral(), dev->id,
-    } else {
             =                     =   OBJECT(dev), NULL);
-        = g_free(name);
-    }

 

     /* set properties = */
-- 
1.7.5.4