Bug 1245453

Summary: virtio-blk in virtio 1.0 mode do not honor scsi=on
Product: Red Hat Enterprise Linux 7 Reporter: Xiaoqing Wei <xwei>
Component: qemu-kvm-rhevAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: jasowang, juzhang, virt-maint, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 07:29:28 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: 1366991    

Description Xiaoqing Wei 2015-07-22 06:29:45 UTC
Description of problem:

virtio-blk in virtio 1.0 mode do honor scsi=on

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.3.0-12.el7.x86_64
3.10.0-297.el7.x86_64 - guest driver

How reproducible:
100%

Steps to Reproduce:
1. boot a vm with virtio-blk-pci and disable-modern=off,disable-legacy=on,scsi=on
2. execute the test program, src code to be pasted in a separated comment later.
3. test program sees no difference between scsi=on and scsi=off

Actual results:

test program sees no difference between scsi=on and scsi=off

Expected results:
test program should see difference, in another word, qemu should expose scsi=on when cli asked.

Additional info:



[root@dhcp-8-150 ~]# lspci -nn
00:00.0 Host bridge [0600]: Intel Corporation 440FX - 82441FX PMC [Natoma] [8086:1237] (rev 02)
00:01.0 ISA bridge [0601]: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] [8086:7000]
00:01.1 IDE interface [0101]: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II] [8086:7010]
00:01.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI [8086:7113] (rev 03)
00:02.0 VGA compatible controller [0300]: Red Hat, Inc. QXL paravirtual graphic card [1b36:0100] (rev 04)
00:03.0 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 [8086:2934] (rev 03)
00:04.0 SCSI storage controller [0100]: Red Hat, Inc Virtio block device [1af4:1001]
00:05.0 Ethernet controller [0200]: Red Hat, Inc Virtio network device [1af4:1000]
00:06.0 SCSI storage controller [0100]: Red Hat, Inc Device [1af4:1042] (rev 01)
[root@dhcp-8-150 ~]# ./scsi_test /dev/vda
INQUIRY sense data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
 0x00 0x00 
INQUIRY SCSI status=0xff
[root@dhcp-8-150 ~]# ./scsi_test /dev/vdb
/dev/vdb is not an sg device, or old sg driver
[root@dhcp-8-150 ~]# grep . /sys/module/virtio_blk/parameters/*
128
[root@dhcp-8-150 ~]# grep . /sys/module/virtio_pci/parameters/*
N
[root@dhcp-8-150 ~]# uname -r
3.10.0-297.el7.x86_64
[root@dhcp-8-150 ~]# 


info qtree

    bus: pci.0
      type PCI
      dev: virtio-blk-pci, id "image2"
        class = 0 (0x0)
        ioeventfd = true
        vectors = 2 (0x2)
        virtio-pci-bus-master-bug-migration = false
        disable-legacy = true
        disable-modern = false
        addr = 06.0
        romfile = ""
        rombar = 1 (0x1)
        multifunction = false
        command_serr_enable = true
        class SCSI controller, addr 00:06.0, pci id 1af4:1042 (sub 1af4:1100)
        bar 1: mem at 0xfc054000 [0xfc054fff]
        bar 4: mem at 0xfe000000 [0xfe7fffff]
        bus: virtio-bus
          type virtio-pci-bus
          dev: virtio-blk-device, id ""
            drive = "drive_image2"
            logical_block_size = 512 (0x200)
            physical_block_size = 512 (0x200)
            min_io_size = 0 (0x0)
            opt_io_size = 0 (0x0)
            discard_granularity = 4294967295 (0xffffffff)
            cyls = 2080 (0x820)
            heads = 16 (0x10)
            secs = 63 (0x3f)
            serial = "QEMU-DISK1"
            config-wce = true
            scsi = true
            request-merging = true
            x-data-plane = false
            indirect_desc = true
            event_idx = true
            notify_on_empty = true


      dev: virtio-blk-pci, id "image1"
        class = 0 (0x0)
        ioeventfd = true
        vectors = 2 (0x2)
        virtio-pci-bus-master-bug-migration = false
        disable-legacy = false
        disable-modern = true
        addr = 04.0
        romfile = ""
        rombar = 1 (0x1)
        multifunction = false
        command_serr_enable = true
        class SCSI controller, addr 00:04.0, pci id 1af4:1001 (sub 1af4:0002)
        bar 0: i/o at 0xc000 [0xc03f]
        bar 1: mem at 0xfc052000 [0xfc052fff]
        bus: virtio-bus
          type virtio-pci-bus
          dev: virtio-blk-device, id ""
            drive = "drive_image1"
            logical_block_size = 512 (0x200)
            physical_block_size = 512 (0x200)
            min_io_size = 0 (0x0)
            opt_io_size = 0 (0x0)
            discard_granularity = 4294967295 (0xffffffff)
            cyls = 16383 (0x3fff)
            heads = 16 (0x10)
            secs = 63 (0x3f)
            serial = ""
            config-wce = true
            scsi = true
            request-merging = true
            x-data-plane = false
            indirect_desc = true
            event_idx = true
            notify_on_empty = true

Comment 1 Xiaoqing Wei 2015-07-22 06:31:14 UTC
test program source code

# cat a.c
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <scsi/sg.h> /* take care: fetches glibc's /usr/include/scsi/sg.h */
/* This is a simple program executing a SCSI INQUIRY command using the
* sg_io_hdr interface of the SCSI generic (sg) driver.
*
* * Copyright (C) 2001 D. Gilbert
* * This program is free software. Version 1.01 (20020226)
* */
#define INQ_REPLY_LEN 96
#define INQ_CMD_CODE 0x12
#define INQ_CMD_LEN 6
int main(int argc, char * argv[])
{
int sg_fd, k;
unsigned char inqCmdBlk[INQ_CMD_LEN] =
{INQ_CMD_CODE, 0, 0, 0, INQ_REPLY_LEN, 0};
/* This is a "standard" SCSI INQUIRY command. It is standard because the
* * CMDDT and EVPD bits (in the second byte) are zero. All SCSI targets
* * should respond promptly to a standard INQUIRY */
unsigned char inqBuff[INQ_REPLY_LEN];
unsigned char sense_buffer[32];
sg_io_hdr_t io_hdr;
if (2 != argc) {
printf("Usage: 'sg_simple0 <sg_device>'\n");
return 1;
}
if ((sg_fd = open(argv[1], O_RDONLY)) < 0) {
/* Note that most SCSI commands require the O_RDWR flag to be set */
perror("error opening given file name");
return 1;
}
/* It is prudent to check we have a sg device by trying an ioctl */
if ((ioctl(sg_fd, SG_GET_VERSION_NUM, &k) < 0) || (k < 30000)) {
printf("%s is not an sg device, or old sg driver\n", argv[1]);
return 1;
}
/* Prepare INQUIRY command */
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
io_hdr.interface_id = 'S';
io_hdr.cmd_len = sizeof(inqCmdBlk);
/* io_hdr.iovec_count = 0; */ /* memset takes care of this */
io_hdr.mx_sb_len = sizeof(sense_buffer);
io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
io_hdr.dxfer_len = INQ_REPLY_LEN;
io_hdr.dxferp = inqBuff;
io_hdr.cmdp = inqCmdBlk;
io_hdr.sbp = sense_buffer;
io_hdr.timeout = 20000; /* 20000 millisecs == 20 seconds */
/* io_hdr.flags = 0; */ /* take defaults: indirect IO, etc */
/* io_hdr.pack_id = 0; */
/* io_hdr.usr_ptr = NULL; */
if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) {
perror("sg_simple0: Inquiry SG_IO ioctl error");
return 1;
}
/* now for the error processing */
if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK) {
if (io_hdr.sb_len_wr > 0) {
printf("INQUIRY sense data: ");
for (k = 0; k < io_hdr.sb_len_wr; ++k) {
if ((k > 0) && (0 == (k % 10)))
printf("\n ");
printf("0x%02x ", sense_buffer[k]);
}
printf("\n");
}
if (io_hdr.masked_status)
printf("INQUIRY SCSI status=0x%x\n", io_hdr.status);
if (io_hdr.host_status)
printf("INQUIRY host_status=0x%x\n", io_hdr.host_status);
if (io_hdr.driver_status)
printf("INQUIRY driver_status=0x%x\n", io_hdr.driver_status);
}
else { /* assume INQUIRY response is present */
char * p = (char *)inqBuff;
printf("Some of the INQUIRY command's response:\n");
printf(" %.8s %.16s %.4s\n", p + 8, p + 16, p + 32);
printf("INQUIRY duration=%u millisecs, resid=%d\n",
io_hdr.duration, io_hdr.resid);
}
close(sg_fd);
return 0;
}



# gcc a.c -o scsi_test
# ./scsi_test /dev/vdX

Comment 2 Xiaoqing Wei 2015-07-22 06:34:30 UTC
found on x86_64, no sure about other arch

Comment 4 jason wang 2015-07-22 07:29:28 UTC
This is expected since:

- Modern driver won't negotiate VIRTIO_BLK_F_SCSI
- scsi ioctl won't work without VIRTIO_BLK_F_SCSI

So when modern is enabled, you will always get /dev/vdb is not an sg device, or old sg driver.

So I close this as not a bug.

Comment 5 Ademar Reis 2016-09-14 01:22:38 UTC
*** Bug 1365823 has been marked as a duplicate of this bug. ***