Skip to contentSkip to conversation

block: improve error message for read-only whitelisted driver

PATCH In review Fam Zheng 2 participants 2 messages Oct 10, 2013

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 block: improve error message for read-only whitelisted driver

Supplement of 7780d47, with message reworded and format probe case
included: print an easy to understand message, when user tries to open a read-only format as read-write.

---
 block.c    | 8 +++++++-
 blockdev.c | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
block.c +7 -1
index 93e113a..240c28e 100644
@@ -769,7 +769,13 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
     bs->read_only = !(open_flags & BDRV_O_RDWR);
 
     if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
-        error_setg(errp, "Driver '%s' is not whitelisted", drv->format_name);
+        if (!bs->read_only && bdrv_is_whitelisted(drv, true)) {
+            error_setg(errp, "format '%s' is only supported read-only",
+                       drv->format_name);
+        } else {
+            error_setg(errp, "Driver '%s' is not whitelisted",
+                       drv->format_name);
+        }
         return -ENOTSUP;
     }
 
blockdev.c +1 -1
index 8aa66a9..c39fd9d 100644
@@ -471,7 +471,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
         drv = bdrv_find_whitelisted_format(buf, ro);
         if (!drv) {
             if (!ro && bdrv_find_whitelisted_format(buf, !ro)) {
-                error_report("'%s' can be only used as read-only device.", buf);
+                error_report("format '%s' is only supported read-only", buf);
             } else {
                 error_report("'%s' invalid format", buf);
             }
Signature · 1 line
1.8.3.1
#1 lore raw

Am 10.10.2013 um 04:31 hat Fam Zheng geschrieben:

Quoted 5 lines

Supplement of 7780d47, with message reworded and format probe case
included: print an easy to understand message, when user tries to open a read-only format as read-write.

There's more to be cleaned up and fixed there. I'll look into it and send patches (it seems format=... is completely ignored at the moment, and the whitelist checks are duplicated in like three places).

Kevin