summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Feng2020-12-07 12:44:06 +0100
committerKevin Wolf2020-12-11 17:52:40 +0100
commiteb43ea16dcb7e6ab01db321b5edac3e593556e7d (patch)
treebff36c40fd24a15515c6596a5f241a45c2d59ba6
parentiotests/308: Add test for FUSE exports (diff)
downloadqemu-eb43ea16dcb7e6ab01db321b5edac3e593556e7d.tar.gz
qemu-eb43ea16dcb7e6ab01db321b5edac3e593556e7d.tar.xz
qemu-eb43ea16dcb7e6ab01db321b5edac3e593556e7d.zip
file-posix: check the use_lock before setting the file lock
The scenario is that when accessing a volume on an NFS filesystem without supporting the file lock, Qemu will complain "Failed to lock byte 100", even when setting the file.locking = off. We should do file lock related operations only when the file.locking is enabled, otherwise, the syscall of 'fcntl' will return non-zero. Signed-off-by: Li Feng <fengli@smartx.com> Message-Id: <1607341446-85506-1-git-send-email-fengli@smartx.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/file-posix.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/file-posix.c b/block/file-posix.c
index d5fd1dbcd2..806764f7e3 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -3104,7 +3104,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
}
/* Copy locks to the new fd */
- if (s->perm_change_fd) {
+ if (s->perm_change_fd && s->use_lock) {
ret = raw_apply_lock_bytes(NULL, s->perm_change_fd, perm, ~shared,
false, errp);
if (ret < 0) {