summary refs log tree commit diff stats
path: root/hw/qdev.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2010-01-29 19:48:57 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-02-03 12:39:01 -0600
commitff952ba25deb927fea0b30b8a74e0059a47c1ef1 (patch)
tree3920f203e387d4911f1d83345bda8efb70918535 /hw/qdev.c
parent4a2594ddd35de7ae7c8cd9c6828cfe72245e6dc5 (diff)
downloadfocaccia-qemu-ff952ba25deb927fea0b30b8a74e0059a47c1ef1.tar.gz
focaccia-qemu-ff952ba25deb927fea0b30b8a74e0059a47c1ef1.zip
qdev: Fix exit code for -device ?
Help was shoehorned into device creation, qdev_device_add().  Since
help doesn't create a device, it returns NULL, which looks to callers
just like failed device creation.  Monitor handler do_device_add()
doesn't care, but main() exits unsuccessfully.

Move help out of device creation, into new qdev_device_help().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r--hw/qdev.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index c64357603d..f47f0cb973 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -153,6 +153,24 @@ static int set_property(const char *name, const char *value, void *opaque)
     return 0;
 }
 
+int qdev_device_help(QemuOpts *opts)
+{
+    const char *driver;
+    DeviceInfo *info;
+    char msg[256];
+
+    driver = qemu_opt_get(opts, "driver");
+    if (driver && !strcmp(driver, "?")) {
+        for (info = device_info_list; info != NULL; info = info->next) {
+            qdev_print_devinfo(info, msg, sizeof(msg));
+            qemu_error("%s\n", msg);
+        }
+        return 1;
+    }
+
+    return 0;
+}
+
 DeviceState *qdev_device_add(QemuOpts *opts)
 {
     const char *driver, *path, *id;
@@ -165,14 +183,6 @@ DeviceState *qdev_device_add(QemuOpts *opts)
         qemu_error("-device: no driver specified\n");
         return NULL;
     }
-    if (strcmp(driver, "?") == 0) {
-        char msg[256];
-        for (info = device_info_list; info != NULL; info = info->next) {
-            qdev_print_devinfo(info, msg, sizeof(msg));
-            qemu_error("%s\n", msg);
-        }
-        return NULL;
-    }
 
     /* find driver */
     info = qdev_find_info(NULL, driver);
@@ -726,7 +736,7 @@ void do_device_add(Monitor *mon, const QDict *qdict)
 
     opts = qemu_opts_parse(&qemu_device_opts,
                            qdict_get_str(qdict, "config"), "driver");
-    if (opts)
+    if (opts && !qdev_device_help(opts))
         qdev_device_add(opts);
 }