diff mbox

[RFC,24/48] qdev: Hide "no_user" devices from users

Message ID 1267034160-3517-25-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Feb. 24, 2010, 5:55 p.m. UTC
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.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/qdev.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index e5f6820..274b052 100644
--- 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) {
         qemu_error_new(QERR_DEVICE_NOT_FOUND, driver);
         return NULL;
     }
-    if (info->no_user) {
-        qemu_error("device \"%s\" can't be added via command line",
-                   info->name);
-        return NULL;
-    }
 
     /* find bus */
     path = qemu_opt_get(opts, "bus");