Description of problem:
After discussing the issue with Paolo on bug 1082673, it is clear that QEMU does not support read-only access to VirtIO-SCSI direct LUNs:
"""
Making a SCSI LUN read-only requires intercepting passed-through commands and modifying the results (for example change the inquiry data to report the LUN as read-only, and QEMU never needed to do this yet).
Is QEMU running as root? If so, one problem is that the kernel doesn't filter write commands on read-only file descriptors when the process has CAP_SYS_RAWIO. This would be a separate fix.
But even if QEMU is not running as root, the kernel will treat the disk as writable and write data to the page cache, only to fail later at writeback time. If QEMU is not running as root, you should notice that adding "oflag=direct" causes writes to fail directly, because they bypass the page cache.
"""
This bug is opened to track the effort of supporting such a flow.
Version-Release number of selected component (if applicable):
qemu-kvm-rhev-0.12.1.2-2.415.el6_5.7.x86_64
How reproducible:
100%
Steps to Reproduce
(copied from bug 1082673, and edited to remove RHEVM specific terminology):
1. Create a VM with disk attached, install RHEL 6.5 guest OS
2. Expose a LUN to the host
3. Attach the LUN to the VM as direct LUN via Virt-IO-SCSI as read-only
4. Try to write to the disk from the guest. I tried with 'dd':
# dd if=/dev/zero of=/dev/sdc bs=1K count=50
Actual results:
Data is written on the device when it is connected via Virt-IO-SCSI:
[root@localhost ~]# dd if=/dev/zero of=/dev/sdc bs=1K count=50
50+0 records in
50+0 records out
51200 bytes (51 kB) copied, 0.0255978 s, 2.0 MB/s