]> git.ipfire.org Git - thirdparty/qemu.git/commit
scsi-generic: let guests recognize readonly=on on passthrough devices
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 16 Sep 2015 15:26:16 +0000 (17:26 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Sep 2015 10:04:41 +0000 (12:04 +0200)
commit0eb2baeb449d27d6e6208a257dba6be1aad4d476
treeb5a99cbff011e402822b636fbf054c772bf4d591
parent5e43efb29ae877da131e6c1a4761cd7f4eec5a16
scsi-generic: let guests recognize readonly=on on passthrough devices

Passed-through SCSI devices can be opened with the readonly=on option.
When this happens, Linux filters away write commands so that the guest
cannot overwrite the contents of the device.

However, the guest does not know that the device is read-only, and
accepts writes.  The writes only fail later when the page cache is
flushed.

This patch modifies scsi-generic to modify the MODE SENSE data and
set the read-only bit in the device-specific parameters, so that
the guest OS treats the disk as write protected.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi/scsi-generic.c