]> git.proxmox.com Git - qemu.git/commit
block/raw-posix: detect readonly Linux block devices using BLKROGET
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 5 Feb 2013 11:28:33 +0000 (12:28 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 12 Feb 2013 11:22:49 +0000 (12:22 +0100)
commitda888d37b0b85fc23e4ea55ab8b0c482d4918afb
tree3bd61e29ccc1bc7acd86533b89a388b39e28a5b0
parent58fa4325228f61d58317f48364259b31e9b92d15
block/raw-posix: detect readonly Linux block devices using BLKROGET

Linux block devices can be set read-only with "blockdev --setro
<device>".  The same thing can be done for LVM volumes using "lvchange
--permission r <volume>".  This read-only setting is independent of
device node permissions.  Therefore the device can still be opened
O_RDWR but actual writes will fail.

This results in odd behavior for QEMU.  bdrv_open() is supposed to fail
if a read-only image is being opened with BDRV_O_RDWR.  By not failing
for Linux block devices, the guest boots up but every write produces an
I/O error.

This patch checks whether the block device is read-only so that Linux
block devices behave like regular files.

Reported-by: Sibiao Luo <sluo@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/raw-posix.c