aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2016-03-07 14:23:04 +0100
committerKevin Wolf <kwolf@redhat.com>2016-03-14 16:46:43 +0100
commita81d616437e53106c31ba5025d5f359e592a2ef4 (patch)
treecc2266fb11c9a4bc6779cfbab6d6143e32bf6822
parent73176bee9918a3738237b0e06eff72b497283869 (diff)
block: Fix cache mode defaults in bds_tree_init()
Without setting explicit defaults in the options, blockdev-add without an ID ended up defaulting to writethrough. It should be writeback as documented. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
-rw-r--r--blockdev.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c
index eecd78d276..1824cae259 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -675,6 +675,13 @@ static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
goto fail;
}
+ /* bdrv_open() defaults to the values in bdrv_flags (for compatibility
+ * with other callers) rather than what we want as the real defaults.
+ * Apply the defaults here instead. */
+ qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_WB, "on");
+ qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_DIRECT, "off");
+ qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
+
if (runstate_check(RUN_STATE_INMIGRATE)) {
bdrv_flags |= BDRV_O_INACTIVE;
}