Bug 1525829 - can not boot up a scsi-block passthrough disk via -blockdev with error "cannot get SG_IO version number: Operation not supported. Is this a SCSI device?"
Summary: can not boot up a scsi-block passthrough disk via -blockdev with error "canno...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Kevin Wolf
QA Contact: CongLi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-14 06:50 UTC by CongLi
Modified: 2018-11-01 11:05 UTC (History)
11 users (show)

Fixed In Version: qemu-kvm-rhev-2.12.0-8.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-01 11:04:00 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3443 None None None 2018-11-01 11:05:51 UTC

Description CongLi 2017-12-14 06:50:07 UTC
Description of problem:
can not boot up a scsi-block passthrough disk via -blockdev with error "cannot get SG_IO version number: Operation not supported.  Is this a SCSI device?" 

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.10.0-12.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. simulate a scsi disk on host:
# modprobe scsi_debug lbpu=1 dev_size_mb=1024
2. check the disk:
# lsscsi 
[0:0:0:0]    storage HP       P420i            7.02  -        
[0:1:0:0]    disk    HP       LOGICAL VOLUME   7.02  /dev/sda 
[3:0:0:0]    cd/dvd  hp       DVDRAM GT80N     EA02  /dev/sr0 
[16:0:0:0]   disk    Linux    scsi_debug       0004  /dev/sdb  
3. passthrough /dev/sdb to guest:
    -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=0x3 \
    -blockdev driver=raw,node-name=drive2,file.driver=file,file.filename=/dev/sdb \
    -device scsi-block,drive=drive2 \

Actual results:
can not boot up the disk via -blockdev with error:
QEMU 2.10.0 monitor - type 'help' for more information
(qemu) qemu-kvm: -device scsi-block,drive=drive2: cannot get SG_IO version number: Operation not supported.  Is this a SCSI device?

Expected results:
should boot up the scsi-block disk via -blockdev successfully

Additional info:
1. scsi-hd + -blockdev works well:
    -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=0x3 \
    -blockdev driver=raw,node-name=drive2,file.driver=file,file.filename=/dev/sdb \
    -device scsi-hd,drive=drive2 \

QEMU 2.10.0 monitor - type 'help' for more information
(qemu) q

2. -drive + scsi_block works well:
    -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=0x3 \
    -drive file=/dev/sdb,if=none,id=drive2,format=raw \
    -device scsi-block,drive=drive2 \

QEMU 2.10.0 monitor - type 'help' for more information
(qemu) q

Comment 2 Paolo Bonzini 2017-12-15 14:15:02 UTC
"-drive" with file.driver=file also doesn't work:

  -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=0x3 \
  -drive format=raw,if=none,id=drive2,file.driver=file,file.filename=/dev/sdc \
  -device scsi-block,drive=drive2

This is unintuitive behavior, and it's not documented anywhere, so we may want to add some workaround or improve the error message.  However, it is intended.  You are specifying "file.driver=file", and files are not SCSI devices. :)  It works with "file.driver=host_device", and that's what libvirt should specify.

Kevin, any ideas?

Comment 3 CongLi 2017-12-18 09:47:13 UTC
(In reply to Paolo Bonzini from comment #2)
> "-drive" with file.driver=file also doesn't work:
> 
>   -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=0x3 \
>   -drive
> format=raw,if=none,id=drive2,file.driver=file,file.filename=/dev/sdc \
>   -device scsi-block,drive=drive2
> 
> This is unintuitive behavior, and it's not documented anywhere, so we may
> want to add some workaround or improve the error message.  However, it is
> intended.  You are specifying "file.driver=file", and files are not SCSI
> devices. :)  It works with "file.driver=host_device", and that's what
> libvirt should specify.

Thanks Paolo for the explanation.
And it would be great that list all driver options in qemu-options.hx. :)

Comment 4 Kevin Wolf 2017-12-18 10:17:24 UTC
(In reply to Paolo Bonzini from comment #2)
> Kevin, any ideas?

Perhaps the file driver can print a warning if you don't give it a regular file? We could possibly even make it an error after a few releases.

Comment 6 Miroslav Rezanina 2018-07-24 14:08:46 UTC
Fix included in qemu-kvm-rhev-2.12.0-8.el7

Comment 8 CongLi 2018-08-01 08:43:10 UTC
Tested with qemu-kvm-rhev-2.12.0-8.el7.x86_64:

Test pass with iotest 226.

1.  driver: file
1.1 directory (/root/test is a directory)
qemu-kvm: -blockdev driver=raw,file.driver=file,node-name=drive2,file.filename=/root/test: Could not open '/root/test': Is a directory

1.2 host device (/dev/sdc is a host device)
qemu-kvm: -blockdev driver=raw,file.driver=file,node-name=drive2,file.filename=/dev/sdc: warning: Opening a block device as a file using the 'file' driver is deprecated

1.3 file --> successfully

2.  driver: host_device
2.1 directory (/root/test is a directory)
qemu-kvm: -blockdev driver=raw,file.driver=host_device,node-name=drive2,file.filename=/root/test: Could not open '/root/test': Is a directory

2.2 file
qemu-kvm: -blockdev driver=qcow2,file.driver=host_device,node-name=drive2,file.filename=/root/test.qcow2: 'host_device' driver expects either a character or block device

2.3 host device --> successfully

3. driver: host_cdrom
qemu-kvm: -blockdev driver=raw,file.driver=host_cdrom,node-name=drive2,file.filename=/root/test: Driver 'host_cdrom' is not whitelisted


Hi Kevin,

QE met 'Driver 'host_cdrom' is not whitelisted' error, I would like to confirm if QEMU downstream support it or it's a missing.

Thanks.

Comment 9 Fam Zheng 2018-08-01 09:20:10 UTC
host_cdrom is disabled on purpose in RHEL7. See also BZ 760885 and BZ 1077302.

Comment 10 CongLi 2018-08-01 10:30:00 UTC
(In reply to Fam Zheng from comment #9)
> host_cdrom is disabled on purpose in RHEL7. See also BZ 760885 and BZ
> 1077302.

Thanks Fam.

Based on comment 8 and comment 9, set this bug to 'VERIFIED'.

Comment 11 errata-xmlrpc 2018-11-01 11:04:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3443


Note You need to log in before you can comment on or make changes to this bug.