Skip to contentSkip to conversation

gluster: fix .bdrv_reopen_prepare when backing file is a JSON object

PATCH Applied Stefano Garzarella 2 participants 2 messages Jul 15, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gluster: fix .bdrv_reopen_prepare when backing file is a JSON object

When the backing_file is specified as a JSON object, the qemu_gluster_reopen_prepare() fails with this message:

    invalid URI json:{"server.0.host": ...}

In this case, we should call qemu_gluster_init() using the QDict 'state->options' that contains the JSON parameters already parsed.

---
v2:
- check if 'state->bs->exact_filename' is empty, instead to parse 'state->bs->filename' to check if it contains "json:" [Max]

---
 block/gluster.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
block/gluster.c +11 -1
index 62f8ff2147..f64dc5b01e 100644
@@ -931,7 +931,17 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
     gconf->has_debug = true;
     gconf->logfile = g_strdup(s->logfile);
     gconf->has_logfile = true;
-    reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, errp);
+
+    /*
+     * If 'state->bs->exact_filename' is empty, 'state->options' should contain
+     * the JSON parameters already parsed.
+     */
+    if (state->bs->exact_filename[0] != '\0') {
+        reop_s->glfs = qemu_gluster_init(gconf, state->bs->exact_filename, NULL,
+                                         errp);
+    } else {
+        reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp);
+    }
     if (reop_s->glfs == NULL) {
         ret = -errno;
         goto exit;
Signature · 1 line
2.20.1
Applied
#1 lore raw
Quoted 9 lines · Stefano Garzarella

When the backing_file is specified as a JSON object, the qemu_gluster_reopen_prepare() fails with this message:

    invalid URI json:{"server.0.host": ...}

In this case, we should call qemu_gluster_init() using the QDict 'state->options' that contains the JSON parameters already parsed.

Quoted 7 lines

---
v2:
- check if 'state->bs->exact_filename' is empty, instead to parse 'state->bs->filename' to check if it contains "json:" [Max]

---
 block/gluster.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Thanks, applied to my block branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block

Max