Skip to contentSkip to conversation

block: better error message for read only format name

PATCH Applied Fam Zheng 2 participants 2 messages Aug 22, 2013

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 block: better error message for read only format name

When user tries to use read-only whitelist format in the command line option, failure message was "'foo' invalid format". It might be invalid only for writable, but valid for read-only, so it is confusing. Give the user easier to understand information.

---
 blockdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
blockdev.c +5 -1
index bc7016a..d3500c6 100644
@@ -487,7 +487,11 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
 
         drv = bdrv_find_whitelisted_format(buf, ro);
         if (!drv) {
-            error_report("'%s' invalid format", buf);
+            if (!ro && bdrv_find_whitelisted_format(buf, !ro)) {
+                error_report("'%s' can be only used as read-only device.", buf);
+            } else {
+                error_report("'%s' invalid format", buf);
+            }
             return NULL;
         }
     }
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 9 lines · Fam Zheng

When user tries to use read-only whitelist format in the command line option, failure message was "'foo' invalid format". It might be invalid only for writable, but valid for read-only, so it is confusing. Give the user easier to understand information.

---
 blockdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan