* [Qemu-devel] [PATCH v2 0/2] monitor: add peripheral device del completion support @ 2014-09-30 9:40 Zhu Guihua 2014-09-30 9:40 ` [Qemu-devel] [PATCH v2 1/2] qdev: add list built for devices Zhu Guihua 2014-09-30 9:40 ` [Qemu-devel] [PATCH v2 2/2] monitor: add del completion for peripheral device Zhu Guihua 0 siblings, 2 replies; 4+ messages in thread From: Zhu Guihua @ 2014-09-30 9:40 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. v2: - use object_child_foreach() to simplify the implementation (Andreas) Zhu Guihua (2): qdev: add list built for devices monitor: add del completion for peripheral device hw/core/qdev.c | 13 +++++++++++++ include/hw/qdev-core.h | 2 ++ monitor.c | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+) -- 1.9.3 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] qdev: add list built for devices 2014-09-30 9:40 [Qemu-devel] [PATCH v2 0/2] monitor: add peripheral device del completion support Zhu Guihua @ 2014-09-30 9:40 ` Zhu Guihua 2014-09-30 12:08 ` Igor Mammedov 2014-09-30 9:40 ` [Qemu-devel] [PATCH v2 2/2] monitor: add del completion for peripheral device Zhu Guihua 1 sibling, 1 reply; 4+ messages in thread From: Zhu Guihua @ 2014-09-30 9:40 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 devices. Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com> --- hw/core/qdev.c | 13 +++++++++++++ include/hw/qdev-core.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index fcb1638..041ac38 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1074,6 +1074,19 @@ void device_reset(DeviceState *dev) } } +int device_built_list(Object *obj, void *opaque) +{ + GSList **list = opaque; + DeviceState *dev = DEVICE(obj); + + if (dev->realized) { + *list = g_slist_append(*list, dev); + } + + return 0; + +} + Object *qdev_get_machine(void) { static Object *dev; diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 178fee2..3c30837 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -348,6 +348,8 @@ void qdev_machine_init(void); */ void device_reset(DeviceState *dev); +int device_built_list(Object *obj, void *opaque); + const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); const char *qdev_fw_name(DeviceState *dev); -- 1.9.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] qdev: add list built for devices 2014-09-30 9:40 ` [Qemu-devel] [PATCH v2 1/2] qdev: add list built for devices Zhu Guihua @ 2014-09-30 12:08 ` Igor Mammedov 0 siblings, 0 replies; 4+ messages in thread From: Igor Mammedov @ 2014-09-30 12:08 UTC (permalink / raw) To: Zhu Guihua Cc: peter.crosthwaite, mst, hutao, armbru, qemu-devel, isimatu.yasuaki, kroosec, tangchen, pbonzini, lcapitulino, afaerber On Tue, 30 Sep 2014 17:40:34 +0800 Zhu Guihua <zhugh.fnst@cn.fujitsu.com> wrote: rephrase subj to qdev: func_name() helper > For peripheral device del completion, add a function to build a list for > devices. > > Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com> > --- > hw/core/qdev.c | 13 +++++++++++++ > include/hw/qdev-core.h | 2 ++ > 2 files changed, 15 insertions(+) > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index fcb1638..041ac38 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -1074,6 +1074,19 @@ void device_reset(DeviceState *dev) > } > } > > +int device_built_list(Object *obj, void *opaque) qdev_build_hotpluggable_device_list() might describe better what function does You can put object_child_foreach(peripheral, device_built_list, &list) inside if this callback, see for example qmp_pc_dimm_device_list() Also function would return ALL devices regardless of whether they are hotpluggable or not. "hotpluggable" property can be used to discard non hotpluggable devices. > +{ > + GSList **list = opaque; > + DeviceState *dev = DEVICE(obj); > + > + if (dev->realized) { > + *list = g_slist_append(*list, dev); > + } > + > + return 0; > + > +} > + > Object *qdev_get_machine(void) > { > static Object *dev; > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h > index 178fee2..3c30837 100644 > --- a/include/hw/qdev-core.h > +++ b/include/hw/qdev-core.h > @@ -348,6 +348,8 @@ void qdev_machine_init(void); > */ > void device_reset(DeviceState *dev); > > +int device_built_list(Object *obj, void *opaque); > + > const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); > > const char *qdev_fw_name(DeviceState *dev); ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] monitor: add del completion for peripheral device 2014-09-30 9:40 [Qemu-devel] [PATCH v2 0/2] monitor: add peripheral device del completion support Zhu Guihua 2014-09-30 9:40 ` [Qemu-devel] [PATCH v2 1/2] qdev: add list built for devices Zhu Guihua @ 2014-09-30 9:40 ` Zhu Guihua 1 sibling, 0 replies; 4+ messages in thread From: Zhu Guihua @ 2014-09-30 9:40 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 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/monitor.c b/monitor.c index 667efb7..55f4466 100644 --- a/monitor.c +++ b/monitor.c @@ -4351,6 +4351,28 @@ 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, device_built_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 +4446,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] 4+ messages in thread
end of thread, other threads:[~2014-09-30 12:09 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-30 9:40 [Qemu-devel] [PATCH v2 0/2] monitor: add peripheral device del completion support Zhu Guihua 2014-09-30 9:40 ` [Qemu-devel] [PATCH v2 1/2] qdev: add list built for devices Zhu Guihua 2014-09-30 12:08 ` Igor Mammedov 2014-09-30 9:40 ` [Qemu-devel] [PATCH v2 2/2] monitor: add del completion for peripheral device 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).