[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 26/27] block: Turn on image locking by default
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH v4 26/27] block: Turn on image locking by default |
Date: |
Tue, 10 May 2016 10:50:58 +0800 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH v4 16/27] qemu-nbd: Add "--no-lock/-L" option, (continued)
- [Qemu-devel] [PATCH v4 16/27] qemu-nbd: Add "--no-lock/-L" option, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 14/27] qemu-img: Add "-L" option to sub commands, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 17/27] block: Don't lock drive-backup target image in none mode, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 18/27] mirror: Disable image locking on target backing chain, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 20/27] qemu-iotests: 046: Move version detection out from verify_io, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 22/27] qemu-iotests: 030: Disable image lock when checking test image, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 19/27] qemu-iotests: 140: Disable image lock for qemu-io access, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 24/27] iotests: Disable image locking in 085, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 21/27] qemu-iotests: Wait for QEMU processes before checking image in 091, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 23/27] iotests: 087: Disable image lock in cases where file is shared, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 26/27] block: Turn on image locking by default,
Fam Zheng <=
- [Qemu-devel] [PATCH v4 25/27] tests: Use null-co:// instead of /dev/null, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 27/27] qemu-iotests: Add test case 153 for image locking, Fam Zheng, 2016/05/09
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Richard W.M. Jones, 2016/05/10
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Richard W.M. Jones, 2016/05/10
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Daniel P. Berrange, 2016/05/10
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Kevin Wolf, 2016/05/10
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Daniel P. Berrange, 2016/05/10
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Kevin Wolf, 2016/05/10
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Daniel P. Berrange, 2016/05/10
- Re: [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Kevin Wolf, 2016/05/10