aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-10-17 18:24:30 +0200
committerKevin Wolf <kwolf@redhat.com>2018-11-05 15:09:55 +0100
commit9384a444f6ebcd66bba0ae3c8434120d03c8dfea (patch)
tree9e54a99750e7c647dcf16aae33668ed64aa23eea /blockdev.c
parent8f3bf50d340372662a35564c669e567c6c846943 (diff)
block: Make auto-read-only=on default for -drive
While we want machine interfaces like -blockdev and QMP blockdev-add to add as little auto-detection as possible so that management tools are explicit about their needs, -drive is a convenience option for human users. Enabling auto-read-only=on by default there enables users to use read-only images for read-only guest devices without having to specify read-only=on explicitly. If they try to attach the image to a read-write device, they will still get an error message. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c
index fc8794862f..e5b5eb46e2 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -590,6 +590,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY,
read_only ? "on" : "off");
+ qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on");
assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0);
if (runstate_check(RUN_STATE_INMIGRATE)) {