]> git.proxmox.com Git - mirror_qemu.git/commit - block/file-posix.c
file-posix: Make auto-read-only dynamic
authorKevin Wolf <kwolf@redhat.com>
Fri, 1 Mar 2019 21:15:11 +0000 (22:15 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 12 Mar 2019 19:30:14 +0000 (20:30 +0100)
commit23dece19da41724349809873923e20a48b619cb7
treecba82738b64fcacaa7ad1cacd2b319f5f00782cb
parent6ceabe6f77e4ae5ac2fa3d2ac1be11dc95021941
file-posix: Make auto-read-only dynamic

Until now, with auto-read-only=on we tried to open the file read-write
first and if that failed, read-only was tried. This is actually not good
enough for libvirt, which gives QEMU SELinux permissions for read-write
only as soon as it actually intends to write to the image. So we need to
be able to switch between read-only and read-write at runtime.

This patch makes auto-read-only dynamic, i.e. the file is opened
read-only as long as no user of the node has requested write
permissions, but it is automatically reopened read-write as soon as the
first writer is attached. Conversely, if the last writer goes away, the
file is reopened read-only again.

bs->read_only is no longer set for auto-read-only=on files even if the
file descriptor is opened read-only because it will be transparently
upgraded as soon as a writer is attached. This changes the output of
qemu-iotests 232.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/file-posix.c
tests/qemu-iotests/232.out