From 16eae79ddae2a3b757005569a924737a400bbb4f Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 31 Mar 2010 13:24:48 -0300 Subject: [PATCH 33/66] qdev: Hide "no_user" devices from users RH-Author: Markus Armbruster Message-id: <1270041921-28969-34-git-send-email-armbru@redhat.com> Patchwork-id: 8241 O-Subject: [PATCH 33/66] qdev: Hide "no_user" devices from users Bugzilla: 579470 RH-Acked-by: Kevin Wolf RH-Acked-by: Juan Quintela RH-Acked-by: Luiz Capitulino 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. (cherry picked from commit c64eafaf0c2f080d81f4c51a1eb2a98ceb40d2c8) --- hw/qdev.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) Signed-off-by: Eduardo Habkost --- hw/qdev.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index de60108..233480e 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) { 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"); -- 1.7.0.3