Received: from eggs.gnu.org ([2001:4830:134:3::10]:52083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm4R3-0004CK-VG for qemu-devel@nongnu.org; Thu, 28 Nov 2013 11:27:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm4Qs-0002xv-Vy for qemu-devel@nongnu.org; Thu, 28 Nov 2013 11:27:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm4Qs-0002xR-NH for qemu-devel@nongnu.org; Thu, 28 Nov 2013 11:27:14 -0500 From: armbru@redhat.com Date: Thu, 28 Nov 2013 17:27:03 +0100 Message-Id: <1385656023-11519-11-git-send-email-armbru@redhat.com> In-Reply-To: <1385656023-11519-1-git-send-email-armbru@redhat.com> References: <1385656023-11519-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v4 10/10] qdev: Do not let the user try to device_add when it cannot work List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: borntraeger@de.ibm.com, marcel.a@redhat.com, afaerber@suse.de, aliguori@amazon.com, peter.maydell@linaro.org From: Markus Armbruster Such devices have always been unavailable and omitted from the list of available devices shown by device_add help. Until commit 18b6dad silently broke the former, setting up nasty traps for unwary users, like this one: $ qemu-system-x86_64 -nodefaults -monitor stdio -display none QEMU 1.6.50 monitor - type 'help' for more information (qemu) device_add apic Segmentation fault (core dumped) I call that a regression. Fix it. Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum --- qdev-monitor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qdev-monitor.c b/qdev-monitor.c index e6825ba..177b849 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -490,6 +490,11 @@ DeviceState *qdev_device_add(QemuOpts *opts) } dc = DEVICE_CLASS(oc); + if (dc->cannot_instantiate_with_device_add_yet) { + qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", + "pluggable device type"); + return NULL; + } /* find bus */ path = qemu_opt_get(opts, "bus"); -- 1.8.1.4