s390x: Enable virtio-scsi boot from /dev/sgX
v2 cover s390x: Enable virtio-scsi boot from /dev/sgX
Today, trying to boot a guest from a SCSI LUN on s390x yields the following:
virtio-blk = OK
virtio-scsi and /dev/sdX = OK
virtio-scsi and /dev/sgX = FAIL
Example of the failing scenario:
/usr/bin/qemu-system-s390x ...
-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001
-drive file=/dev/sg2,if=none,id=drive0,format=raw
-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,drive=drive0,id=disk0 LOADPARM=[........]
Using virtio-scsi.
Using SCSI scheme.
..
! virtio-scsi:read_many: STATUS=02 RSPN=70 KEY=0b CODE=00 QLFR=06, sure !
Why do we care? Well, libvirt converts a virtio-scsi device from the host SCSI address (host:bus:target:lun) into the associated /dev/sgX device, which means we can't boot from virtio-scsi and have to rely on virtio-blk for this action.
The short version of what happens is the host block device driver rejects our requests because the transfer lengths are too long for it to satisfy. A virtio-scsi disk connected via scsi-generic is fine as a non-boot device because the guest kernel is able to break up the requests for us. So we just need to handle this situation for the boot process.
Patches 1-3 read the max_sectors parameter for the virtio-scsi controller, and break up the READ(10) I/Os into something that the host will accept. If not specified, max_sectors defaults to 65535, but could look like this:
qemu-system-s390x ...
-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001,max_sectors=2048
Patches 4-6 read the max_io_size parameter for the virtio-scsi disk device, and use the minimum of it and the max_sectors from the controller for breaking up the READ(10) I/Os. If not specified, max_io_size defaults to 2147483647 but could look like this:
qemu-system-s390x ...
-drive file=/dev/sda,if=none,id=drive0,format=raw ...
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,
drive=drive0,id=disk0,max_io_size=1048576In the two examples above, the maximum parameters are equivalent due to the controller parameter measuring 512-byte blocks, and the disk measuring bytes.
Patch 7 establishes a workable default, in case neither the controller nor the disk have the parameters specified (and thus the overly large defaults are taken), or if they are set to something beyond what we can boot from.
Patch 8 rebuilds the s390-ccw BIOS with this entire patch set.
Changelog:
RFC v2:
- Dropped patch outside the pc-bios/s390-ccw/ tree
- Added Christian's r-b to patch 1 (formerly patch 2)
- Added EVPD Inquiry calls to retrieve Block Limits page if supported
- Added a default if Block Limits page is not supported, or response is still way to big to allow boot
RFC v1:
- https://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg05121.html
Eric Farman (8):
pc-bios/s390-ccw: Remove duplicate blk_factor adjustment pc-bios/s390-ccw: Move SCSI block factor to outer read pc-bios/s390-ccw: Break up virtio-scsi read into multiples pc-bios/s390-ccw: Refactor scsi_inquiry function pc-bios/s390-ccw: Get list of supported VPD pages pc-bios/s390-ccw: Get Block Limits VPD device data pc-bios/s390-ccw: Build a reasonable max_sectors limit pc-bios/s390-ccw.img: rebuild image
pc-bios/s390-ccw.img | Bin 26472 -> 26480 bytes pc-bios/s390-ccw/s390-ccw.h | 7 ++++ pc-bios/s390-ccw/scsi.h | 30 +++++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 85 +++++++++++++++++++++++++++++++++++------ pc-bios/s390-ccw/virtio-scsi.h | 2 + pc-bios/s390-ccw/virtio.h | 1 + 6 files changed, 114 insertions(+), 11 deletions(-)
Signature · 1 line
2.10.2
RFC PATCH v2 1/8 pc-bios/s390-ccw: Remove duplicate blk_factor adjustment
When using virtio-scsi, we multiply the READ(10) data_size by a block factor twice when building the I/O. This is fine, since it's only 1 for SCSI disks, but let's clean it up.
--- pc-bios/s390-ccw/virtio-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pc-bios/s390-ccw/virtio-scsi.c +1 -1
@@ -154,7 +154,7 @@ static bool scsi_read_10(VDev *vdev,VirtioCmd read_10[] = { { &req,sizeof (req),VRING_DESC_F_NEXT }, { &resp,sizeof (resp),VRING_DESC_F_WRITE |VRING_DESC_F_NEXT }, - { data, data_size * f,VRING_DESC_F_WRITE }, + { data, data_size,VRING_DESC_F_WRITE }, };debug_print_int ("read_10 sector" , sector);
Signature · 1 line
2.10.2
RFC PATCH v2 2/8 pc-bios/s390-ccw: Move SCSI block factor to outer read
In reply to Eric FarmanSimple refactoring so that the blk_factor adjustment is moved into virtio_scsi_read_many routine, in preparation for another change.
--- pc-bios/s390-ccw/virtio-scsi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/virtio-scsi.c +8 -6
@@ -142,14 +142,13 @@ static bool scsi_report_luns(VDev *vdev, void *data, uint32_t data_size) }static bool scsi_read_10 (VDev *vdev, -ulong sector,int sectors,void *data) +ulong sector,int sectors,void *data, +unsigned int data_size) { -int f = vdev->blk_factor; -unsigned int data_size = sectors *virtio_get_block_size () * f;ScsiCdbRead10 cdb = { .command =0x28 , - .lba = sector * f, - .xfer_length = sectors * f, + .lba = sector, + .xfer_length = sectors, };VirtioCmd read_10[] = { { &req,sizeof (req),VRING_DESC_F_NEXT },
@@ -255,7 +254,10 @@ static void virtio_scsi_locate_device(VDev *vdev)int virtio_scsi_read_many (VDev *vdev,ulong sector,void *load_addr,int sec_num) { -if (!scsi_read_10 (vdev, sector, sec_num, load_addr)) { +int f = vdev->blk_factor; +unsigned int data_size = sec_num *virtio_get_block_size () * f; + +if (!scsi_read_10 (vdev, sector * f, sec_num * f, load_addr, data_size)) {virtio_scsi_verify_response (&resp,"virtio-scsi:read_many" ); }
Signature · 1 line
2.10.2
RFC PATCH v2 4/8 pc-bios/s390-ccw: Refactor scsi_inquiry function
In reply to Eric FarmanIf we want to issue any of the SCSI Inquiry EVPD pages, which we do, we could use this function to issue both types of commands with a little bit of refactoring.
--- pc-bios/s390-ccw/scsi.h | 6 ++++++ pc-bios/s390-ccw/virtio-scsi.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/scsi.h +6 -0
@@ -26,6 +26,12 @@#define SCSI_SENSE_KEY_NO_SENSE 0#define SCSI_SENSE_KEY_UNIT_ATTENTION 6 +/* SCSI Inquiry Types */ +#define SCSI_INQUIRY_STANDARD 0x00U + +/* SCSI Inquiry Pages */ +#define SCSI_INQUIRY_STANDARD_NONE 0x00U +union ScsiLun {uint64_t v64;/* numeric shortcut */ uint8_t v8[8 ];/* generic 8 bytes representation */
pc-bios/s390-ccw/virtio-scsi.c +8 -2
@@ -89,10 +89,13 @@ static void vs_run(const char *title, VirtioCmd *cmd, VDev *vdev,/* SCSI protocol implementation routines */ -static bool scsi_inquiry (VDev *vdev,void *data,uint32_t data_size) +static bool scsi_inquiry (VDev *vdev,uint8_t evpd,uint8_t page, +void *data,uint32_t data_size) {ScsiCdbInquiry cdb = { .command =0x12 , + .b1 = evpd, + .b2 = page, .alloc_len = data_size <65535 ? data_size :65535 , };VirtioCmd inquiry[] = {
@@ -346,7 +349,10 @@ void virtio_scsi_setup(VDev *vdev) }/* read and cache SCSI INQUIRY response */ -if (!scsi_inquiry (vdev, scsi_inquiry_std_response, +if (!scsi_inquiry (vdev, +SCSI_INQUIRY_STANDARD , +SCSI_INQUIRY_STANDARD_NONE , + scsi_inquiry_std_response,sizeof (scsi_inquiry_std_response))) {virtio_scsi_verify_response (&resp,"virtio-scsi:setup:inquiry" ); }
Signature · 1 line
2.10.2
RFC PATCH v2 6/8 pc-bios/s390-ccw: Get Block Limits VPD device data
In reply to Eric FarmanThe "Block Limits" Inquiry VPD page is optional for any SCSI device, but if it's supported it provides a hint of the maximum I/O transfer length for this particular device. If this page is supported by the disk, let's issue that Inquiry and use the minimum of it and the SCSI controller limit. That will cover this scenario:
qemu-system-s390x ...
-device virtio-scsi-ccw,id=scsi0,max_sectors=32768 ...
-drive file=/dev/sda,if=none,id=drive0,format=raw ...
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,
drive=drive0,id=disk0,max_io_size=1048576controller: 32768 sectors x 512 bytes/sector = 16777216 bytes
disk: 1048576 bytes
Now that we have a limit for a virtio-scsi disk, compare that with the limit for the virtio-scsi controller when we actually build the I/O. The minimum of these two limits should be the one we use.
--- pc-bios/s390-ccw/scsi.h | 14 ++++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 21 ++++++++++++++++++++- pc-bios/s390-ccw/virtio.h | 1 + 3 files changed, 35 insertions(+), 1 deletion(-)
pc-bios/s390-ccw/scsi.h +14 -0
@@ -33,6 +33,7 @@/* SCSI Inquiry Pages */ #define SCSI_INQUIRY_STANDARD_NONE 0x00U#define SCSI_INQUIRY_EVPD_SUPPORTED_PAGES 0x00U +#define SCSI_INQUIRY_EVPD_BLOCK_LIMITS 0xb0Uunion ScsiLun {uint64_t v64;/* numeric shortcut */
@@ -87,6 +88,19 @@ struct ScsiInquiryEvpdPages { } __attribute__((packed));typedef struct ScsiInquiryEvpdPages ScsiInquiryEvpdPages ; +struct ScsiInquiryEvpdBl { +uint8_t peripheral_qdt;/* b0, use (b0 & 0x1f) to get SCSI_INQ_RDT */ +uint8_t page_code; +uint16_t page_length; +uint8_t b4; +uint8_t b5; +uint16_t b6; +uint32_t max_transfer;/* b8 */ +uint32_t b12[7 ];/* b12..b43 (defined fields) */ +uint32_t b44[5 ];/* b44..b63 (reserved fields) */ +} __attribute__((packed)); +typedef struct ScsiInquiryEvpdBl ScsiInquiryEvpdBl ; +struct ScsiCdbInquiry {uint8_t command;/* b0, == 0x12 */ uint8_t b1;/* b1, |= 0x01 (evpd) */
pc-bios/s390-ccw/virtio-scsi.c +20 -1
@@ -20,6 +20,7 @@ static VirtioScsiCmdResp resp;static uint8_t scsi_inquiry_std_response[256 ];static ScsiInquiryEvpdPages scsi_inquiry_evpd_pages_response; +static ScsiInquiryEvpdBl scsi_inquiry_evpd_bl_response;static inline void vs_assert (bool term,const char **msgs) {
@@ -262,9 +263,11 @@ int virtio_scsi_read_many(VDev *vdev,int sector_count;int f = vdev->blk_factor;unsigned int data_size; +unsigned int max_transfer =MIN_NON_ZERO (vdev->config.scsi.max_sectors, + vdev->max_transfer); do { - sector_count = MIN_NON_ZERO(sec_num, vdev->config.scsi.max_sectors); + sector_count = MIN_NON_ZERO(sec_num, max_transfer); data_size = sector_count * virtio_get_block_size() * f; if (!scsi_read_10(vdev, sector * f, sector_count * f, load_addr, data_size)) {
@@ -321,6 +324,7 @@ void virtio_scsi_setup(VDev *vdev)uint8_t data[256 ];uint32_t data_size =sizeof (data);ScsiInquiryEvpdPages *evpd = &scsi_inquiry_evpd_pages_response; +ScsiInquiryEvpdBl *evpd_bl = &scsi_inquiry_evpd_bl_response;int i; vdev->scsi_device = &default_scsi_device;
@@ -378,6 +382,21 @@ void virtio_scsi_setup(VDev *vdev)for (i =0 ; i <= evpd->page_length; i++) {debug_print_int ("supported EVPD page" , evpd->byte[i]); + +if (evpd->byte[i] !=SCSI_INQUIRY_EVPD_BLOCK_LIMITS ) { +continue ; + } + +if (!scsi_inquiry (vdev, +SCSI_INQUIRY_EVPD , +SCSI_INQUIRY_EVPD_BLOCK_LIMITS , + evpd_bl, +sizeof (*evpd_bl))) { +virtio_scsi_verify_response (&resp,"virtio-scsi:setup:blocklimits" ); + } + +debug_print_int ("max transfer" , evpd_bl->max_transfer); + vdev->max_transfer = evpd_bl->max_transfer; }if (!scsi_read_capacity (vdev, data, data_size)) {
pc-bios/s390-ccw/virtio.h +1 -0
@@ -277,6 +277,7 @@ struct VDev {bool scsi_device_selected;ScsiDevice selected_scsi_device;uint64_t netboot_start_addr; +uint32_t max_transfer; };typedef struct VDev VDev ;
Signature · 1 line
2.10.2
RFC PATCH v2 3/8 pc-bios/s390-ccw: Break up virtio-scsi read into multiples
In reply to Eric FarmanA virtio-scsi request that goes through the host sd driver and exceeds the maximum transfer size is automatically broken up for us. But the equivalent request going to the sg driver presumes that any length requirements have already been honored.
Let's use the max_sectors field on the virtio-scsi controller device, and break up all requests (both sd and sg) to avoid this problem.
--- pc-bios/s390-ccw/s390-ccw.h | 7 +++++++ pc-bios/s390-ccw/virtio-scsi.c | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-)
pc-bios/s390-ccw/s390-ccw.h +7 -0
@@ -42,6 +42,13 @@ typedef unsigned long long __u64;#ifndef NULL #define NULL 0#endif +#ifndef MIN +#define MIN (a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MIN_NON_ZERO +#define MIN_NON_ZERO (a, b) ((a) == 0 ? (b) : \ + ((b) == 0 ? (a) : (MIN(a, b)))) +#endif #include "cio.h" #include "iplb.h"
pc-bios/s390-ccw/virtio-scsi.c +15 -5
@@ -202,6 +202,7 @@ static void virtio_scsi_locate_device(VDev *vdev)debug_print_int ("config.scsi.max_channel" , vdev->config.scsi.max_channel);debug_print_int ("config.scsi.max_target " , vdev->config.scsi.max_target);debug_print_int ("config.scsi.max_lun " , vdev->config.scsi.max_lun); +debug_print_int ("config.scsi.max_sectors" , vdev->config.scsi.max_sectors);if (vdev->scsi_device_selected) { sdev->channel = vdev->selected_scsi_device.channel;
@@ -254,12 +255,21 @@ static void virtio_scsi_locate_device(VDev *vdev)int virtio_scsi_read_many (VDev *vdev,ulong sector,void *load_addr,int sec_num) { +int sector_count;int f = vdev->blk_factor; -unsigned int data_size = sec_num *virtio_get_block_size () * f; - -if (!scsi_read_10 (vdev, sector * f, sec_num * f, load_addr, data_size)) { -virtio_scsi_verify_response (&resp,"virtio-scsi:read_many" ); - } +unsigned int data_size; + +do { + sector_count =MIN_NON_ZERO (sec_num, vdev->config.scsi.max_sectors); + data_size = sector_count *virtio_get_block_size () * f; +if (!scsi_read_10 (vdev, sector * f, sector_count * f, load_addr, + data_size)) { +virtio_scsi_verify_response (&resp,"virtio-scsi:read_many" ); + } + load_addr += data_size; + sector += sector_count; + sec_num -= sector_count; + }while (sec_num >0 );return 0 ; }
Signature · 1 line
2.10.2
RFC PATCH v2 5/8 pc-bios/s390-ccw: Get list of supported VPD pages
In reply to Eric FarmanThe "Supported Pages" Inquiry EVPD page is mandatory for all SCSI devices, and is used as a gateway for what VPD pages the device actually supports. Let's issue this Inquiry, and dump that list with the debug facility.
--- pc-bios/s390-ccw/scsi.h | 10 ++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 17 +++++++++++++++++ 2 files changed, 27 insertions(+)
pc-bios/s390-ccw/scsi.h +10 -0
@@ -28,9 +28,11 @@/* SCSI Inquiry Types */ #define SCSI_INQUIRY_STANDARD 0x00U +#define SCSI_INQUIRY_EVPD 0x01U/* SCSI Inquiry Pages */ #define SCSI_INQUIRY_STANDARD_NONE 0x00U +#define SCSI_INQUIRY_EVPD_SUPPORTED_PAGES 0x00Uunion ScsiLun {uint64_t v64;/* numeric shortcut */
@@ -77,6 +79,14 @@ struct ScsiInquiryStd { } __attribute__((packed));typedef struct ScsiInquiryStd ScsiInquiryStd ; +struct ScsiInquiryEvpdPages { +uint8_t peripheral_qdt;/* b0, use (b0 & 0x1f) to get SCSI_INQ_RDT */ +uint8_t page_code;/* b1 */ +uint16_t page_length;/* b2..b3 length = N-3 */ +uint8_t byte[28 ];/* b4..bN Supported EVPD pages (N=31 here) */ +} __attribute__((packed)); +typedef struct ScsiInquiryEvpdPages ScsiInquiryEvpdPages ; +struct ScsiCdbInquiry {uint8_t command;/* b0, == 0x12 */ uint8_t b1;/* b1, |= 0x01 (evpd) */
pc-bios/s390-ccw/virtio-scsi.c +17 -0
@@ -19,6 +19,7 @@ static VirtioScsiCmdReq req;static VirtioScsiCmdResp resp;static uint8_t scsi_inquiry_std_response[256 ]; +static ScsiInquiryEvpdPages scsi_inquiry_evpd_pages_response;static inline void vs_assert (bool term,const char **msgs) {
@@ -319,6 +320,8 @@ void virtio_scsi_setup(VDev *vdev)int retry_test_unit_ready =3 ;uint8_t data[256 ];uint32_t data_size =sizeof (data); +ScsiInquiryEvpdPages *evpd = &scsi_inquiry_evpd_pages_response; +int i; vdev->scsi_device = &default_scsi_device;virtio_scsi_locate_device (vdev);
@@ -363,6 +366,20 @@ void virtio_scsi_setup(VDev *vdev) vdev->scsi_block_size =VIRTIO_ISO_BLOCK_SIZE ; } +if (!scsi_inquiry (vdev, +SCSI_INQUIRY_EVPD , +SCSI_INQUIRY_EVPD_SUPPORTED_PAGES , + evpd, +sizeof (*evpd))) { +virtio_scsi_verify_response (&resp,"virtio-scsi:setup:supported_pages" ); + } + +debug_print_int ("EVPD length" , evpd->page_length); + +for (i =0 ; i <= evpd->page_length; i++) { +debug_print_int ("supported EVPD page" , evpd->byte[i]); + } +if (!scsi_read_capacity (vdev, data, data_size)) {virtio_scsi_verify_response (&resp,"virtio-scsi:setup:read_capacity" ); }
Signature · 1 line
2.10.2
RFC PATCH v2 7/8 pc-bios/s390-ccw: Build a reasonable max_sectors limit
In reply to Eric FarmanNow that we've read all the possible limits that have been defined for a virtio-scsi controller and the disk we're booting from, it's possible that we are STILL going to exceed the limits of the host device. For example, a "-device scsi-generic" device does not support the Block Limits VPD page.
So, let's fallback to something that seems to work for most boot configurations if larger values were specified (including if nothing was explicitly specified, and we took default values).
--- pc-bios/s390-ccw/virtio-scsi.c | 9 +++++++++ pc-bios/s390-ccw/virtio-scsi.h | 2 ++ 2 files changed, 11 insertions(+)
pc-bios/s390-ccw/virtio-scsi.c +9 -0
@@ -399,6 +399,15 @@ void virtio_scsi_setup(VDev *vdev) vdev->max_transfer = evpd_bl->max_transfer; } +/* +* The host sg driver will often be unhappy with particularly large +* I/Os that exceed the block iovec limits. Let's enforce something +* reasonable, despite what the device configuration tells us. +*/ + + vdev->max_transfer =MIN_NON_ZERO (VIRTIO_SCSI_MAX_SECTORS , + vdev->max_transfer); +if (!scsi_read_capacity (vdev, data, data_size)) {virtio_scsi_verify_response (&resp,"virtio-scsi:setup:read_capacity" ); }
pc-bios/s390-ccw/virtio-scsi.h +2 -0
@@ -19,6 +19,8 @@#define VIRTIO_SCSI_CDB_SIZE SCSI_DEFAULT_CDB_SIZE#define VIRTIO_SCSI_SENSE_SIZE SCSI_DEFAULT_SENSE_SIZE +#define VIRTIO_SCSI_MAX_SECTORS 2048 +/* command-specific response values */ #define VIRTIO_SCSI_S_OK 0x00#define VIRTIO_SCSI_S_BAD_TARGET 0x03
Signature · 1 line
2.10.2
RFC PATCH v2 8/8 pc-bios/s390-ccw.img: rebuild image
In reply to Eric FarmanContains the following commits:
- pc-bios/s390-ccw: Remove duplicate blk_factor adjustment
- pc-bios/s390-ccw: Move SCSI block factor to outer read
- pc-bios/s390-ccw: Break up virtio-scsi read into multiples
- pc-bios/s390-ccw: Refactor scsi_inquiry function
- pc-bios/s390-ccw: Get list of supported EVPD pages
- pc-bios/s390-ccw: Get Block Limits VPD device data
- pc-bios/s390-ccw: Build a reasonable max_sectors limit
--- pc-bios/s390-ccw.img | Bin 26472 -> 26480 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
2.10.2
Quoted 46 lines · On Wed, 10 May 2017 17:53:51 +0200 Eric Farman <[email protected]>…
Today, trying to boot a guest from a SCSI LUN on s390x yields the following:
virtio-blk = OK
virtio-scsi and/dev/sdX= OK
virtio-scsi and/dev/sgX= FAILExample of the failing scenario:
/usr/bin/qemu-system-s390x...-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001 -drive file=/dev/sg2,if=none,id=drive0,format=raw -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,drive=drive0,id=disk0LOADPARM=[........]
Using virtio-scsi.
Using SCSI scheme.
..
! virtio-scsi:read_many: STATUS=02 RSPN=70 KEY=0b CODE=00 QLFR=06, sure !Why do we care? Well, libvirt converts a virtio-scsi device from the host SCSI address (host:bus:target:lun) into the associated
/dev/sgXdevice, which means we can't boot from virtio-scsi and have to rely on virtio-blk for this action.The short version of what happens is the host block device driver rejects our requests because the transfer lengths are too long for it to satisfy. A virtio-scsi disk connected via scsi-generic is fine as a non-boot device because the guest kernel is able to break up the requests for us. So we just need to handle this situation for the boot process.
Patches 1-3 read the
max_sectorsparameter for the virtio-scsi controller, and break up the READ(10) I/Os into something that the host will accept. If not specified,max_sectorsdefaults to 65535, but could look like this:qemu-system-s390x ...
-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001,max_sectors=2048Patches 4-6 read the
max_io_sizeparameter for the virtio-scsi disk device, and use the minimum of it and themax_sectorsfrom the controller for breaking up the READ(10) I/Os. If not specified,max_io_sizedefaults to 2147483647 but could look like this:qemu-system-s390x ...
-drive file=/dev/sda,if=none,id=drive0,format=raw ... -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0, drive=drive0,id=disk0,max_io_size=1048576
Quoted 8 lines
In the two examples above, the maximum parameters are equivalent due to the controller parameter measuring 512-byte blocks, and the disk measuring bytes.
Patch 7 establishes a workable default, in case neither the controller nor the disk have the parameters specified (and thus the overly large defaults are taken), or if they are set to something beyond what we can boot from.
Patch 8 rebuilds the s390-ccw BIOS with this entire patch set.
This patch set looks reasonable to me, but I have not delved into the scsi particulars :)
The code changes seem to be fine, so if someone with more scsi knowledge than me could give their ok as well, I'll be happy to take this through my s390 tree.
Quoted 76 lines · Eric Farman
Today, trying to boot a guest from a SCSI LUN on s390x yields the following:
virtio-blk = OK
virtio-scsi and/dev/sdX= OK
virtio-scsi and/dev/sgX= FAILExample of the failing scenario:
/usr/bin/qemu-system-s390x...-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001 -drive file=/dev/sg2,if=none,id=drive0,format=raw -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,drive=drive0,id=disk0LOADPARM=[........]
Using virtio-scsi.
Using SCSI scheme.
..
! virtio-scsi:read_many: STATUS=02 RSPN=70 KEY=0b CODE=00 QLFR=06, sure !Why do we care? Well, libvirt converts a virtio-scsi device from the host SCSI address (host:bus:target:lun) into the associated
/dev/sgXdevice, which means we can't boot from virtio-scsi and have to rely on virtio-blk for this action.The short version of what happens is the host block device driver rejects our requests because the transfer lengths are too long for it to satisfy. A virtio-scsi disk connected via scsi-generic is fine as a non-boot device because the guest kernel is able to break up the requests for us. So we just need to handle this situation for the boot process.
Patches 1-3 read the
max_sectorsparameter for the virtio-scsi controller, and break up the READ(10) I/Os into something that the host will accept. If not specified,max_sectorsdefaults to 65535, but could look like this:qemu-system-s390x ...
-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001,max_sectors=2048Patches 4-6 read the
max_io_sizeparameter for the virtio-scsi disk device, and use the minimum of it and themax_sectorsfrom the controller for breaking up the READ(10) I/Os. If not specified,max_io_sizedefaults to 2147483647 but could look like this:qemu-system-s390x ...
-drive file=/dev/sda,if=none,id=drive0,format=raw ... -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0, drive=drive0,id=disk0,max_io_size=1048576In the two examples above, the maximum parameters are equivalent due to the controller parameter measuring 512-byte blocks, and the disk measuring bytes.
Patch 7 establishes a workable default, in case neither the controller nor the disk have the parameters specified (and thus the overly large defaults are taken), or if they are set to something beyond what we can boot from.
Patch 8 rebuilds the s390-ccw BIOS with this entire patch set.
Changelog:
RFC v2:
- Dropped patch outside the pc-bios/s390-ccw/ tree
- Added Christian's r-b to patch 1 (formerly patch 2)
- Added EVPD Inquiry calls to retrieve Block Limits page if supported
- Added a default if Block Limits page is not supported, or response is still way to big to allow boot
RFC v1:
- https://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg05121.htmlEric Farman (8):
pc-bios/s390-ccw: Remove duplicateblk_factoradjustment pc-bios/s390-ccw: Move SCSI block factor to outer read pc-bios/s390-ccw: Break up virtio-scsi read into multiples pc-bios/s390-ccw: Refactorscsi_inquiryfunction pc-bios/s390-ccw: Get list of supported VPD pages pc-bios/s390-ccw: Get Block Limits VPD device data pc-bios/s390-ccw: Build a reasonablemax_sectorslimit pc-bios/s390-ccw.img: rebuild image
Quoted 8 lines
pc-bios/s390-ccw.img | Bin 26472 -> 26480 bytes pc-bios/s390-ccw/s390-ccw.h | 7 ++++ pc-bios/s390-ccw/scsi.h | 30 +++++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 85 +++++++++++++++++++++++++++++++++++------ pc-bios/s390-ccw/virtio-scsi.h | 2 + pc-bios/s390-ccw/virtio.h | 1 + 6 files changed, 114 insertions(+), 11 deletions(-)
Patch set looks good. Conny, can you apply the series?
Quoted 86 lines · On Tue, 16 May 2017 15:44:43 +0200 Christian Borntraeger…
Quoted 76 lines · Eric Farman
Today, trying to boot a guest from a SCSI LUN on s390x yields the following:
virtio-blk = OK
virtio-scsi and/dev/sdX= OK
virtio-scsi and/dev/sgX= FAILExample of the failing scenario:
/usr/bin/qemu-system-s390x...-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001 -drive file=/dev/sg2,if=none,id=drive0,format=raw -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,drive=drive0,id=disk0LOADPARM=[........]
Using virtio-scsi.
Using SCSI scheme.
..
! virtio-scsi:read_many: STATUS=02 RSPN=70 KEY=0b CODE=00 QLFR=06, sure !Why do we care? Well, libvirt converts a virtio-scsi device from the host SCSI address (host:bus:target:lun) into the associated
/dev/sgXdevice, which means we can't boot from virtio-scsi and have to rely on virtio-blk for this action.The short version of what happens is the host block device driver rejects our requests because the transfer lengths are too long for it to satisfy. A virtio-scsi disk connected via scsi-generic is fine as a non-boot device because the guest kernel is able to break up the requests for us. So we just need to handle this situation for the boot process.
Patches 1-3 read the
max_sectorsparameter for the virtio-scsi controller, and break up the READ(10) I/Os into something that the host will accept. If not specified,max_sectorsdefaults to 65535, but could look like this:qemu-system-s390x ...
-device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001,max_sectors=2048Patches 4-6 read the
max_io_sizeparameter for the virtio-scsi disk device, and use the minimum of it and themax_sectorsfrom the controller for breaking up the READ(10) I/Os. If not specified,max_io_sizedefaults to 2147483647 but could look like this:qemu-system-s390x ...
-drive file=/dev/sda,if=none,id=drive0,format=raw ... -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0, drive=drive0,id=disk0,max_io_size=1048576In the two examples above, the maximum parameters are equivalent due to the controller parameter measuring 512-byte blocks, and the disk measuring bytes.
Patch 7 establishes a workable default, in case neither the controller nor the disk have the parameters specified (and thus the overly large defaults are taken), or if they are set to something beyond what we can boot from.
Patch 8 rebuilds the s390-ccw BIOS with this entire patch set.
Changelog:
RFC v2:
- Dropped patch outside the pc-bios/s390-ccw/ tree
- Added Christian's r-b to patch 1 (formerly patch 2)
- Added EVPD Inquiry calls to retrieve Block Limits page if supported
- Added a default if Block Limits page is not supported, or response is still way to big to allow boot
RFC v1:
- https://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg05121.htmlEric Farman (8):
pc-bios/s390-ccw: Remove duplicateblk_factoradjustment pc-bios/s390-ccw: Move SCSI block factor to outer read pc-bios/s390-ccw: Break up virtio-scsi read into multiples pc-bios/s390-ccw: Refactorscsi_inquiryfunction pc-bios/s390-ccw: Get list of supported VPD pages pc-bios/s390-ccw: Get Block Limits VPD device data pc-bios/s390-ccw: Build a reasonablemax_sectorslimit pc-bios/s390-ccw.img: rebuild imageQuoted 8 lines
pc-bios/s390-ccw.img | Bin 26472 -> 26480 bytes pc-bios/s390-ccw/s390-ccw.h | 7 ++++ pc-bios/s390-ccw/scsi.h | 30 +++++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 85 +++++++++++++++++++++++++++++++++++------ pc-bios/s390-ccw/virtio-scsi.h | 2 + pc-bios/s390-ccw/virtio.h | 1 + 6 files changed, 114 insertions(+), 11 deletions(-)
Quoted 2 lines
Patch set looks good. Conny, can you apply the series?
I had hoped for some comments from folks more familiar with scsi...
Nevertheless, applied to s390-next.