Bug 1095663

Summary: Support read only VirtIO-SCSI direct LUNs in QEMU
Product: Red Hat Enterprise Linux 6 Reporter: Allon Mureinik <amureini>
Component: qemu-kvmAssignee: Paolo Bonzini <pbonzini>
Status: CLOSED DEFERRED QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: acathrow, bsarathy, chayang, ebenahar, famz, iheim, juzhang, michen, mkenneth, pbonzini, qzhang, rwashbur, scohen, sluo, vered, virt-maint
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
: 1110396 (view as bug list) Environment:
Last Closed: 2014-06-17 14:44:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1095666, 1110396    

Description Allon Mureinik 2014-05-08 10:18:27 UTC
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

Comment 1 Allon Mureinik 2014-05-08 10:23:48 UTC
Sean, IIUC, this usecase is especially interesting for CFME. Can you elaborate please?

Comment 2 Andrew Cathrow 2014-05-19 14:26:40 UTC
Is this a realistic RFE, it makes sense for virtio-blk but do we want to go down this path for virtio-scsi

Comment 3 Andrew Cathrow 2014-05-19 14:26:51 UTC
Is this a realistic RFE, it makes sense for virtio-blk but do we want to go down this path for virtio-scsi

Comment 7 Ademar Reis 2014-06-17 14:44:59 UTC
Clone for RHEL7: Bug 1110396

Closing this RHEL6 version as WONTFIX.