Message ID | 3c1b1ad5e50b71d98e0d6dcdc2ffb02681c600c7.1536226505.git.berto@igalia.com |
---|---|
State | New |
Headers | show |
Series | Misc reopen-related patches | expand |
Am 06.09.2018 um 11:37 hat Alberto Garcia geschrieben: > 'force-share' is one of the basic BlockdevOptions available for all > drivers, but it's not handled by bdrv_reopen_prepare() so any attempt > to change it results in a "Cannot change the option" error: > > (qemu) qemu-io virtio0 "reopen -o force-share=on" > Cannot change the option 'force-share' > > Since there's no reason why we shouldn't allow changing it and the > implementation is simple let's just do it. > > It's worth noting that after this patch the above reopen call will > still return an error -although a different one- if the image is not > read-only: > > (qemu) qemu-io virtio0 "reopen -o force-share=on" > force-share=on can only be used with read-only images > > Signed-off-by: Alberto Garcia <berto@igalia.com> > Reviewed-by: Max Reitz <mreitz@redhat.com> > @@ -3353,6 +3370,7 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state) > bs->open_flags = reopen_state->flags; > bs->read_only = !(reopen_state->flags & BDRV_O_RDWR); > bs->detect_zeroes = reopen_state->detect_zeroes; > + bs->force_share = reopen_state->force_share; Just changing bs->force_share without actually triggering recalculation of the permissions is kind of pointless, no? As the patch is, you would have to trigger some graph change for the new setting to take effect. The rest of the series looks good to me, so if you like, I could apply patches 1-9, and then you can either send a v4 of only this one or we'll just drop it. Kevin
On Wed 26 Sep 2018 01:34:28 PM CEST, Kevin Wolf wrote: >> @@ -3353,6 +3370,7 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state) >> bs->open_flags = reopen_state->flags; >> bs->read_only = !(reopen_state->flags & BDRV_O_RDWR); >> bs->detect_zeroes = reopen_state->detect_zeroes; >> + bs->force_share = reopen_state->force_share; > > Just changing bs->force_share without actually triggering recalculation > of the permissions is kind of pointless, no? As the patch is, you would > have to trigger some graph change for the new setting to take effect. > > The rest of the series looks good to me, so if you like, I could apply > patches 1-9, and then you can either send a v4 of only this one or we'll > just drop it. Apply it without this one then. Thanks! Berto
Am 26.09.2018 um 13:39 hat Alberto Garcia geschrieben: > On Wed 26 Sep 2018 01:34:28 PM CEST, Kevin Wolf wrote: > >> @@ -3353,6 +3370,7 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state) > >> bs->open_flags = reopen_state->flags; > >> bs->read_only = !(reopen_state->flags & BDRV_O_RDWR); > >> bs->detect_zeroes = reopen_state->detect_zeroes; > >> + bs->force_share = reopen_state->force_share; > > > > Just changing bs->force_share without actually triggering recalculation > > of the permissions is kind of pointless, no? As the patch is, you would > > have to trigger some graph change for the new setting to take effect. > > > > The rest of the series looks good to me, so if you like, I could apply > > patches 1-9, and then you can either send a v4 of only this one or we'll > > just drop it. > > Apply it without this one then. Thanks! Ok, thanks. That's what I did now. Kevin
diff --git a/block.c b/block.c index 808411ebf3..57cc4161a2 100644 --- a/block.c +++ b/block.c @@ -789,6 +789,18 @@ static BlockdevDetectZeroesOptions bdrv_parse_detect_zeroes(QemuOpts *opts, return detect_zeroes; } +static bool bdrv_parse_force_share(QemuOpts *opts, int flags, Error **errp) +{ + bool value = qemu_opt_get_bool_del(opts, BDRV_OPT_FORCE_SHARE, false); + + if (value && (flags & BDRV_O_RDWR)) { + error_setg(errp, BDRV_OPT_FORCE_SHARE + "=on can only be used with read-only images"); + } + + return value; +} + /** * Set open flags for a given discard mode * @@ -1374,12 +1386,9 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, drv = bdrv_find_format(driver_name); assert(drv != NULL); - bs->force_share = qemu_opt_get_bool(opts, BDRV_OPT_FORCE_SHARE, false); - - if (bs->force_share && (bs->open_flags & BDRV_O_RDWR)) { - error_setg(errp, - BDRV_OPT_FORCE_SHARE - "=on can only be used with read-only images"); + bs->force_share = bdrv_parse_force_share(opts, bs->open_flags, &local_err); + if (local_err) { + error_propagate(errp, local_err); ret = -EINVAL; goto fail_opts; } @@ -3202,6 +3211,14 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, goto error; } + reopen_state->force_share = + bdrv_parse_force_share(opts, reopen_state->flags, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto error; + } + /* All other options (including node-name and driver) must be unchanged. * Put them back into the QDict, so that they are checked at the end * of this function. */ @@ -3353,6 +3370,7 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state) bs->open_flags = reopen_state->flags; bs->read_only = !(reopen_state->flags & BDRV_O_RDWR); bs->detect_zeroes = reopen_state->detect_zeroes; + bs->force_share = reopen_state->force_share; /* Remove child references from bs->options and bs->explicit_options. * Child options were already removed in bdrv_reopen_queue_child() */ diff --git a/include/block/block.h b/include/block/block.h index f71fa5a1c4..a49a027c54 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -185,6 +185,7 @@ typedef struct BDRVReopenState { BlockDriverState *bs; int flags; BlockdevDetectZeroesOptions detect_zeroes; + bool force_share; uint64_t perm, shared_perm; QDict *options; QDict *explicit_options;