* [Qemu-devel] [PATCH v1 0/3] monitor: add peripheral device del completion support @ 2014-09-18 7:53 Zhu Guihua 2014-09-18 7:53 ` [Qemu-devel] [PATCH v1 1/3] qom: add function to get opaque property in ObjectProperty Zhu Guihua ` (3 more replies) 0 siblings, 4 replies; 10+ messages in thread From: Zhu Guihua @ 2014-09-18 7:53 UTC (permalink / raw) To: qemu-devel, aliguori, afaerber, lcapitulino Cc: hutao, isimatu.yasuaki, Zhu Guihua, tangchen After inputting device_del command in monitor, we expect to list all hotpluggable devices automatically by pressing tab key. This patchset provides the function to list all peripheral devices such as memory devices. Zhu Guihua (3): qom: add function to get opaque property in ObjectProperty qom: export object_property_is_child() monitor: add del completion for peripheral device include/qom/object.h | 2 ++ monitor.c | 24 ++++++++++++++++++++++++ qom/object.c | 11 ++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v1 1/3] qom: add function to get opaque property in ObjectProperty 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 ` Zhu Guihua 2014-09-18 7:53 ` [Qemu-devel] [PATCH v1 2/3] qom: export object_property_is_child() Zhu Guihua ` (2 subsequent siblings) 3 siblings, 0 replies; 10+ messages in thread From: Zhu Guihua @ 2014-09-18 7:53 UTC (permalink / raw) To: qemu-devel, aliguori, afaerber, lcapitulino Cc: hutao, isimatu.yasuaki, Zhu Guihua, tangchen Add object_property_get_opaque() to get opaque property in ObjectProperty. Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com> --- include/qom/object.h | 1 + qom/object.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 8a05a81..5d55889 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1300,5 +1300,6 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), */ Object *container_get(Object *root, const char *path); +void *object_property_get_opaque(ObjectProperty *prop, Error **errp); #endif diff --git a/qom/object.c b/qom/object.c index da0919a..00a25e0 100644 --- a/qom/object.c +++ b/qom/object.c @@ -356,6 +356,15 @@ static inline bool object_property_is_child(ObjectProperty *prop) return strstart(prop->type, "child<", NULL); } +void *object_property_get_opaque(ObjectProperty *prop, Error **errp) +{ + if (prop == NULL) { + return NULL; + } + + return prop->opaque; +} + static void object_property_del_all(Object *obj) { while (!QTAILQ_EMPTY(&obj->properties)) { -- 1.9.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v1 2/3] qom: export object_property_is_child() 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 ` 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 2:01 ` [Qemu-devel] [PATCH v1 0/3] monitor: add peripheral device del completion support Zhu Guihua 3 siblings, 1 reply; 10+ messages in thread From: Zhu Guihua @ 2014-09-18 7:53 UTC (permalink / raw) To: qemu-devel, aliguori, afaerber, lcapitulino Cc: hutao, isimatu.yasuaki, Zhu Guihua, tangchen Export object_property_is_child() to let it be invoked in other places. Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com> --- include/qom/object.h | 1 + qom/object.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/qom/object.h b/include/qom/object.h index 5d55889..8f27b7c 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1302,4 +1302,5 @@ Object *container_get(Object *root, const char *path); void *object_property_get_opaque(ObjectProperty *prop, Error **errp); +bool object_property_is_child(ObjectProperty *prop); #endif diff --git a/qom/object.c b/qom/object.c index 00a25e0..8de2599 100644 --- a/qom/object.c +++ b/qom/object.c @@ -351,7 +351,7 @@ void object_initialize(void *data, size_t size, const char *typename) object_initialize_with_type(data, size, type); } -static inline bool object_property_is_child(ObjectProperty *prop) +bool object_property_is_child(ObjectProperty *prop) { return strstart(prop->type, "child<", NULL); } -- 1.9.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v1 2/3] qom: export object_property_is_child() 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 0 siblings, 0 replies; 10+ messages in thread From: Andreas Färber @ 2014-09-26 9:31 UTC (permalink / raw) To: Zhu Guihua, qemu-devel, aliguori, lcapitulino Cc: hutao, isimatu.yasuaki, tangchen Am 18.09.2014 um 09:53 schrieb Zhu Guihua: > Export object_property_is_child() to let it be invoked in other places. > > Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com> > --- > include/qom/object.h | 1 + > qom/object.c | 2 +- > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/qom/object.h b/include/qom/object.h > index 5d55889..8f27b7c 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -1302,4 +1302,5 @@ Object *container_get(Object *root, const char *path); > > void *object_property_get_opaque(ObjectProperty *prop, Error **errp); > > +bool object_property_is_child(ObjectProperty *prop); You already dropped one white line in the previous patch, now you're leaving no spacing at all. Please always leave at least one before the header guard. Regards, Andreas > #endif > diff --git a/qom/object.c b/qom/object.c > index 00a25e0..8de2599 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -351,7 +351,7 @@ void object_initialize(void *data, size_t size, const char *typename) > object_initialize_with_type(data, size, type); > } > > -static inline bool object_property_is_child(ObjectProperty *prop) > +bool object_property_is_child(ObjectProperty *prop) > { > return strstart(prop->type, "child<", NULL); > } > -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device 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-18 7:53 ` Zhu Guihua 2014-09-26 9:29 ` Andreas Färber 2014-09-26 17:25 ` Luiz Capitulino 2014-09-26 2:01 ` [Qemu-devel] [PATCH v1 0/3] monitor: add peripheral device del completion support Zhu Guihua 3 siblings, 2 replies; 10+ messages in thread From: Zhu Guihua @ 2014-09-18 7:53 UTC (permalink / raw) To: qemu-devel, aliguori, afaerber, lcapitulino Cc: hutao, isimatu.yasuaki, Zhu Guihua, tangchen 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)); + if (dev->id && !strncmp(str, dev->id, len)) { + 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) -- 1.9.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device 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 2014-09-26 17:25 ` Luiz Capitulino 1 sibling, 0 replies; 10+ messages in thread From: Andreas Färber @ 2014-09-26 9:29 UTC (permalink / raw) To: Zhu Guihua, qemu-devel, aliguori, lcapitulino Cc: hutao, isimatu.yasuaki, tangchen 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device 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 @ 2014-09-26 17:25 ` Luiz Capitulino 2014-09-26 17:29 ` Luiz Capitulino 1 sibling, 1 reply; 10+ messages in thread From: Luiz Capitulino @ 2014-09-26 17:25 UTC (permalink / raw) To: Zhu Guihua Cc: kroosec, hutao, qemu-devel, tangchen, isimatu.yasuaki, aliguori, afaerber On Thu, 18 Sep 2014 15:53:21 +0800 Zhu Guihua <zhugh.fnst@cn.fujitsu.com> wrote: > 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)); > + if (dev->id && !strncmp(str, dev->id, len)) { > + 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); > } The series intro email mentions device_del, but this is added to chardev-remove. Is there a reason for this? Hani, could you please review this series? > > void object_del_completion(ReadLineState *rs, int nb_args, const char *str) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device 2014-09-26 17:25 ` Luiz Capitulino @ 2014-09-26 17:29 ` Luiz Capitulino 2014-09-29 21:33 ` Hani Benhabiles 0 siblings, 1 reply; 10+ messages in thread From: Luiz Capitulino @ 2014-09-26 17:29 UTC (permalink / raw) To: Zhu Guihua Cc: kroosec, hutao, qemu-devel, tangchen, isimatu.yasuaki, aliguori, afaerber On Fri, 26 Sep 2014 13:25:45 -0400 Luiz Capitulino <lcapitulino@redhat.com> wrote: > On Thu, 18 Sep 2014 15:53:21 +0800 > Zhu Guihua <zhugh.fnst@cn.fujitsu.com> wrote: > > > 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)); > > + if (dev->id && !strncmp(str, dev->id, len)) { > > + 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); > > } > > The series intro email mentions device_del, but this is added to > chardev-remove. Is there a reason for this? Turns out this is not added to chardev_remove_completion(), looked too quickly. In any case, would be nice to have Hani's review. > > Hani, could you please review this series? > > > > > void object_del_completion(ReadLineState *rs, int nb_args, const char *str) > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device 2014-09-26 17:29 ` Luiz Capitulino @ 2014-09-29 21:33 ` Hani Benhabiles 0 siblings, 0 replies; 10+ messages in thread From: Hani Benhabiles @ 2014-09-29 21:33 UTC (permalink / raw) To: Luiz Capitulino Cc: Zhu Guihua, hutao, qemu-devel, tangchen, isimatu.yasuaki, aliguori, afaerber On Fri, Sep 26, 2014 at 01:29:41PM -0400, Luiz Capitulino wrote: > On Fri, 26 Sep 2014 13:25:45 -0400 > Luiz Capitulino <lcapitulino@redhat.com> wrote: > > > On Thu, 18 Sep 2014 15:53:21 +0800 > > Zhu Guihua <zhugh.fnst@cn.fujitsu.com> wrote: > > > > > 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)); > > > + if (dev->id && !strncmp(str, dev->id, len)) { > > > + 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); > > > } > > > > The series intro email mentions device_del, but this is added to > > chardev-remove. Is there a reason for this? > > Turns out this is not added to chardev_remove_completion(), looked too > quickly. In any case, would be nice to have Hani's review. Hi, I'm wrestling with my ISP at the moment. Will get back to these as soon as possible Thanks. > > > > > Hani, could you please review this series? > > > > > > > > void object_del_completion(ReadLineState *rs, int nb_args, const char *str) > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v1 0/3] monitor: add peripheral device del completion support 2014-09-18 7:53 [Qemu-devel] [PATCH v1 0/3] monitor: add peripheral device del completion support Zhu Guihua ` (2 preceding siblings ...) 2014-09-18 7:53 ` [Qemu-devel] [PATCH v1 3/3] monitor: add del completion for peripheral device Zhu Guihua @ 2014-09-26 2:01 ` Zhu Guihua 3 siblings, 0 replies; 10+ messages in thread From: Zhu Guihua @ 2014-09-26 2:01 UTC (permalink / raw) To: qemu-devel Cc: hutao, tangchen, isimatu.yasuaki, aliguori, lcapitulino, afaerber ping ... On Thu, 2014-09-18 at 15:53 +0800, Zhu Guihua wrote: > After inputting device_del command in monitor, we expect to list all > hotpluggable devices automatically by pressing tab key. This patchset provides > the function to list all peripheral devices such as memory devices. > > Zhu Guihua (3): > qom: add function to get opaque property in ObjectProperty > qom: export object_property_is_child() > monitor: add del completion for peripheral device > > include/qom/object.h | 2 ++ > monitor.c | 24 ++++++++++++++++++++++++ > qom/object.c | 11 ++++++++++- > 3 files changed, 36 insertions(+), 1 deletion(-) > ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-09-29 21:33 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).