Bug 1179577

Summary: QEMU fail to do SG_IO INQUIRY checking when pass-through(scsi-block) a LVM to KVM guest
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvm-rhevAssignee: Ademar Reis <areis>
Status: CLOSED CANTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: chayang, famz, juzhang, knoel, kwolf, michen, pbonzini, qzhang, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1179578 (view as bug list) Environment:
Last Closed: 2015-01-08 18:14:55 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: 1179578    

Description Sibiao Luo 2015-01-07 06:59:13 UTC
Description of problem:
as subject, QEMU fail to do SG_IO INQUIRY checking when pass-through(scsi-block) a LV to KVM guest. LVM is not SCSI device which should not be pass-through to KVM guest.

Version-Release number of selected component (if applicable):
host info:
# uname -r && rpm -q qemu-kvm
3.10.0-220.el7.x86_64
qemu-kvm-rhev-2.1.2-17.el7.x86_64
guest info:
# uname -r
3.10.0-220.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.create a LVM in guest.
# lvscan | grep lv
  ACTIVE            '/dev/vg/lv' [10.00 GiB] inherit

2.pass-through(scsi-block) a LVM to KVM guest.
e.g: # /usr/libexec/qemu-kvm -M pc -cpu Opteron_G2 -enable-kvm -m 2048 -smp 2,sockets=2,cores=1,threads=1 -no-kvm-pit-reinjection -drive file=/dev/vg/lv,if=none,id=drive-data-disk,format=raw,cache=none,aio=native -device virtio-scsi-pci,bus=pci.0,addr=0x7,id=scsi0,ioeventfd=on -device scsi-block,drive=drive-data-disk,id=data-disk,bus=scsi0.0...

Actual results:
after step 2, it can boot up successfully and the LVM work well in guest.

Expected results:
QEMU should reject to pass-through a LVM to KVM guest, like:
(qemu) qemu-kvm: -device scsi-block,drive=drive-data-disk,id=data-disk,bus=scsi0.0: cannot get SG_IO version number: Operation not supported.  Is this a SCSI device?
qemu-kvm: -device scsi-block,drive=drive-data-disk,id=data-disk,bus=scsi0.0: Device initialization failed.
qemu-kvm: -device scsi-block,drive=drive-data-disk,id=data-disk,bus=scsi0.0: Device 'scsi-block' could not be initialized

Additional info:
rhel6.x did not hit this issue, just rhel7 hit it.
for rhel6.x prompting example:
qemu-kvm: -device scsi-block,drive=drive-data-disk,id=data-disk,bus=scsi0.0: scsi-block: INQUIRY failed
qemu-kvm: -device scsi-block,drive=drive-data-disk,id=data-disk,bus=scsi0.0: Device 'scsi-block' could not be initialized

Comment 1 Paolo Bonzini 2015-01-08 18:14:55 UTC
This is unfortunately expected behavior when CAP_SYS_RAWIO is valid.  The patch that was applied to RHEL6 was rejected upstream and is not in RHEL7.  Example:

# capsh --drop=cap_sys_rawio -- -c '/usr/libexec/qemu-kvm -M pc -enable-kvm -m 2048 -smp 2 -drive file=/dev/vg-root/rhel5-x86-64,id=root,if=none -device virtio-scsi-pci -device scsi-block,drive=root -S'
qemu-kvm: -device scsi-block,drive=root: scsi-block: INQUIRY failed
qemu-kvm: -device scsi-block,drive=root: Device initialization failed.
qemu-kvm: -device scsi-block,drive=root: Device 'scsi-block' could not be initialized

(put the capsh command on a single line).