aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2016-03-18 15:36:31 +0100
committerKevin Wolf <kwolf@redhat.com>2016-03-30 12:16:03 +0200
commit19dbecdceef3f0800a96c25931d71b0b82c3a47a (patch)
tree11bb70b5e272daf0ec9a4550d0d45334d1eebc70 /block.c
parent04feb4a5073e75b8ed213b297c857fa3ccc0b538 (diff)
qemu-io: Use bdrv_parse_cache_mode() in reopen_f()
We must forbid changing the WCE flag in bdrv_reopen() in the same patch, as otherwise the behaviour would change so that the flag takes precedence over the explicitly specified option. The correct value of the WCE flag depends on the BlockBackend user (e.g. guest device) and isn't a decision that the QMP client makes, so this change is what we want. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/block.c b/block.c
index ca7e7a0b45..4e27c49a75 100644
--- a/block.c
+++ b/block.c
@@ -2028,18 +2028,12 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
update_flags_from_options(&reopen_state->flags, opts);
- /* If a guest device is attached, it owns WCE */
- if (reopen_state->bs->blk && blk_get_attached_dev(reopen_state->bs->blk)) {
- bool old_wce = bdrv_enable_write_cache(reopen_state->bs);
- bool new_wce = (reopen_state->flags & BDRV_O_CACHE_WB);
- if (old_wce != new_wce) {
- error_setg(errp, "Cannot change cache.writeback: Device attached");
- ret = -EINVAL;
- goto error;
- }
- }
- if (!reopen_state->bs->blk && !(reopen_state->flags & BDRV_O_CACHE_WB)) {
- error_setg(errp, "Cannot disable cache.writeback: No BlockBackend");
+ /* WCE is a BlockBackend level option, can't change it */
+ bool old_wce = bdrv_enable_write_cache(reopen_state->bs);
+ bool new_wce = (reopen_state->flags & BDRV_O_CACHE_WB);
+
+ if (old_wce != new_wce) {
+ error_setg(errp, "Cannot change cache.writeback");
ret = -EINVAL;
goto error;
}