diff mbox

[v2,1/3] qdev-monitor: improve error message when alias device is unavailable

Message ID 1455831854-49013-2-git-send-email-silbe@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sascha Silbe Feb. 18, 2016, 9:44 p.m. UTC
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 <cornelia.huck@de.ibm.com>
Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
---
v1->v2: new patch
---
 qdev-monitor.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Cornelia Huck Feb. 22, 2016, 11:54 a.m. UTC | #1
On Thu, 18 Feb 2016 22:44:12 +0100
Sascha Silbe <silbe@linux.vnet.ibm.com> wrote:

> 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 <cornelia.huck@de.ibm.com>
> Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
> ---
> v1->v2: new patch
> ---
>  qdev-monitor.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
diff mbox

Patch

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;
     }