]> git.proxmox.com Git - qemu.git/commitdiff
block: make bdrv_set_enable_write_cache() modify open_flags
authorJeff Cody <jcody@redhat.com>
Thu, 20 Sep 2012 19:13:18 +0000 (15:13 -0400)
committerKevin Wolf <kwolf@redhat.com>
Mon, 24 Sep 2012 13:15:11 +0000 (15:15 +0200)
bdrv_set_enable_write_cache() sets the bs->enable_write_cache flag,
but without the flag recorded in bs->open_flags, then next time
a reopen() is performed the enable_write_cache setting may be
inadvertently lost.

This will set the flag in open_flags, so it is preserved across
reopens.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c

diff --git a/block.c b/block.c
index 4c0e7f5439c0b27772196621eb3360964a82ba9b..458bcc9b135d59d0272ab72d3919aab552afa0b9 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2168,6 +2168,13 @@ int bdrv_enable_write_cache(BlockDriverState *bs)
 void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce)
 {
     bs->enable_write_cache = wce;
+
+    /* so a reopen() will preserve wce */
+    if (wce) {
+        bs->open_flags |= BDRV_O_CACHE_WB;
+    } else {
+        bs->open_flags &= ~BDRV_O_CACHE_WB;
+    }
 }
 
 int bdrv_is_encrypted(BlockDriverState *bs)