From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXRqg-0001wg-09 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 05:30:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXRqY-0007gB-H6 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 05:29:57 -0400 Received: from cantor2.suse.de ([195.135.220.15]:41449 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXRqY-0007er-AY for qemu-devel@nongnu.org; Fri, 26 Sep 2014 05:29:50 -0400 Message-ID: <54253205.90701@suse.de> Date: Fri, 26 Sep 2014 11:29:41 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <455e2daf231fd33c3e828936c7e1e07d27c17dac.1411019133.git.zhugh.fnst@cn.fujitsu.com> In-Reply-To: <455e2daf231fd33c3e828936c7e1e07d27c17dac.1411019133.git.zhugh.fnst@cn.fujitsu.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhu Guihua , qemu-devel@nongnu.org, aliguori@amazon.com, lcapitulino@redhat.com Cc: hutao@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, tangchen@cn.fujitsu.com Hi, Am 18.09.2014 um 09:53 schrieb Zhu Guihua: > Add peripheral_device_del_completion() to let peripheral device del com= pletion > be possible. >=20 > Signed-off-by: Zhu Guihua > --- > monitor.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) >=20 > diff --git a/monitor.c b/monitor.c > index 667efb7..c0e00e4 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -4351,6 +4351,29 @@ static void device_del_bus_completion(ReadLineSt= ate *rs, BusState *bus, > } > } > =20 > +static void peripheral_device_del_completion(ReadLineState *rs, > + const char *str, size_t l= en) > +{ > + Object *peripheral; > + DeviceState *dev =3D NULL; > + ObjectProperty *prop; > + > + peripheral =3D object_resolve_path("/machine/peripheral/", NULL); > + > + if (peripheral =3D=3D NULL) { > + return; > + } > + > + QTAILQ_FOREACH(prop, &peripheral->properties, node) { > + if (object_property_is_child(prop)) { > + dev =3D DEVICE(object_property_get_opaque(prop, NULL)); Why so complicated? Can't you use object_child_foreach()? That would obsolete patches 1-2, leaving the gory details in QOM code and making this a monitor-only series. > + if (dev->id && !strncmp(str, dev->id, len)) { All devices in /machine/peripheral/ should have an id, but better safe than sorry. :) If you do respin, I'd have a preference for strncmp() =3D=3D 0 for clarit= y. > + readline_add_completion(rs, dev->id); > + } > + } > + } > +} > + > void chardev_remove_completion(ReadLineState *rs, int nb_args, const c= har *str) > { > size_t len; > @@ -4424,6 +4447,7 @@ void device_del_completion(ReadLineState *rs, int= nb_args, const char *str) > len =3D strlen(str); > readline_set_completion_index(rs, len); > device_del_bus_completion(rs, sysbus_get_default(), str, len); > + peripheral_device_del_completion(rs, str, len); > } > =20 > void object_del_completion(ReadLineState *rs, int nb_args, const char = *str) Whether these two are correct, would then just need to be reviewed by someone who knows about completion (not me). Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg