qdev: Hide "no_user" devices from users
authorMarkus Armbruster <armbru@redhat.com>
Fri, 19 Feb 2010 12:31:49 +0000 (13:31 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 16 Mar 2010 15:58:32 +0000 (16:58 +0100)
Users can't create them, so qdev_device_help() shouldn't list them.
Fix that.

Also make qdev_device_add() pretend they don't exist.  Before, it
rejected them with a "can't be added via command line" message, which
wasn't quite right for monitor command device_add.

hw/qdev.c

index de60108b1aaed237c79f06759a2c05d054567a89..233480e12dda709f3276ea1381a190ece5666fe5 100644 (file)
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -162,6 +162,9 @@ int qdev_device_help(QemuOpts *opts)
     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;
@@ -197,15 +200,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
 
     /* find driver */
     info = qdev_find_info(NULL, driver);
-    if (!info) {
+    if (!info || info->no_user) {
         qerror_report(QERR_DEVICE_NOT_FOUND, driver);
         return NULL;
     }
-    if (info->no_user) {
-        error_report("device \"%s\" can't be added via command line",
-                     info->name);
-        return NULL;
-    }
 
     /* find bus */
     path = qemu_opt_get(opts, "bus");