* [Qemu-devel] [PATCH v4 1/3] qdev: add qdev_build_hotpluggable_device_list helper
2014-10-17 9:35 [Qemu-devel] [PATCH v4 0/3] monitor: add peripheral device del completion support Zhu Guihua
@ 2014-10-17 9:35 ` Zhu Guihua
2014-10-17 9:35 ` [Qemu-devel] [PATCH v4 2/3] monitor: add del completion for peripheral device Zhu Guihua
2014-10-17 9:36 ` [Qemu-devel] [PATCH v4 3/3] monitor: delete device_del_bus_completion Zhu Guihua
2 siblings, 0 replies; 6+ messages in thread
From: Zhu Guihua @ 2014-10-17 9:35 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, Zhu Guihua, mst, hutao, armbru, lcapitulino,
isimatu.yasuaki, 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 | 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 a1e9247..9357aba 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -866,6 +866,19 @@ 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);
+
+ if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) {
+ *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 1fca75c..22820fe 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -360,6 +360,8 @@ extern int qdev_hotplug;
char *qdev_get_dev_path(DeviceState *dev);
+int qdev_build_hotpluggable_device_list(Object *obj, void *opaque);
+
void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler,
Error **errp);
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v4 2/3] monitor: add del completion for peripheral device
2014-10-17 9:35 [Qemu-devel] [PATCH v4 0/3] monitor: add peripheral device del completion support Zhu Guihua
2014-10-17 9:35 ` [Qemu-devel] [PATCH v4 1/3] qdev: add qdev_build_hotpluggable_device_list helper Zhu Guihua
@ 2014-10-17 9:35 ` Zhu Guihua
2014-10-19 11:37 ` Marcel Apfelbaum
2014-10-17 9:36 ` [Qemu-devel] [PATCH v4 3/3] monitor: delete device_del_bus_completion Zhu Guihua
2 siblings, 1 reply; 6+ messages in thread
From: Zhu Guihua @ 2014-10-17 9:35 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, Zhu Guihua, mst, hutao, armbru, lcapitulino,
isimatu.yasuaki, 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 2d14f39..9c3fa01 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4359,6 +4359,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 (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;
@@ -4432,6 +4455,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] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v4 2/3] monitor: add del completion for peripheral device
2014-10-17 9:35 ` [Qemu-devel] [PATCH v4 2/3] monitor: add del completion for peripheral device Zhu Guihua
@ 2014-10-19 11:37 ` Marcel Apfelbaum
2014-10-20 0:58 ` Zhu Guihua
0 siblings, 1 reply; 6+ messages in thread
From: Marcel Apfelbaum @ 2014-10-19 11:37 UTC (permalink / raw)
To: Zhu Guihua
Cc: peter.crosthwaite, mst, hutao, qemu-devel, lcapitulino,
isimatu.yasuaki, pbonzini, imammedo, tangchen, afaerber, armbru
On Fri, 2014-10-17 at 17:35 +0800, Zhu Guihua 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 2d14f39..9c3fa01 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -4359,6 +4359,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 (dev->id && !strncmp(str, dev->id, len)) {
> + readline_add_completion(rs, dev->id);
> + }
> +
Hi,
Am I missing something or g_slist_free(list)
should be somewhere here?
Thanks,
Marcel
> +}
> +
> void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str)
> {
> size_t len;
> @@ -4432,6 +4455,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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v4 2/3] monitor: add del completion for peripheral device
2014-10-19 11:37 ` Marcel Apfelbaum
@ 2014-10-20 0:58 ` Zhu Guihua
0 siblings, 0 replies; 6+ messages in thread
From: Zhu Guihua @ 2014-10-20 0:58 UTC (permalink / raw)
To: marcel.a
Cc: peter.crosthwaite, mst, hutao, qemu-devel, lcapitulino,
isimatu.yasuaki, pbonzini, imammedo, tangchen, afaerber, armbru
On Sun, 2014-10-19 at 14:37 +0300, Marcel Apfelbaum wrote:
> On Fri, 2014-10-17 at 17:35 +0800, Zhu Guihua 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 2d14f39..9c3fa01 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -4359,6 +4359,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 (dev->id && !strncmp(str, dev->id, len)) {
> > + readline_add_completion(rs, dev->id);
> > + }
> > +
> Hi,
>
> Am I missing something or g_slist_free(list)
> should be somewhere here?
>
Yes, you are right, g_slist_free(list) should be here.
I am sorry to forget to do this. Thanks for your reminding, I will fix
this.
Regards,
Zhu
> Thanks,
> Marcel
>
>
>
> > +}
> > +
> > void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str)
> > {
> > size_t len;
> > @@ -4432,6 +4455,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)
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v4 3/3] monitor: delete device_del_bus_completion
2014-10-17 9:35 [Qemu-devel] [PATCH v4 0/3] monitor: add peripheral device del completion support Zhu Guihua
2014-10-17 9:35 ` [Qemu-devel] [PATCH v4 1/3] qdev: add qdev_build_hotpluggable_device_list helper Zhu Guihua
2014-10-17 9:35 ` [Qemu-devel] [PATCH v4 2/3] monitor: add del completion for peripheral device Zhu Guihua
@ 2014-10-17 9:36 ` Zhu Guihua
2 siblings, 0 replies; 6+ messages in thread
From: Zhu Guihua @ 2014-10-17 9:36 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, Zhu Guihua, mst, hutao, armbru, lcapitulino,
isimatu.yasuaki, imammedo, pbonzini, tangchen, afaerber
device_del_bus_completion() that gathers devices from buses is unused; delete
it.
Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
---
monitor.c | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/monitor.c b/monitor.c
index 9c3fa01..42affb7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4340,25 +4340,6 @@ void object_add_completion(ReadLineState *rs, int nb_args, const char *str)
g_slist_free(list);
}
-static void device_del_bus_completion(ReadLineState *rs, BusState *bus,
- const char *str, size_t len)
-{
- BusChild *kid;
-
- QTAILQ_FOREACH(kid, &bus->children, sibling) {
- DeviceState *dev = kid->child;
- BusState *dev_child;
-
- if (dev->id && !strncmp(str, dev->id, len)) {
- readline_add_completion(rs, dev->id);
- }
-
- QLIST_FOREACH(dev_child, &dev->child_bus, sibling) {
- device_del_bus_completion(rs, dev_child, str, len);
- }
- }
-}
-
static void peripheral_device_del_completion(ReadLineState *rs,
const char *str, size_t len)
{
@@ -4454,7 +4435,6 @@ 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);
}
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread