[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 09/23] block: Allow changing 'discard' on reopen
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 09/23] block: Allow changing 'discard' on reopen |
Date: |
Mon, 1 Oct 2018 19:18:47 +0200 |
From: Alberto Garcia <address@hidden>
'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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/block.c b/block.c
index e36ae3e8d1..7fb267bd1f 100644
--- a/block.c
+++ b/block.c
@@ -3156,6 +3156,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue,
BlockDriver *drv;
QemuOpts *opts;
QDict *orig_reopen_opts;
+ char *discard = NULL;
bool read_only;
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);
+ 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.
* Put them back into the QDict, so that they are checked at the end
* of this function. */
@@ -3291,6 +3301,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue,
error:
qemu_opts_del(opts);
qobject_unref(orig_reopen_opts);
+ g_free(discard);
return ret;
}
--
2.13.6
- [Qemu-block] [PULL 00/23] Block layer patches, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 02/23] qemu-io: Fix writethrough check in reopen, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 01/23] file-posix: Include filename in locking error message, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 03/23] file-posix: x-check-cache-dropped should default to false on reopen, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 04/23] block: Remove child references from bs->{options, explicit_options}, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 06/23] block: Allow child references on reopen, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 07/23] block: Forbid trying to change unsupported options during reopen, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 05/23] block: Don't look for child references in append_open_options(), Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 10/23] block: Allow changing 'detect-zeroes' on reopen, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 09/23] block: Allow changing 'discard' on reopen,
Kevin Wolf <=
- [Qemu-block] [PULL 19/23] qcow2: Explicit number replaced by a constant, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 12/23] include: Add a lookup table of sizes, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 16/23] qcow2: Increase the default upper limit on the L2 cache size, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 17/23] qcow2: Resize the cache upon image resizing, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 20/23] block-backend: Set werror/rerror defaults in blk_new(), Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 21/23] qcow2: Fix cache-clean-interval documentation, Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 22/23] test-replication: Lock AioContext around blk_unref(), Kevin Wolf, 2018/10/01
- [Qemu-block] [PULL 08/23] file-posix: Forbid trying to change unsupported options during reopen, Kevin Wolf, 2018/10/01