qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: improve error message for read-only whitelisted driver
@ 2013-10-10  2:31 Fam Zheng
  2013-10-10  9:29 ` Kevin Wolf
  0 siblings, 1 reply; 2+ messages in thread
From: Fam Zheng @ 2013-10-10  2:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, famz, stefanha

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(-)

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-10-10 10:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-10  2:31 [Qemu-devel] [PATCH] block: improve error message for read-only whitelisted driver Fam Zheng
2013-10-10  9:29 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).