Skip to contentSkip to conversation

Add tab-completion for device_add.

PATCH In review Andrzej Zaborowski 1 participant 2 messages Jan 9, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add tab-completion for device_add.

---
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
index d0cf66d..ba97312 100644
@@ -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
index 2abb767..b72a31a 100644
@@ -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
#1 lore raw
Quoted 9 lines · Andrzej Zaborowski

---
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(-)

Sorry, sent the old version of the patch, please look at the one I'll send in a minute instead.

Cheers