From: "Andreas Färber" <afaerber@suse.de>
To: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>,
qemu-devel@nongnu.org, aliguori@amazon.com,
lcapitulino@redhat.com
Cc: hutao@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com,
tangchen@cn.fujitsu.com
Subject: Re: [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device
Date: Fri, 26 Sep 2014 11:29:41 +0200 [thread overview]
Message-ID: <54253205.90701@suse.de> (raw)
In-Reply-To: <455e2daf231fd33c3e828936c7e1e07d27c17dac.1411019133.git.zhugh.fnst@cn.fujitsu.com>
Hi,
Am 18.09.2014 um 09:53 schrieb Zhu Guihua:
> Add peripheral_device_del_completion() to let peripheral device del completion
> be possible.
>
> Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
> ---
> monitor.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> 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(ReadLineState *rs, BusState *bus,
> }
> }
>
> +static void peripheral_device_del_completion(ReadLineState *rs,
> + const char *str, size_t len)
> +{
> + Object *peripheral;
> + DeviceState *dev = NULL;
> + ObjectProperty *prop;
> +
> + peripheral = object_resolve_path("/machine/peripheral/", NULL);
> +
> + if (peripheral == NULL) {
> + return;
> + }
> +
> + QTAILQ_FOREACH(prop, &peripheral->properties, node) {
> + if (object_property_is_child(prop)) {
> + dev = 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() == 0 for clarity.
> + readline_add_completion(rs, dev->id);
> + }
> + }
> + }
> +}
> +
> void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str)
> {
> size_t len;
> @@ -4424,6 +4447,7 @@ void device_del_completion(ReadLineState *rs, int nb_args, const char *str)
> len = 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);
> }
>
> 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
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2014-09-26 9:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 7:53 [Qemu-devel] [PATCH v1 0/3] monitor: add peripheral device del completion support Zhu Guihua
2014-09-18 7:53 ` [Qemu-devel] [PATCH v1 1/3] qom: add function to get opaque property in ObjectProperty Zhu Guihua
2014-09-18 7:53 ` [Qemu-devel] [PATCH v1 2/3] qom: export object_property_is_child() Zhu Guihua
2014-09-26 9:31 ` Andreas Färber
2014-09-18 7:53 ` [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device Zhu Guihua
2014-09-26 9:29 ` Andreas Färber [this message]
2014-09-26 17:25 ` Luiz Capitulino
2014-09-26 17:29 ` Luiz Capitulino
2014-09-29 21:33 ` Hani Benhabiles
2014-09-26 2:01 ` [Qemu-devel] [PATCH v1 0/3] monitor: add peripheral device del completion support Zhu Guihua
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54253205.90701@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=hutao@cn.fujitsu.com \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=tangchen@cn.fujitsu.com \
--cc=zhugh.fnst@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).