Now that test cases are covered, we can turn it on. RO (shared) lock is disabled to allow existing libguestfs use cases (invoking QEMU for reading image that is exclusively locked by another QEMU).
Signed-off-by: Fam Zheng <[email protected]> --- block.c | 7 +++++++ blockdev.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 1b3aac4..a490bfe 100644 --- a/block.c +++ b/block.c @@ -972,6 +972,13 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, bs->zero_beyond_eof = true; bs->read_only = !(bs->open_flags & BDRV_O_RDWR); + if (bs->read_only) { + /* libguestfs uses us to _read_ images that are rw opened by another + * QEMU, skip locking ro images because the other QEMU may have an + * exclusive lock. */ + bs->open_flags |= BDRV_O_NO_LOCK; + } + if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { error_setg(errp, !bs->read_only && bdrv_is_whitelisted(drv, true) diff --git a/blockdev.c b/blockdev.c index 9968568..007690b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -383,7 +383,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, } } - if (!qemu_opt_get_bool(opts, "lock-image", false)) { + if (!qemu_opt_get_bool(opts, "lock-image", true)) { *bdrv_flags |= BDRV_O_NO_LOCK; } } -- 2.8.2
