* [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support
@ 2014-10-06 11:38 Zhu Guihua
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 1/2] qdev: add qdev_build_hotpluggable_device_list helper Zhu Guihua
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Zhu Guihua @ 2014-10-06 11:38 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, Zhu Guihua, mst, hutao, armbru, lcapitulino,
isimatu.yasuaki, kroosec, imammedo, pbonzini, tangchen, afaerber
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.
v3:
- commit message changes (Igor)
- rename function in patch 1 (Igor)
- use 'hotpluggable' property to discard non-hotpluggable devices (Igor)
v2:
- use object_child_foreach() to simplify the implementation (Andreas)
Zhu Guihua (2):
qdev: add qdev_build_hotpluggable_device_list helper
monitor: add del completion for peripheral device
hw/core/qdev.c | 14 ++++++++++++++
include/hw/qdev-core.h | 2 ++
monitor.c | 24 ++++++++++++++++++++++++
3 files changed, 40 insertions(+)
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 1/2] qdev: add qdev_build_hotpluggable_device_list helper
2014-10-06 11:38 [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support Zhu Guihua
@ 2014-10-06 11:38 ` Zhu Guihua
2014-10-16 11:42 ` Igor Mammedov
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device Zhu Guihua
2014-10-13 11:39 ` [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support Zhu Guihua
2 siblings, 1 reply; 7+ messages in thread
From: Zhu Guihua @ 2014-10-06 11:38 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, Zhu Guihua, mst, hutao, armbru, lcapitulino,
isimatu.yasuaki, kroosec, imammedo, pbonzini, tangchen, afaerber
For peripheral device del completion, add a function to build a list for
hotpluggable devices.
Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
---
hw/core/qdev.c | 14 ++++++++++++++
include/hw/qdev-core.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index fcb1638..5f4b2b9 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -801,6 +801,20 @@ void qdev_alias_all_properties(DeviceState *target, Object *source)
} while (class != object_class_by_name(TYPE_DEVICE));
}
+int qdev_build_hotpluggable_device_list(Object *obj, void *opaque)
+{
+ GSList **list = opaque;
+ DeviceState *dev = DEVICE(obj);
+ DeviceClass *dc = DEVICE_GET_CLASS(dev);
+
+ if (dev->realized && dc->hotpluggable) {
+ *list = g_slist_append(*list, dev);
+ }
+
+ object_child_foreach(obj, qdev_build_hotpluggable_device_list, opaque);
+ return 0;
+}
+
static bool device_get_realized(Object *obj, Error **errp)
{
DeviceState *dev = DEVICE(obj);
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 178fee2..aa76fdc 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -361,6 +361,8 @@ extern int qdev_hotplug;
char *qdev_get_dev_path(DeviceState *dev);
+int qdev_build_hotpluggable_device_list(Object *obj, void *opaque);
+
static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler,
Error **errp)
{
--
1.9.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device
2014-10-06 11:38 [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support Zhu Guihua
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 1/2] qdev: add qdev_build_hotpluggable_device_list helper Zhu Guihua
@ 2014-10-06 11:38 ` Zhu Guihua
2014-10-16 11:50 ` Igor Mammedov
2014-10-13 11:39 ` [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support Zhu Guihua
2 siblings, 1 reply; 7+ messages in thread
From: Zhu Guihua @ 2014-10-06 11:38 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, Zhu Guihua, mst, hutao, armbru, lcapitulino,
isimatu.yasuaki, kroosec, imammedo, pbonzini, tangchen, afaerber
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..ffe5405 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;
+ GSList *list = NULL, *item;
+
+ peripheral = object_resolve_path("/machine/peripheral/", NULL);
+
+ if (peripheral == NULL) {
+ return;
+ }
+
+ object_child_foreach(peripheral, qdev_build_hotpluggable_device_list,
+ &list);
+
+ for (item = list; item; item = g_slist_next(item)) {
+ DeviceState *dev = item->data;
+ if (!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] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support
2014-10-06 11:38 [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support Zhu Guihua
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 1/2] qdev: add qdev_build_hotpluggable_device_list helper Zhu Guihua
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device Zhu Guihua
@ 2014-10-13 11:39 ` Zhu Guihua
2 siblings, 0 replies; 7+ messages in thread
From: Zhu Guihua @ 2014-10-13 11:39 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, mst, hutao, armbru, lcapitulino,
isimatu.yasuaki, kroosec, imammedo, pbonzini, tangchen, afaerber
ping...
On Mon, 2014-10-06 at 19:38 +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.
>
> v3:
> - commit message changes (Igor)
> - rename function in patch 1 (Igor)
> - use 'hotpluggable' property to discard non-hotpluggable devices (Igor)
>
> v2:
> - use object_child_foreach() to simplify the implementation (Andreas)
>
>
> Zhu Guihua (2):
> qdev: add qdev_build_hotpluggable_device_list helper
> monitor: add del completion for peripheral device
>
> hw/core/qdev.c | 14 ++++++++++++++
> include/hw/qdev-core.h | 2 ++
> monitor.c | 24 ++++++++++++++++++++++++
> 3 files changed, 40 insertions(+)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 1/2] qdev: add qdev_build_hotpluggable_device_list helper
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 1/2] qdev: add qdev_build_hotpluggable_device_list helper Zhu Guihua
@ 2014-10-16 11:42 ` Igor Mammedov
0 siblings, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2014-10-16 11:42 UTC (permalink / raw)
To: Zhu Guihua
Cc: peter.crosthwaite, mst, hutao, armbru, qemu-devel,
isimatu.yasuaki, kroosec, tangchen, pbonzini, lcapitulino,
afaerber
On Mon, 6 Oct 2014 19:38:43 +0800
Zhu Guihua <zhugh.fnst@cn.fujitsu.com> wrote:
> For peripheral device del completion, add a function to build a list
> for hotpluggable devices.
>
> Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
> ---
> hw/core/qdev.c | 14 ++++++++++++++
> include/hw/qdev-core.h | 2 ++
> 2 files changed, 16 insertions(+)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index fcb1638..5f4b2b9 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -801,6 +801,20 @@ void qdev_alias_all_properties(DeviceState
> *target, Object *source) } while (class !=
> object_class_by_name(TYPE_DEVICE)); }
>
> +int qdev_build_hotpluggable_device_list(Object *obj, void *opaque)
> +{
> + GSList **list = opaque;
> + DeviceState *dev = DEVICE(obj);
> + DeviceClass *dc = DEVICE_GET_CLASS(dev);
> +
> + if (dev->realized && dc->hotpluggable) {
pls use object_property_get_bool() to get value of hotpluggable property
since it's might not be enough to have dc->hotpluggable set to true to
be hotpluggable.
> + *list = g_slist_append(*list, dev);
> + }
> +
> + object_child_foreach(obj, qdev_build_hotpluggable_device_list,
> opaque);
> + return 0;
> +}
> +
> static bool device_get_realized(Object *obj, Error **errp)
> {
> DeviceState *dev = DEVICE(obj);
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 178fee2..aa76fdc 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -361,6 +361,8 @@ extern int qdev_hotplug;
>
> char *qdev_get_dev_path(DeviceState *dev);
>
> +int qdev_build_hotpluggable_device_list(Object *obj, void *opaque);
> +
> static inline void qbus_set_hotplug_handler(BusState *bus,
> DeviceState *handler, Error **errp)
> {
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device Zhu Guihua
@ 2014-10-16 11:50 ` Igor Mammedov
2014-10-17 3:39 ` Zhu Guihua
0 siblings, 1 reply; 7+ messages in thread
From: Igor Mammedov @ 2014-10-16 11:50 UTC (permalink / raw)
To: Zhu Guihua
Cc: peter.crosthwaite, mst, hutao, armbru, qemu-devel,
isimatu.yasuaki, kroosec, tangchen, pbonzini, lcapitulino,
afaerber
On Mon, 6 Oct 2014 19:38:44 +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..ffe5405 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;
> + GSList *list = NULL, *item;
> +
> + peripheral = object_resolve_path("/machine/peripheral/", NULL);
> +
pls remove unnecessary blank line
> + if (peripheral == NULL) {
> + return;
> + }
> +
> + object_child_foreach(peripheral,
> qdev_build_hotpluggable_device_list,
> + &list);
> +
> + for (item = list; item; item = g_slist_next(item)) {
> + DeviceState *dev = item->data;
add blank line here, pls.
> + if (!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);
All ID-ed devices that might be available for removal are returned by
following line, so do we still need above recusive bus walker that
gathers duplicate devices from buses?
> + peripheral_device_del_completion(rs, str, len);
> }
>
> void object_del_completion(ReadLineState *rs, int nb_args, const
> char *str)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device
2014-10-16 11:50 ` Igor Mammedov
@ 2014-10-17 3:39 ` Zhu Guihua
0 siblings, 0 replies; 7+ messages in thread
From: Zhu Guihua @ 2014-10-17 3:39 UTC (permalink / raw)
To: Igor Mammedov
Cc: peter.crosthwaite, mst, hutao, armbru, qemu-devel,
isimatu.yasuaki, kroosec, tangchen, pbonzini, lcapitulino,
afaerber
On Thu, 2014-10-16 at 13:50 +0200, Igor Mammedov wrote:
> On Mon, 6 Oct 2014 19:38:44 +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..ffe5405 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;
> > + GSList *list = NULL, *item;
> > +
> > + peripheral = object_resolve_path("/machine/peripheral/", NULL);
> > +
> pls remove unnecessary blank line
>
> > + if (peripheral == NULL) {
> > + return;
> > + }
> > +
> > + object_child_foreach(peripheral,
> > qdev_build_hotpluggable_device_list,
> > + &list);
> > +
> > + for (item = list; item; item = g_slist_next(item)) {
> > + DeviceState *dev = item->data;
> add blank line here, pls.
>
> > + if (!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);
> All ID-ed devices that might be available for removal are returned by
> following line, so do we still need above recusive bus walker that
> gathers duplicate devices from buses?
>
yeah, we do not need recursive bus walker any more.
I will change it, thanks.
Regards,
Zhu
> > + peripheral_device_del_completion(rs, str, len);
> > }
> >
> > void object_del_completion(ReadLineState *rs, int nb_args, const
> > char *str)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-17 3:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-06 11:38 [Qemu-devel] [PATCH v3 0/2] monitor: add peripheral device del completion support Zhu Guihua
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 1/2] qdev: add qdev_build_hotpluggable_device_list helper Zhu Guihua
2014-10-16 11:42 ` Igor Mammedov
2014-10-06 11:38 ` [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device Zhu Guihua
2014-10-16 11:50 ` Igor Mammedov
2014-10-17 3:39 ` Zhu Guihua
2014-10-13 11:39 ` [Qemu-devel] [PATCH v3 0/2] 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).