aboutsummaryrefslogtreecommitdiff
path: root/block/file-posix.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-05-22 19:03:45 +0200
committerKevin Wolf <kwolf@redhat.com>2019-06-18 16:41:10 +0200
commit094e36394481fd2c8493cec2a7c026f342232f15 (patch)
tree8fcf57cf3571ecfaef0858757707fcd25e4a8123 /block/file-posix.c
parentb23c580c946644b906af36e3f903b9fedd6ccd61 (diff)
downloadqemu-094e36394481fd2c8493cec2a7c026f342232f15.zip
qemu-094e36394481fd2c8493cec2a7c026f342232f15.tar.gz
qemu-094e36394481fd2c8493cec2a7c026f342232f15.tar.bz2
file-posix: Update open_flags in raw_set_perm()
raw_check_perm() + raw_set_perm() can change the flags associated with the current FD. If so, we have to update BDRVRawState.open_flags accordingly. Otherwise, we may keep reopening the FD even though the current one already has the correct flags. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/file-posix.c')
-rw-r--r--block/file-posix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block/file-posix.c b/block/file-posix.c
index 83ab1b7..ab05b51 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -146,6 +146,7 @@ typedef struct BDRVRawState {
uint64_t locked_shared_perm;
int perm_change_fd;
+ int perm_change_flags;
BDRVReopenState *reopen_state;
#ifdef CONFIG_XFS
@@ -2788,6 +2789,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
assert(s->reopen_state->shared_perm == shared);
rs = s->reopen_state->opaque;
s->perm_change_fd = rs->fd;
+ s->perm_change_flags = rs->open_flags;
} else {
/* We may need a new fd if auto-read-only switches the mode */
ret = raw_reconfigure_getfd(bs, bs->open_flags, &open_flags, perm,
@@ -2796,6 +2798,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
return ret;
} else if (ret != s->fd) {
s->perm_change_fd = ret;
+ s->perm_change_flags = open_flags;
}
}
@@ -2834,6 +2837,7 @@ static void raw_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared)
if (s->perm_change_fd && s->fd != s->perm_change_fd) {
qemu_close(s->fd);
s->fd = s->perm_change_fd;
+ s->open_flags = s->perm_change_flags;
}
s->perm_change_fd = 0;