[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v11 15/16] qcow2: Force "no other writer" lock on bs
From: |
Fam Zheng |
Subject: |
[Qemu-block] [PATCH v11 15/16] qcow2: Force "no other writer" lock on bs->file |
Date: |
Fri, 20 Jan 2017 15:23:09 +0800 |
Writing to the same qcow2 file from two QEMU processes at the same time
will never work correctly, so disable it even when the caller specifies
BDRV_O_RDWR.
Other formats are less vulnerable because they don't have internal
snapshots thus qemu-img is less often misused to create live snapshot.
Signed-off-by: Fam Zheng <address@hidden>
---
block/qcow2.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 96fb8a8..879361a 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1177,6 +1177,17 @@ static int qcow2_open(BlockDriverState *bs, QDict
*options, int flags,
}
}
+ if ((flags & BDRV_O_SHARE_RW) && (flags & BDRV_O_RDWR)) {
+ /* Shared write is never a good idea for qcow2, override it.
+ * XXX: Use permission propagation and masking mechanism in op blockers
+ * API once it's there. */
+ ret = bdrv_reopen(bs->file->bs, flags & ~BDRV_O_SHARE_RW, &local_err);
+ if (ret) {
+ error_propagate(errp, local_err);
+ goto fail;
+ }
+ }
+
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
--
2.9.3
- [Qemu-block] [PATCH v11 04/16] qemu-img: Set "share-rw" flag in read-only commands, (continued)
- [Qemu-block] [PATCH v11 04/16] qemu-img: Set "share-rw" flag in read-only commands, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 05/16] block: Set "share-rw" flag in drive-backup when sync=none, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 06/16] iotests: 055: Don't attach the drive to vm for drive-backup, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 07/16] iotests: 030: Read-only open image for getting map, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 08/16] iotests: 087: Don't attach test image twice, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 10/16] iotests: 091: Quit QEMU before checking image, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 09/16] iotests: 085: Avoid image locking conflict, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 11/16] iotests: 172: Use separate images for multiple devices, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 12/16] tests: Use null-co:// instead of /dev/null as the dummy image, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 13/16] tests: Disable image lock in test-replication, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 15/16] qcow2: Force "no other writer" lock on bs->file,
Fam Zheng <=
- [Qemu-block] [PATCH v11 14/16] file-posix: Implement image locking, Fam Zheng, 2017/01/20
- [Qemu-block] [PATCH v11 16/16] tests: Add test-image-lock, Fam Zheng, 2017/01/20
- Re: [Qemu-block] [Qemu-devel] [PATCH v11 00/16] block: Image locking series, no-reply, 2017/01/20