From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWWN4-0005zK-2c for qemu-devel@nongnu.org; Thu, 18 Feb 2016 16:44:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWWMv-0003nB-0s for qemu-devel@nongnu.org; Thu, 18 Feb 2016 16:44:22 -0500 Received: from e06smtp07.uk.ibm.com ([195.75.94.103]:39644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWWMu-0003m0-MK for qemu-devel@nongnu.org; Thu, 18 Feb 2016 16:44:12 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Feb 2016 21:44:10 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id BBFEA1B08069 for ; Thu, 18 Feb 2016 21:44:25 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1ILi85h59572280 for ; Thu, 18 Feb 2016 21:44:08 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1ILi72E017473 for ; Thu, 18 Feb 2016 14:44:07 -0700 From: Sascha Silbe Date: Thu, 18 Feb 2016 22:44:12 +0100 Message-Id: <1455831854-49013-2-git-send-email-silbe@linux.vnet.ibm.com> In-Reply-To: <1455831854-49013-1-git-send-email-silbe@linux.vnet.ibm.com> References: <1455831854-49013-1-git-send-email-silbe@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 1/3] qdev-monitor: improve error message when alias device is unavailable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, "Michael S. Tsirkin" , Cornelia Huck , Christian Borntraeger , Markus Armbruster When trying to instantiate an alias that points to a device class that doesn't exist, the error message looks like qemu misunderstood the request: $ s390x-softmmu/qemu-system-s390x -device virtio-gpu qemu-system-s390x: -device virtio-gpu: 'virtio-gpu-ccw' is not a valid device model name Special-case the error message to make it explicit that alias expansion is going on: $ s390x-softmmu/qemu-system-s390x -device virtio-gpu qemu-system-s390x: -device virtio-gpu: 'virtio-gpu' (alias 'virtio-gpu-ccw') is not a valid device model name Suggested-By: Cornelia Huck Signed-off-by: Sascha Silbe --- v1->v2: new patch --- qdev-monitor.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index 81e3ff3..e5136d7 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -188,6 +188,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp) { ObjectClass *oc; DeviceClass *dc; + const char *original_name = *driver; oc = object_class_by_name(*driver); if (!oc) { @@ -200,7 +201,12 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp) } if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) { - error_setg(errp, "'%s' is not a valid device model name", *driver); + if (*driver != original_name) { + error_setg(errp, "'%s' (alias '%s') is not a valid device model" + " name", original_name, *driver); + } else { + error_setg(errp, "'%s' is not a valid device model name", *driver); + } return NULL; } -- 2.1.4