From sgarzare at redhat.com Fri Jul 12 10:46:17 2019 From: sgarzare at redhat.com (Stefano Garzarella) Date: Fri, 12 Jul 2019 12:46:17 +0200 Subject: [GEDI] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object Message-ID: <20190712104617.94707-1-sgarzare@redhat.com> 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 parameters already parsed. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 Signed-off-by: Stefano Garzarella --- block/gluster.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/block/gluster.c b/block/gluster.c index 62f8ff2147..26971db1ea 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -931,7 +931,16 @@ 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 'bs->filename' starts with "json:", then 'state->options' will + * contain the parameters already parsed. + */ + if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { + reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, + errp); + } else { + reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp); + } if (reop_s->glfs == NULL) { ret = -errno; goto exit; -- 2.20.1 From mreitz at redhat.com Fri Jul 12 18:35:12 2019 From: mreitz at redhat.com (Max Reitz) Date: Fri, 12 Jul 2019 20:35:12 +0200 Subject: [GEDI] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <20190712104617.94707-1-sgarzare@redhat.com> References: <20190712104617.94707-1-sgarzare@redhat.com> Message-ID: <5017daf6-2739-d260-09fd-cfccd6c77bc1@redhat.com> On 12.07.19 12:46, Stefano Garzarella wrote: > 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 parameters already parsed. > > Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 > Signed-off-by: Stefano Garzarella > --- > block/gluster.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/block/gluster.c b/block/gluster.c > index 62f8ff2147..26971db1ea 100644 > --- a/block/gluster.c > +++ b/block/gluster.c > @@ -931,7 +931,16 @@ 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 'bs->filename' starts with "json:", then 'state->options' will > + * contain the parameters already parsed. > + */ > + if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { > + reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, > + errp); > + } else { > + reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp); > + } Hmmm, aren?t they always in state->options? Max -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From no-reply at patchew.org Sat Jul 13 12:24:46 2019 From: no-reply at patchew.org (no-reply at patchew.org) Date: Sat, 13 Jul 2019 05:24:46 -0700 (PDT) Subject: [GEDI] [Qemu-devel] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <20190712104617.94707-1-sgarzare@redhat.com> Message-ID: <156302068569.12463.17823158690472274941@c4a48874b076> Patchew URL: https://patchew.org/QEMU/20190712104617.94707-1-sgarzare at redhat.com/ Hi, This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally. === TEST SCRIPT BEGIN === #!/bin/bash make docker-image-fedora V=1 NETWORK=1 time make docker-test-debug at fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END === CC audio/noaudio.o CC audio/wavaudio.o CC audio/mixeng.o /tmp/qemu-test/src/block/gluster.c:938:20: error: address of array 'state->bs->filename' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion] if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { ~~~~~~~~~~~^~~~~~~~ ~~ 1 error generated. The full log is available at http://patchew.org/logs/20190712104617.94707-1-sgarzare at redhat.com/testing.asan/?type=message. --- Email generated automatically by Patchew [https://patchew.org/]. Please send your feedback to patchew-devel at redhat.com From sgarzare at redhat.com Mon Jul 15 08:16:01 2019 From: sgarzare at redhat.com (Stefano Garzarella) Date: Mon, 15 Jul 2019 10:16:01 +0200 Subject: [GEDI] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <5017daf6-2739-d260-09fd-cfccd6c77bc1@redhat.com> References: <20190712104617.94707-1-sgarzare@redhat.com> <5017daf6-2739-d260-09fd-cfccd6c77bc1@redhat.com> Message-ID: <20190715081601.rpvavykcuhyr3fiw@steredhat> On Fri, Jul 12, 2019 at 08:35:12PM +0200, Max Reitz wrote: > On 12.07.19 12:46, Stefano Garzarella wrote: > > 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 parameters already parsed. > > > > Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 > > Signed-off-by: Stefano Garzarella > > --- > > block/gluster.c | 11 ++++++++++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/block/gluster.c b/block/gluster.c > > index 62f8ff2147..26971db1ea 100644 > > --- a/block/gluster.c > > +++ b/block/gluster.c > > @@ -931,7 +931,16 @@ 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 'bs->filename' starts with "json:", then 'state->options' will > > + * contain the parameters already parsed. > > + */ > > + if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { > > + reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, > > + errp); > > + } else { > > + reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp); > > + } > > Hmmm, aren?t they always in state->options? Yes, you are rigth, but the qemu_gluster_parse() doesn't search for the 'filename' in the QDict *options. Maybe I can simply modify it in this way in order to hanlde this case, calling qemu_gluster_init() only with 'state->options'. diff --git a/block/gluster.c b/block/gluster.c index 26971db1ea..91d674cd2b 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -695,6 +695,11 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf, QDict *options, Error **errp) { int ret; + + if (!filename) { + filename = qdict_get_try_str(options, GLUSTER_OPT_FILENAME); + } + if (filename) { ret = qemu_gluster_parse_uri(gconf, filename); if (ret < 0) { Do you think it is better/cleaner? Thanks, Stefano From mreitz at redhat.com Mon Jul 15 10:53:57 2019 From: mreitz at redhat.com (Max Reitz) Date: Mon, 15 Jul 2019 12:53:57 +0200 Subject: [GEDI] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <20190715081601.rpvavykcuhyr3fiw@steredhat> References: <20190712104617.94707-1-sgarzare@redhat.com> <5017daf6-2739-d260-09fd-cfccd6c77bc1@redhat.com> <20190715081601.rpvavykcuhyr3fiw@steredhat> Message-ID: <3f090545-0ca1-ca42-7e44-49f82e3ff760@redhat.com> On 15.07.19 10:16, Stefano Garzarella wrote: > On Fri, Jul 12, 2019 at 08:35:12PM +0200, Max Reitz wrote: >> On 12.07.19 12:46, Stefano Garzarella wrote: >>> 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 parameters already parsed. >>> >>> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 >>> Signed-off-by: Stefano Garzarella >>> --- >>> block/gluster.c | 11 ++++++++++- >>> 1 file changed, 10 insertions(+), 1 deletion(-) >>> >>> diff --git a/block/gluster.c b/block/gluster.c >>> index 62f8ff2147..26971db1ea 100644 >>> --- a/block/gluster.c >>> +++ b/block/gluster.c >>> @@ -931,7 +931,16 @@ 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 'bs->filename' starts with "json:", then 'state->options' will >>> + * contain the parameters already parsed. >>> + */ >>> + if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { >>> + reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, >>> + errp); >>> + } else { >>> + reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp); >>> + } >> >> Hmmm, aren?t they always in state->options? > > Yes, you are rigth, but the qemu_gluster_parse() doesn't search for the > 'filename' in the QDict *options. > > Maybe I can simply modify it in this way in order to hanlde this case, > calling qemu_gluster_init() only with 'state->options'. > > diff --git a/block/gluster.c b/block/gluster.c > index 26971db1ea..91d674cd2b 100644 > --- a/block/gluster.c > +++ b/block/gluster.c > @@ -695,6 +695,11 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf, > QDict *options, Error **errp) > { > int ret; > + > + if (!filename) { > + filename = qdict_get_try_str(options, GLUSTER_OPT_FILENAME); > + } > + > if (filename) { > ret = qemu_gluster_parse_uri(gconf, filename); > if (ret < 0) { > > > Do you think it is better/cleaner? No, because the rest of the function completely ignores @options if @filename is set. Hm. I can?t think of anything better than your original solution, then. Except the ?state->bs->filename? should probably be a ?state->bs->filename[0]? (as Patchew has pointed out). Max -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From sgarzare at redhat.com Mon Jul 15 12:50:05 2019 From: sgarzare at redhat.com (Stefano Garzarella) Date: Mon, 15 Jul 2019 14:50:05 +0200 Subject: [GEDI] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <3f090545-0ca1-ca42-7e44-49f82e3ff760@redhat.com> References: <20190712104617.94707-1-sgarzare@redhat.com> <5017daf6-2739-d260-09fd-cfccd6c77bc1@redhat.com> <20190715081601.rpvavykcuhyr3fiw@steredhat> <3f090545-0ca1-ca42-7e44-49f82e3ff760@redhat.com> Message-ID: <20190715125005.zzcslkysazi6rqdb@steredhat> On Mon, Jul 15, 2019 at 12:53:57PM +0200, Max Reitz wrote: > On 15.07.19 10:16, Stefano Garzarella wrote: > > On Fri, Jul 12, 2019 at 08:35:12PM +0200, Max Reitz wrote: > >> On 12.07.19 12:46, Stefano Garzarella wrote: > >>> 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 parameters already parsed. > >>> > >>> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 > >>> Signed-off-by: Stefano Garzarella > >>> --- > >>> block/gluster.c | 11 ++++++++++- > >>> 1 file changed, 10 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/block/gluster.c b/block/gluster.c > >>> index 62f8ff2147..26971db1ea 100644 > >>> --- a/block/gluster.c > >>> +++ b/block/gluster.c > >>> @@ -931,7 +931,16 @@ 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 'bs->filename' starts with "json:", then 'state->options' will > >>> + * contain the parameters already parsed. > >>> + */ > >>> + if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { > >>> + reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, > >>> + errp); > >>> + } else { > >>> + reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp); > >>> + } > >> > >> Hmmm, aren?t they always in state->options? > > > > Yes, you are rigth, but the qemu_gluster_parse() doesn't search for the > > 'filename' in the QDict *options. > > > > Maybe I can simply modify it in this way in order to hanlde this case, > > calling qemu_gluster_init() only with 'state->options'. > > > > diff --git a/block/gluster.c b/block/gluster.c > > index 26971db1ea..91d674cd2b 100644 > > --- a/block/gluster.c > > +++ b/block/gluster.c > > @@ -695,6 +695,11 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf, > > QDict *options, Error **errp) > > { > > int ret; > > + > > + if (!filename) { > > + filename = qdict_get_try_str(options, GLUSTER_OPT_FILENAME); > > + } > > + > > if (filename) { > > ret = qemu_gluster_parse_uri(gconf, filename); > > if (ret < 0) { > > > > > > Do you think it is better/cleaner? > > No, because the rest of the function completely ignores @options if > @filename is set. > > Hm. I can?t think of anything better than your original solution, then. > Except the ?state->bs->filename? should probably be a > ?state->bs->filename[0]? (as Patchew has pointed out). Sure, I'll fix it in the v2. Thanks, Stefano From mreitz at redhat.com Mon Jul 15 13:00:29 2019 From: mreitz at redhat.com (Max Reitz) Date: Mon, 15 Jul 2019 15:00:29 +0200 Subject: [GEDI] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <20190715125005.zzcslkysazi6rqdb@steredhat> References: <20190712104617.94707-1-sgarzare@redhat.com> <5017daf6-2739-d260-09fd-cfccd6c77bc1@redhat.com> <20190715081601.rpvavykcuhyr3fiw@steredhat> <3f090545-0ca1-ca42-7e44-49f82e3ff760@redhat.com> <20190715125005.zzcslkysazi6rqdb@steredhat> Message-ID: <47523a4f-04a5-7ef9-9023-00c281644995@redhat.com> On 15.07.19 14:50, Stefano Garzarella wrote: > On Mon, Jul 15, 2019 at 12:53:57PM +0200, Max Reitz wrote: >> On 15.07.19 10:16, Stefano Garzarella wrote: >>> On Fri, Jul 12, 2019 at 08:35:12PM +0200, Max Reitz wrote: >>>> On 12.07.19 12:46, Stefano Garzarella wrote: >>>>> 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 parameters already parsed. >>>>> >>>>> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 >>>>> Signed-off-by: Stefano Garzarella >>>>> --- >>>>> block/gluster.c | 11 ++++++++++- >>>>> 1 file changed, 10 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/block/gluster.c b/block/gluster.c >>>>> index 62f8ff2147..26971db1ea 100644 >>>>> --- a/block/gluster.c >>>>> +++ b/block/gluster.c >>>>> @@ -931,7 +931,16 @@ 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 'bs->filename' starts with "json:", then 'state->options' will >>>>> + * contain the parameters already parsed. >>>>> + */ >>>>> + if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { >>>>> + reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, >>>>> + errp); >>>>> + } else { >>>>> + reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp); >>>>> + } >>>> >>>> Hmmm, aren?t they always in state->options? >>> >>> Yes, you are rigth, but the qemu_gluster_parse() doesn't search for the >>> 'filename' in the QDict *options. >>> >>> Maybe I can simply modify it in this way in order to hanlde this case, >>> calling qemu_gluster_init() only with 'state->options'. >>> >>> diff --git a/block/gluster.c b/block/gluster.c >>> index 26971db1ea..91d674cd2b 100644 >>> --- a/block/gluster.c >>> +++ b/block/gluster.c >>> @@ -695,6 +695,11 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf, >>> QDict *options, Error **errp) >>> { >>> int ret; >>> + >>> + if (!filename) { >>> + filename = qdict_get_try_str(options, GLUSTER_OPT_FILENAME); >>> + } >>> + >>> if (filename) { >>> ret = qemu_gluster_parse_uri(gconf, filename); >>> if (ret < 0) { >>> >>> >>> Do you think it is better/cleaner? >> >> No, because the rest of the function completely ignores @options if >> @filename is set. >> >> Hm. I can?t think of anything better than your original solution, then. >> Except the ?state->bs->filename? should probably be a >> ?state->bs->filename[0]? (as Patchew has pointed out). > > Sure, I'll fix it in the v2. Oh, wait. You can actually just use state->bs->exact_filename. That will never be a json:{} filename, so you don?t have to do the prefix check (just see whether it is empty). Max -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From sgarzare at redhat.com Mon Jul 15 13:25:20 2019 From: sgarzare at redhat.com (Stefano Garzarella) Date: Mon, 15 Jul 2019 15:25:20 +0200 Subject: [GEDI] [PATCH] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <47523a4f-04a5-7ef9-9023-00c281644995@redhat.com> References: <20190712104617.94707-1-sgarzare@redhat.com> <5017daf6-2739-d260-09fd-cfccd6c77bc1@redhat.com> <20190715081601.rpvavykcuhyr3fiw@steredhat> <3f090545-0ca1-ca42-7e44-49f82e3ff760@redhat.com> <20190715125005.zzcslkysazi6rqdb@steredhat> <47523a4f-04a5-7ef9-9023-00c281644995@redhat.com> Message-ID: <20190715132520.pvt6kjnthyti3kdx@steredhat> On Mon, Jul 15, 2019 at 03:00:29PM +0200, Max Reitz wrote: > On 15.07.19 14:50, Stefano Garzarella wrote: > > On Mon, Jul 15, 2019 at 12:53:57PM +0200, Max Reitz wrote: > >> On 15.07.19 10:16, Stefano Garzarella wrote: > >>> On Fri, Jul 12, 2019 at 08:35:12PM +0200, Max Reitz wrote: > >>>> On 12.07.19 12:46, Stefano Garzarella wrote: > >>>>> 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 parameters already parsed. > >>>>> > >>>>> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 > >>>>> Signed-off-by: Stefano Garzarella > >>>>> --- > >>>>> block/gluster.c | 11 ++++++++++- > >>>>> 1 file changed, 10 insertions(+), 1 deletion(-) > >>>>> > >>>>> diff --git a/block/gluster.c b/block/gluster.c > >>>>> index 62f8ff2147..26971db1ea 100644 > >>>>> --- a/block/gluster.c > >>>>> +++ b/block/gluster.c > >>>>> @@ -931,7 +931,16 @@ 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 'bs->filename' starts with "json:", then 'state->options' will > >>>>> + * contain the parameters already parsed. > >>>>> + */ > >>>>> + if (state->bs->filename && !strstart(state->bs->filename, "json:", NULL)) { > >>>>> + reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, > >>>>> + errp); > >>>>> + } else { > >>>>> + reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp); > >>>>> + } > >>>> > >>>> Hmmm, aren?t they always in state->options? > >>> > >>> Yes, you are rigth, but the qemu_gluster_parse() doesn't search for the > >>> 'filename' in the QDict *options. > >>> > >>> Maybe I can simply modify it in this way in order to hanlde this case, > >>> calling qemu_gluster_init() only with 'state->options'. > >>> > >>> diff --git a/block/gluster.c b/block/gluster.c > >>> index 26971db1ea..91d674cd2b 100644 > >>> --- a/block/gluster.c > >>> +++ b/block/gluster.c > >>> @@ -695,6 +695,11 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf, > >>> QDict *options, Error **errp) > >>> { > >>> int ret; > >>> + > >>> + if (!filename) { > >>> + filename = qdict_get_try_str(options, GLUSTER_OPT_FILENAME); > >>> + } > >>> + > >>> if (filename) { > >>> ret = qemu_gluster_parse_uri(gconf, filename); > >>> if (ret < 0) { > >>> > >>> > >>> Do you think it is better/cleaner? > >> > >> No, because the rest of the function completely ignores @options if > >> @filename is set. > >> > >> Hm. I can?t think of anything better than your original solution, then. > >> Except the ?state->bs->filename? should probably be a > >> ?state->bs->filename[0]? (as Patchew has pointed out). > > > > Sure, I'll fix it in the v2. > > Oh, wait. You can actually just use state->bs->exact_filename. That > will never be a json:{} filename, so you don?t have to do the prefix > check (just see whether it is empty). Yeah, thanks for the suggestion! Stefano From sgarzare at redhat.com Mon Jul 15 13:28:44 2019 From: sgarzare at redhat.com (Stefano Garzarella) Date: Mon, 15 Jul 2019 15:28:44 +0200 Subject: [GEDI] [PATCH v2] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object Message-ID: <20190715132844.506584-1-sgarzare@redhat.com> 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. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 Signed-off-by: Stefano Garzarella --- 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(-) diff --git a/block/gluster.c b/block/gluster.c index 62f8ff2147..f64dc5b01e 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -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; -- 2.20.1 From mreitz at redhat.com Mon Jul 15 13:44:13 2019 From: mreitz at redhat.com (Max Reitz) Date: Mon, 15 Jul 2019 15:44:13 +0200 Subject: [GEDI] [PATCH v2] gluster: fix .bdrv_reopen_prepare when backing file is a JSON object In-Reply-To: <20190715132844.506584-1-sgarzare@redhat.com> References: <20190715132844.506584-1-sgarzare@redhat.com> Message-ID: <53e61e05-00a8-31e4-3165-8e87649893d3@redhat.com> On 15.07.19 15:28, Stefano Garzarella wrote: > 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. > > Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1542445 > Signed-off-by: Stefano Garzarella > --- > 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: