diff mbox

block: improve error message for read-only whitelisted driver

Message ID 1381372271-24429-1-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng Oct. 10, 2013, 2:31 a.m. UTC
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.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block.c    | 8 +++++++-
 blockdev.c | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Kevin Wolf Oct. 10, 2013, 9:29 a.m. UTC | #1
Am 10.10.2013 um 04:31 hat Fam Zheng geschrieben:
> 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.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>

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
diff mbox

Patch

diff --git a/block.c b/block.c
index 93e113a..240c28e 100644
--- a/block.c
+++ b/block.c
@@ -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;
     }
 
diff --git a/blockdev.c b/blockdev.c
index 8aa66a9..c39fd9d 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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);
             }