9ae3a8
From 41eb96b80b2e805573cc79e3b6e7eff49892dd47 Mon Sep 17 00:00:00 2001
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Fri, 17 Jan 2014 17:07:59 +0100
9ae3a8
Subject: [PATCH 09/11] qdev-monitor: Improve error message for -device nonexistant
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Markus Armbruster <armbru@redhat.com>
9ae3a8
Message-id: <1389978479-30595-10-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 56794
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 9/9] qdev-monitor: Improve error message for -device nonexistant
9ae3a8
Bugzilla: 669524
9ae3a8
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
9ae3a8
Once upon a time, the error message was:
9ae3a8
9ae3a8
    qemu: -device nonexistant: Device "nonexistant" not found.  Try -device '?' for a list.
9ae3a8
9ae3a8
But progress marches on, and conversion to QError (commit 0204276)
9ae3a8
changed it into:
9ae3a8
9ae3a8
    Invalid parameter 'driver'
9ae3a8
    Try with argument '?' for a list.
9ae3a8
9ae3a8
Progress didn't stop there, of course.  After a couple of iterations,
9ae3a8
we arrived at the current message (commit 6acbe4c):
9ae3a8
9ae3a8
    qemu: -device nonexistant: Parameter 'driver' expects device type
9ae3a8
9ae3a8
Mission accomplished: this is complete mush.
9ae3a8
9ae3a8
We've since abandoned our quest for "rich" error objects, fortunately
9ae3a8
before it turned all error messages into mush.  Time to undo the
9ae3a8
damage to this one.  Make it:
9ae3a8
9ae3a8
    qemu: -device nonexistant: nonexistant is not a valid device model name
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Andreas Färber <afaerber@suse.de>
9ae3a8
(cherry picked from commit 11c308b17a34932033cceca4f88b5e67009e3ebd)
9ae3a8
---
9ae3a8
 qdev-monitor.c | 3 ++-
9ae3a8
 1 file changed, 2 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 qdev-monitor.c |    3 ++-
9ae3a8
 1 files changed, 2 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/qdev-monitor.c b/qdev-monitor.c
9ae3a8
index 55a476b..ac65a10 100644
9ae3a8
--- a/qdev-monitor.c
9ae3a8
+++ b/qdev-monitor.c
9ae3a8
@@ -479,7 +479,8 @@ DeviceState *qdev_device_add(QemuOpts *opts)
9ae3a8
     }
9ae3a8
 
9ae3a8
     if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
9ae3a8
-        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", "device type");
9ae3a8
+        qerror_report(ERROR_CLASS_GENERIC_ERROR,
9ae3a8
+                      "'%s' is not a valid device model name", driver);
9ae3a8
         return NULL;
9ae3a8
     }
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8