Skip to content

Commit

Permalink
file-posix: check the use_lock before setting the file lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Li Feng authored and kevmw committed Dec 11, 2020
1 parent e6c7964 commit eb43ea1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/file-posix.c
Expand Up @@ -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) {
Expand Down

0 comments on commit eb43ea1

Please sign in to comment.