From patchwork Thu Mar 4 15:56:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 46968 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 940AEB7CEC for ; Fri, 5 Mar 2010 04:55:50 +1100 (EST) Received: from localhost ([127.0.0.1]:48309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnF88-0003OD-H0 for incoming@patchwork.ozlabs.org; Thu, 04 Mar 2010 12:46:36 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NnDYW-0006C4-7p for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:05:44 -0500 Received: from [199.232.76.173] (port=58612 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnDYV-0006BE-2i for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:05:43 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NnDYQ-0001cL-61 for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:05:42 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:47519) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NnDYP-0001bD-A8 for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:05:37 -0500 Received: from blackfin.pond.sub.org (pD9E38041.dip.t-dialin.net [217.227.128.65]) by oxygen.pond.sub.org (Postfix) with ESMTPA id A1E5E276DBD for ; Thu, 4 Mar 2010 16:57:15 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 75268119; Thu, 4 Mar 2010 16:57:13 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 4 Mar 2010 16:56:46 +0100 Message-Id: <1267718231-13303-26-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1267718231-13303-1-git-send-email-armbru@redhat.com> References: <1267718231-13303-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Luiz Capitulino Subject: [Qemu-devel] [PATCH 25/50] qdev: Hide "no_user" devices from users X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- hw/qdev.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 7bc711b..5ebf013 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");