[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH RFC] file-posix: make lock_fd read-only
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH RFC] file-posix: make lock_fd read-only |
Date: |
Tue, 10 Oct 2017 16:42:05 +0300 |
We do not reopen lock_fd on bdrv_reopen which leads to problems on
reopen image RO. So, lets make lock_fd be always RO.
This is correct, because qemu_lock_fd always called with exclusive=false
on lock_fd.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
Hi all!
We've faced the following problem with our shared-storage migration
scheme. We make an external snapshot and need base image to be reopened
RO. However, bdrv_reopen reopens only .fd of BDRVRawState but not
.lock_fd. So, .lock_fd is left opened RW and this breaks the whole
thing.
The simple fix is here: let's just open lock_fd as RO always. This
looks fine for current code, as we never try to set write locks
(qemu_lock_fd always called with exclusive=false).
However it will not work if we are going to use write locks.
block/file-posix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 36ee89e940..5c52df9174 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -514,7 +514,8 @@ static int raw_open_common(BlockDriverState *bs, QDict
*options,
s->lock_fd = -1;
if (s->use_lock) {
- fd = qemu_open(filename, s->open_flags);
+ /* open it read-only, as we do not reopen it on bdrv_reopen */
+ fd = qemu_open(filename, (s->open_flags & ~BDRV_O_RDWR));
if (fd < 0) {
ret = -errno;
error_setg_errno(errp, errno, "Could not open '%s' for locking",
--
2.11.1
- [Qemu-block] [PATCH RFC] file-posix: make lock_fd read-only,
Vladimir Sementsov-Ogievskiy <=