Stefan Hajnoczi <stefa...@redhat.com> writes:

> 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 <s...@redhat.com>
> Suggested-by: Paolo Bonzini <pbonz...@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>

Reviewed-by: Markus Armbruster <arm...@redhat.com>

Reply via email to