diff mbox

[3/4] qdev-properties-system: Improve error message for drive assignment conflict

Message ID 1434115575-7214-4-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell June 12, 2015, 1:26 p.m. UTC
If the user forgot if=none on their drive specification they're likely
to get an error message because the drive is assigned once automatically
by QEMU and once by the manual id=/drive= user command line specification.
Improve the error message produced in this case to explicitly guide the
user towards if=none.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/core/qdev-properties-system.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Peter Maydell June 22, 2015, 10:13 a.m. UTC | #1
On 22 June 2015 at 10:12, Markus Armbruster <armbru@redhat.com> wrote:
> I think we should just bite the bullet and extend Error to support
> additional helpful information for humans.

...I thought all of the string was already just helpful information
for humans? I certainly hope we aren't expecting anybody to parse it...

-- PMM
diff mbox

Patch

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 56954b4..bde9e12 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -78,8 +78,20 @@  static void parse_drive(DeviceState *dev, const char *str, void **ptr,
         return;
     }
     if (blk_attach_dev(blk, dev) < 0) {
-        error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
-                  object_get_typename(OBJECT(dev)), propname, str);
+        DriveInfo *dinfo = blk_legacy_dinfo(blk);
+
+        if (dinfo->auto_claimed) {
+            error_setg(errp, "Property '%s.%s' can't be set to drive ID '%s'; "
+                       "that drive has been automatically connected to another "
+                       "device. Use if=none if you do not want that automatic "
+                       "connection.",
+                       object_get_typename(OBJECT(dev)), propname, str);
+        } else {
+            error_setg(errp, "Property '%s.%s' can't be set to drive ID '%s'; "
+                       "that drive has already been connected to another "
+                       "device.",
+                       object_get_typename(OBJECT(dev)), propname, str);
+        }
         return;
     }
     *ptr = blk;