diff mbox

[4/5] qdev: Re-arrange code to have device properties shown from own function

Message ID fed433e1e70fdcde45db3f58c21b32b8a6f46dc6.1275309375.git.amit.shah@redhat.com
State New
Headers show

Commit Message

Amit Shah May 31, 2010, 12:41 p.m. UTC
Instead of printing out the device properties help messages from
qdev_device_help(), split it off into a new function. This way, we have
two separate function calls for device help and device properties help.

This will be later used to show all the devices and all the properties
associated with the device as part of a complete coverage for all
devices and options associated with each of them.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/qdev.c |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)
diff mbox

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index 2cd205b..89ba986 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -151,27 +151,11 @@  static int set_property(const char *name, const char *value, void *opaque)
     return 0;
 }
 
-int qdev_device_help(QemuOpts *opts)
+static int show_device_props(const char *driver)
 {
-    const char *driver;
     DeviceInfo *info;
     Property *prop;
 
-    driver = qemu_opt_get(opts, "driver");
-    if (driver && !strcmp(driver, "?")) {
-        for (info = device_info_list; info != NULL; info = info->next) {
-            if (info->no_user) {
-                continue;       /* not available, don't show */
-            }
-            qdev_print_devinfo(info);
-        }
-        return 1;
-    }
-
-    if (!qemu_opt_get(opts, "?")) {
-        return 0;
-    }
-
     info = qdev_find_info(NULL, driver);
     if (!info) {
         return 0;
@@ -193,6 +177,29 @@  int qdev_device_help(QemuOpts *opts)
     return 1;
 }
 
+int qdev_device_help(QemuOpts *opts)
+{
+    const char *driver;
+    DeviceInfo *info;
+
+    driver = qemu_opt_get(opts, "driver");
+    if (driver && !strcmp(driver, "?")) {
+        for (info = device_info_list; info != NULL; info = info->next) {
+            if (info->no_user) {
+                continue;       /* not available, don't show */
+            }
+            qdev_print_devinfo(info);
+        }
+        return 1;
+    }
+
+    if (!qemu_opt_get(opts, "?")) {
+        return 0;
+    }
+
+    return show_device_props(driver);
+}
+
 DeviceState *qdev_device_add(QemuOpts *opts)
 {
     const char *driver, *path, *id;