From patchwork Tue Dec 22 20:30:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Tsai X-Patchwork-Id: 41638 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 22F87B7BA5 for ; Wed, 23 Dec 2009 07:31:36 +1100 (EST) Received: from localhost ([127.0.0.1]:60559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNBOG-0001Nh-Rd for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2009 15:31:32 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNBNf-0001K3-2e for qemu-devel@nongnu.org; Tue, 22 Dec 2009 15:30:55 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNBNZ-0001Cq-Vs for qemu-devel@nongnu.org; Tue, 22 Dec 2009 15:30:54 -0500 Received: from [199.232.76.173] (port=37048 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNBNZ-0001Cj-Qo for qemu-devel@nongnu.org; Tue, 22 Dec 2009 15:30:49 -0500 Received: from mail-yx0-f188.google.com ([209.85.210.188]:44525) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NNBNZ-0002QB-I2 for qemu-devel@nongnu.org; Tue, 22 Dec 2009 15:30:49 -0500 Received: by yxe26 with SMTP id 26so6308154yxe.4 for ; Tue, 22 Dec 2009 12:30:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=9Gapc55Npu5EFkNdl6KJAHcAiv6PeSjEOW9ChhPr0dc=; b=XDGecOMeCWovVmNmYeSUQxS3ctjM+1vuF4AYLYoqNPhrUF3OZbDcvmOsNHYyjSkXmi kZNaKdhleyzHNB4jHjRnO7NvVJiz94IpyAmJ1KlJrVZt5ZpCWtI+KrNM2iFvbU6C3oec w+IgMPazkccHDIuq1RUdWJ2WfUWbvOd9tF2kg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=swBwTTkO+DSHwOsp8MVenUMoPc6l8VsUR0up2Y8Hn42s58cvDgEOVHhmCDKFzq6yi1 7YYUeaafm2xte4CBk0EmDHAZpQABDKUgLhjakCcR1dUiwVqRI8duBuFuTtiCwQAEvDGO LnmjTsvbxL7+bqU47fDTJ70lwN2PKFnG+mzSM= Received: by 10.151.19.5 with SMTP id w5mr3663784ybi.123.1261513846912; Tue, 22 Dec 2009 12:30:46 -0800 (PST) Received: from localhost (220-136-189-82.dynamic.hinet.net [220.136.189.82]) by mx.google.com with ESMTPS id 5sm2943198yxg.46.2009.12.22.12.30.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 22 Dec 2009 12:30:46 -0800 (PST) From: Scott Tsai To: qemu-devel@nongnu.org Date: Wed, 23 Dec 2009 04:30:18 +0800 Message-Id: <1261513818-23626-1-git-send-email-scottt.tw@gmail.com> X-Mailer: git-send-email 1.6.5.2 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Scott Tsai Subject: [Qemu-devel] [FOR 0.12][PATCH] Improve usbdevice error messages 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 When an non-existent USB device is specified on the command line, print "qemu: could not add USB device 'X'". Likewise for the usb_{add,del} monitor commands. Signed-off-by: Scott Tsai --- vl.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 8be3648..ee9c3f9 100644 --- a/vl.c +++ b/vl.c @@ -2689,17 +2689,28 @@ static int usb_device_del(const char *devname) static int usb_parse(const char *cmdline) { - return usb_device_add(cmdline, 0); + int r; + r = usb_device_add(cmdline, 0); + if (r < 0) { + fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline); + } + return r; } void do_usb_add(Monitor *mon, const QDict *qdict) { - usb_device_add(qdict_get_str(qdict, "devname"), 1); + const char *devname = qdict_get_str(qdict, "devname"); + if (usb_device_add(devname, 1) < 0) { + qemu_error("could not add USB device '%s'\n", devname); + } } void do_usb_del(Monitor *mon, const QDict *qdict) { - usb_device_del(qdict_get_str(qdict, "devname")); + const char *devname = qdict_get_str(qdict, "devname"); + if (usb_device_del(devname) < 0) { + qemu_error("could not delete USB device '%s'\n", devname); + } } /***********************************************************/