From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNiCI-0000xn-3r for qemu-devel@nongnu.org; Tue, 17 Feb 2015 08:28:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNiC8-0007e6-9k for qemu-devel@nongnu.org; Tue, 17 Feb 2015 08:28:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44251) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNiC8-0007dr-3B for qemu-devel@nongnu.org; Tue, 17 Feb 2015 08:28:08 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1HDS7t2013417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 17 Feb 2015 08:28:07 -0500 From: Markus Armbruster Date: Tue, 17 Feb 2015 14:28:03 +0100 Message-Id: <1424179685-21050-3-git-send-email-armbru@redhat.com> In-Reply-To: <1424179685-21050-1-git-send-email-armbru@redhat.com> References: <1424179685-21050-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] usb: Improve companion configuration error messages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: hdegoede@redhat.com, kraxel@redhat.com The previous commit broke the additional messages explaining the error messages. Improve the error messages, so they don't need explaining so much. Helps QMP users as well, unlike additional explanations. Signed-off-by: Markus Armbruster --- hw/usb/bus.c | 18 ++++++++---------- hw/usb/hcd-ehci.c | 21 ++++++--------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 8be942f..2219200 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -364,16 +364,14 @@ void usb_register_companion(const char *masterbus, USBPort *ports[], } } - if (!bus || !bus->ops->register_companion) { - error_set(errp, QERR_INVALID_PARAMETER_VALUE, "masterbus", - "an USB masterbus"); -#if 0 /* conversion from qerror_report() to error_set() broke this: */ - if (bus) { - error_printf_unless_qmp( - "USB bus '%s' does not allow companion controllers\n", - masterbus); - } -#endif + if (!bus) { + error_setg(errp, "USB bus '%s' not found", masterbus); + return; + } + if (!bus->ops->register_companion) { + error_setg(errp, "Can't use USB bus '%s' as masterbus," + " it doesn't support companion controllers", + masterbus); return; } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 7d16ba8..5c2a452 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -777,26 +777,17 @@ static void ehci_register_companion(USBBus *bus, USBPort *ports[], uint32_t i; if (firstport + portcount > NB_PORTS) { - error_set(errp, QERR_INVALID_PARAMETER_VALUE, "firstport", - "firstport on masterbus"); -#if 0 /* conversion from qerror_report() to error_set() broke this: */ - error_printf_unless_qmp( - "firstport value of %u makes companion take ports %u - %u, which " - "is outside of the valid range of 0 - %u\n", firstport, firstport, - firstport + portcount - 1, NB_PORTS - 1); -#endif + error_setg(errp, "firstport must be between 0 and %u", + NB_PORTS - portcount); return; } for (i = 0; i < portcount; i++) { if (s->companion_ports[firstport + i]) { - error_set(errp, QERR_INVALID_PARAMETER_VALUE, "masterbus", - "an USB masterbus"); -#if 0 /* conversion from qerror_report() to error_set() broke this: */ - error_printf_unless_qmp( - "port %u on masterbus %s already has a companion assigned\n", - firstport + i, bus->qbus.name); -#endif + error_setg(errp, "firstport %u asks for ports %u-%u," + " but port %u has a companion assigned already", + firstport, firstport, firstport + portcount - 1, + firstport + i); return; } } -- 1.9.3