Add tab-completion for device_add.
PATCH 1/1 Add tab-completion for device_add.
Signed-off-by Andrzej Zaborowski <[email protected]>
---
There are other ways to do this, but adding an API for querying available qdev drivers was the one that made most sense to me.
--- hw/qdev.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 7 +++++++ monitor.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 0 deletions(-)
hw/qdev.c +38 -0
@@ -1535,3 +1535,41 @@ void qdev_machine_init(void)qdev_get_peripheral_anon ();qdev_get_peripheral (); } + +int qdev_driver_foreach (qdev_driver_foreach_func func,void *opaque) +{ +DeviceInfo *info; +int ret =0 ; + +for (info = device_info_list; info !=NULL ; info = info->next) { + ret |= (*func)(info, opaque); + } + +return ret; +} + +int qdev_driver_prop_foreach (qdev_driver_prop_foreach_func func, +const char *driver,void *opaque) +{ +DeviceInfo *info; +Property *prop; +int ret =0 ; + + info =qdev_find_info (NULL , driver); +if (!info) { +return -1 ; + } + +for (prop = info->props; prop && prop->name; prop++) { +/* +* TODO Properties without a parser are just for dirty hacks. +* See comment in qdev_device_help. +*/ +if (!prop->info->parse) { +continue ;/* no way to set it, don't show */ + } + ret |= (*func)(prop, opaque); + } + +return ret; +}
hw/qdev.h +7 -0
@@ -624,4 +624,11 @@ char *qdev_get_type(DeviceState *dev, Error **errp);*/ void qdev_machine_init (void ); +/* Driver querying */ +typedef int (*qdev_driver_foreach_func )(DeviceInfo *info,void *opaque); +int qdev_driver_foreach (qdev_driver_foreach_func func,void *opaque); +typedef int (*qdev_driver_prop_foreach_func )(Property *info,void *opaque); +int qdev_driver_prop_foreach (qdev_driver_prop_foreach_func func, +const char *driver,void *opaque); +#endif
monitor.c +41 -0
68 lines not on this page · raw message
Signature · 1 line
1.7.4.4
Quoted 42 lines · Andrzej Zaborowski
Signed-off-by Andrzej Zaborowski<[email protected]>---
There are other ways to do this, but adding an API for querying available qdev drivers was the one that made most sense to me.--- hw/qdev.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 7 +++++++ monitor.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 0 deletions(-)hw/qdev.c +24
-0@@ -1535,3 +1535,41 @@ void qdev_machine_init(void)qdev_get_peripheral_anon ();qdev_get_peripheral (); } + +int qdev_driver_foreach (qdev_driver_foreach_func func,void *opaque) +{ +DeviceInfo *info; +int ret =0 ; + +for (info = device_info_list; info !=NULL ; info = info->next) { + ret |= (*func)(info, opaque); + } + +return ret; +} + +int qdev_driver_prop_foreach (qdev_driver_prop_foreach_func func, +const char *driver,void *opaque) +{ +DeviceInfo *info; +Property *prop; +int ret =0 ; + + info =qdev_find_info (NULL , driver); +if (!info) { +return -1 ; + }
hw/qdev.c void qdev_machine_init(void) · line 1571
Quoted 10 lines
hw/qdev.c +10
-0+ +for (prop = info->props; prop&& prop->name; prop++) { +/* +* TODO Properties without a parser are just for dirty hacks. +* See comment in qdev_device_help. +*/ +if (!prop->info->parse) { +continue ;/* no way to set it, don't show */ + } + ret |= (*func)(prop, opaque);
Would be better to pass prop->name here as Property is going to go away soon.
Regards,
Anthony Liguori