Skip to contentSkip to conversation

block: include original filename when reporting invalid URIs

PATCH Applied Daniel P. Berrangé 4 participants 4 messages Feb 6, 2018 – Mar 7, 2018 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: include original filename when reporting invalid URIs

Consider passing a JSON based block driver to "qemu-img commit"

$ qemu-img commit 'json:{"driver":"qcow2","file":{"driver":"gluster",\
                  "volume":"gv0","path":"sn1.qcow2",
                  "server":[{"type":\
		  "tcp","host":"10.73.199.197","port":"24007"}]},}'

Currently it will commit the content and then report an incredibly useless error message when trying to re-open the committed image:

qemu-img: invalid URI
Usage: file=gluster[+transport]://[host[:port]]volume/path[?socket=...][,file.debug=N][,file.logfile=/path/filename.log]

With this fix we get:

qemu-img: invalid URI json:{"server.0.host": "10.73.199.197",

      "driver": "gluster", "path": "luks.qcow2", "server.0.type":
      "tcp", "server.0.port": "24007", "volume": "gv0"}

Of course the root cause problem still exists, but now we know what actually needs fixing.

---
 block/gluster.c  | 2 +-
 block/sheepdog.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
block/gluster.c +1 -1
index 0f4265a3a4..0215e19087 100644
@@ -660,7 +660,7 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf,
     if (filename) {
         ret = qemu_gluster_parse_uri(gconf, filename);
         if (ret < 0) {
-            error_setg(errp, "invalid URI");
+            error_setg(errp, "invalid URI %s", filename);
             error_append_hint(errp, "Usage: file=gluster[+transport]://"
                                     "[host[:port]]volume/path[?socket=...]"
                                     "[,file.debug=N]"
block/sheepdog.c +1 -1
index f684477328..c847ab6c98 100644
@@ -1050,7 +1050,7 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
 
     cfg->uri = uri = uri_parse(filename);
     if (!uri) {
-        error_setg(&err, "invalid URI");
+        error_setg(&err, "invalid URI '%s'", filename);
         goto out;
     }
 
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Daniel P. Berrangé

Consider passing a JSON based block driver to "qemu-img commit"

$ qemu-img commit 'json:{"driver":"qcow2","file":{"driver":"gluster",\
                   "volume":"gv0","path":"sn1.qcow2",
                   "server":[{"type":\
		  "tcp","host":"10.73.199.197","port":"24007"}]},}'

Currently it will commit the content and then report an incredibly useless error message when trying to re-open the committed image:

qemu-img: invalid URI
Usage: file=gluster[+transport]://[host[:port]]volume/path[?socket=...][,file.debug=N][,file.logfile=/path/filename.log]

With this fix we get:

   qemu-img: invalid URI json:{"server.0.host": "10.73.199.197",
       "driver": "gluster", "path": "luks.qcow2", "server.0.type":
       "tcp", "server.0.port": "24007", "volume": "gv0"}
Quoted 8 lines

Of course the root cause problem still exists, but now we know what actually needs fixing.

---
  block/gluster.c  | 2 +-
  block/sheepdog.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
In reply to Daniel P. Berrangé
Quoted 19 lines · Daniel P. Berrangé

Consider passing a JSON based block driver to "qemu-img commit"

$ qemu-img commit 'json:{"driver":"qcow2","file":{"driver":"gluster",\
                  "volume":"gv0","path":"sn1.qcow2",
                  "server":[{"type":\
		  "tcp","host":"10.73.199.197","port":"24007"}]},}'

Currently it will commit the content and then report an incredibly useless error message when trying to re-open the committed image:

qemu-img: invalid URI
Usage: file=gluster[+transport]://[host[:port]]volume/path[?socket=...][,file.debug=N][,file.logfile=/path/filename.log]

With this fix we get:

qemu-img: invalid URI json:{"server.0.host": "10.73.199.197",

      "driver": "gluster", "path": "luks.qcow2", "server.0.type":
      "tcp", "server.0.port": "24007", "volume": "gv0"}
Quoted 8 lines

Of course the root cause problem still exists, but now we know what actually needs fixing.

---
 block/gluster.c  | 2 +-
 block/sheepdog.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Jeff: Ping

Quoted 30 lines
block/gluster.c +1 -1
index 0f4265a3a4..0215e19087 100644
@@ -660,7 +660,7 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf,
     if (filename) {
         ret = qemu_gluster_parse_uri(gconf, filename);
         if (ret < 0) {
-            error_setg(errp, "invalid URI");
+            error_setg(errp, "invalid URI %s", filename);
             error_append_hint(errp, "Usage: file=gluster[+transport]://"
                                     "[host[:port]]volume/path[?socket=...]"
                                     "[,file.debug=N]"
block/sheepdog.c +1 -1
index f684477328..c847ab6c98 100644
@@ -1050,7 +1050,7 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
 
     cfg->uri = uri = uri_parse(filename);
     if (!uri) {
-        error_setg(&err, "invalid URI");
+        error_setg(&err, "invalid URI '%s'", filename);
         goto out;
     }
 
Signature · 1 line
2.14.3
Applied
#3 lore raw
In reply to Daniel P. Berrangé
Quoted 57 lines · Daniel P. Berrangé

Consider passing a JSON based block driver to "qemu-img commit"

$ qemu-img commit 'json:{"driver":"qcow2","file":{"driver":"gluster",\
                  "volume":"gv0","path":"sn1.qcow2",
                  "server":[{"type":\
		  "tcp","host":"10.73.199.197","port":"24007"}]},}'

Currently it will commit the content and then report an incredibly useless error message when trying to re-open the committed image:

qemu-img: invalid URI
Usage: file=gluster[+transport]://[host[:port]]volume/path[?socket=...][,file.debug=N][,file.logfile=/path/filename.log]

With this fix we get:

qemu-img: invalid URI json:{"server.0.host": "10.73.199.197",

      "driver": "gluster", "path": "luks.qcow2", "server.0.type":
      "tcp", "server.0.port": "24007", "volume": "gv0"}

Of course the root cause problem still exists, but now we know what actually needs fixing.

---
 block/gluster.c  | 2 +-
 block/sheepdog.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
block/gluster.c +1 -1
index 0f4265a3a4..0215e19087 100644
@@ -660,7 +660,7 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf,
     if (filename) {
         ret = qemu_gluster_parse_uri(gconf, filename);
         if (ret < 0) {
-            error_setg(errp, "invalid URI");
+            error_setg(errp, "invalid URI %s", filename);
             error_append_hint(errp, "Usage: file=gluster[+transport]://"
                                     "[host[:port]]volume/path[?socket=...]"
                                     "[,file.debug=N]"
block/sheepdog.c +1 -1
index f684477328..c847ab6c98 100644
@@ -1050,7 +1050,7 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
 
     cfg->uri = uri = uri_parse(filename);
     if (!uri) {
-        error_setg(&err, "invalid URI");
+        error_setg(&err, "invalid URI '%s'", filename);
         goto out;
     }
 
Signature · 1 line
2.14.3

Thanks,

Applied to my block branch:

git://github.com/codyprime/qemu-kvm-jtc block

-Jeff