[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 08/10] block: Allow changing 'discard' on reopen
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH v3 08/10] block: Allow changing 'discard' on reopen |
Date: |
Thu, 6 Sep 2018 12:37:08 +0300 |
'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>
---
block.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/block.c b/block.c
index 1c0f72454a..bd8467bed8 100644
--- a/block.c
+++ b/block.c
@@ -3155,6 +3155,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);
@@ -3177,6 +3178,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. */
@@ -3290,6 +3300,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.11.0
- [Qemu-block] [PATCH v3 00/10] Misc reopen-related patches, Alberto Garcia, 2018/09/06
- [Qemu-block] [PATCH v3 08/10] block: Allow changing 'discard' on reopen,
Alberto Garcia <=
- [Qemu-block] [PATCH v3 05/10] block: Allow child references on reopen, Alberto Garcia, 2018/09/06
- [Qemu-block] [PATCH v3 09/10] block: Allow changing 'detect-zeroes' on reopen, Alberto Garcia, 2018/09/06
- [Qemu-block] [PATCH v3 02/10] file-posix: x-check-cache-dropped should default to false on reopen, Alberto Garcia, 2018/09/06
- [Qemu-block] [PATCH v3 03/10] block: Remove child references from bs->{options, explicit_options}, Alberto Garcia, 2018/09/06
- [Qemu-block] [PATCH v3 06/10] block: Forbid trying to change unsupported options during reopen, Alberto Garcia, 2018/09/06