mirror of https://github.com/xemu-project/xemu.git
block: Allow changing 'discard' on reopen
'discard' 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 an error: (qemu) qemu-io virtio0 "reopen -o discard=on" Cannot change the option 'discard' Since there's no reason why we shouldn't allow changing it and the implementation is simple let's just do it. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
8d3245750b
commit
593b307197
11
block.c
11
block.c
|
@ -3156,6 +3156,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
|
||||||
BlockDriver *drv;
|
BlockDriver *drv;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
QDict *orig_reopen_opts;
|
QDict *orig_reopen_opts;
|
||||||
|
char *discard = NULL;
|
||||||
bool read_only;
|
bool read_only;
|
||||||
|
|
||||||
assert(reopen_state != NULL);
|
assert(reopen_state != NULL);
|
||||||
|
@ -3178,6 +3179,15 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
|
||||||
|
|
||||||
update_flags_from_options(&reopen_state->flags, opts);
|
update_flags_from_options(&reopen_state->flags, opts);
|
||||||
|
|
||||||
|
discard = qemu_opt_get_del(opts, "discard");
|
||||||
|
if (discard != NULL) {
|
||||||
|
if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) {
|
||||||
|
error_setg(errp, "Invalid discard option");
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* All other options (including node-name and driver) must be unchanged.
|
/* 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
|
* Put them back into the QDict, so that they are checked at the end
|
||||||
* of this function. */
|
* of this function. */
|
||||||
|
@ -3291,6 +3301,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
|
||||||
error:
|
error:
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
qobject_unref(orig_reopen_opts);
|
qobject_unref(orig_reopen_opts);
|
||||||
|
g_free(discard);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue