[Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX

Eric Farman posted 5 patches 6 years, 12 months ago
Only 4 patches received!
hw/scsi/virtio-scsi.c          |  12 ++++++++++++
pc-bios/s390-ccw.img           | Bin 26456 -> 26456 bytes
pc-bios/s390-ccw/s390-ccw.h    |   4 ++++
pc-bios/s390-ccw/virtio-scsi.c |  29 ++++++++++++++++++++---------
4 files changed, 36 insertions(+), 9 deletions(-)
[Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Eric Farman 6 years, 12 months ago
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 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 2-N in this series do that, but rely on us to specify the max_sectors
parameter for the virtio-scsi-ccw device:

  /usr/bin/qemu-system-s390x ...
    -device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001,max_sectors=2048

Without this, the default of xFFFF is used and we still end up exceeding
the limit in the host drivers.  Which is why we have Patch 1, and thus the
"RFC" tag on this series.  The backing block device has a maximum transfer
value calculated with the help of the BLKSECTGET ioctl[1][2].

With patch 1 applied, we are able to go through the children devices and
apply any known limit received from this IOCTL, and thus break up our requests
before submitting them to the host.  It is admittedly a little coarse, since
the max_sectors value is associated with the virtio-scsi controller and
multiple devices can be attached to it, not all of which are associated
with our boot device.  Meanwhile, each attached device can have its own
maximum transfer from the backing device.

[1] http://git.qemu-project.org/?p=qemu.git;a=commitdiff;h=482652502e98b1d570de0585f01dd55e35fdebfb
[2] http://git.qemu-project.org/?p=qemu.git;a=commitdiff;h=c4c41a0a65d650b241dec9efedf4ee3f00a16a30

Eric Farman (5):
  hw/scsi: Override the max_sectors value for virtio-scsi
  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.img: rebuild image

 hw/scsi/virtio-scsi.c          |  12 ++++++++++++
 pc-bios/s390-ccw.img           | Bin 26456 -> 26456 bytes
 pc-bios/s390-ccw/s390-ccw.h    |   4 ++++
 pc-bios/s390-ccw/virtio-scsi.c |  29 ++++++++++++++++++++---------
 4 files changed, 36 insertions(+), 9 deletions(-)

-- 
2.10.2


[Qemu-devel] [RFC PATCH v1 5/5] pc-bios/s390-ccw.img: rebuild image
Posted by Eric Farman 6 years, 12 months ago
Contains 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

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
---
 pc-bios/s390-ccw.img | Bin 26456 -> 26456 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/pc-bios/s390-ccw.img b/pc-bios/s390-ccw.img
index 2a4adfa654844040dbc84e90a9c2e0af56fdb9fa..0451d319e691544ded585846cfcb8f1799b3fbf5 100644
GIT binary patch
delta 4701
zcmZu#3sjWV7CvWYm<J3nFb`%15V(RuqC8a;6mXH54;Ty-6N`N0Gs7f%N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F4|nQ*a4p{
zoVV4Yy)NN50RANQa*o871~70>GHZ{ZqZS<5LC`*FU}#MyzFLLo!4rlS8>-2K!Pyb4
z5wfyTWJ4!qdLW8Kdlp4DSd~3cuE~Qv*|FNKI0^H>=?I4I>?m!cs06)@aXiDWL8T*&
zIibmsBp<ay(BvffOFLvu9xtDepknfqBbQ>vNe{9MgWd4LI-ROQyk8o>S}&IwPGtH%
zQeY3n3h-n?P);;k38^{#<kOjupYtRuhAla<ajhuzek7;vYZ5uH$9_oxz5JL+gELs~
z0nL<X)(V5C3@tr_clXakICf1f=VwH*GI|9IKi1)l=>0GK?dZpnNZWp{*WzrQ9s3J?
zJ}$2?^cUk?<w<a1%F{|AN({Y12cx6{SME&6%8g}5V0rFP`J4@Q<fgH$(4HF`w;#o`
zdIezL#8NyjiqPAi*t0ax=Rwxg5g1!Gb*Qd!7!IU>X6xkC#Ly-&&XQiaut@p>T*g}=
zY+AH-CGNt*w1V=djnLjjT@i)uoR+A&X2sV|@fws7Q0^tSo;rEr_?O3y9{J*MfRjnp
zrs*wuD4t#jYi8>=cR#C>N42h-Gt`jg#4vo)oRB;x$<XWnI7{b@@Dbg?XHsVM{y9$e
EKL#z#%m4rY

-- 
2.10.2


Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Christian Borntraeger 6 years, 12 months ago
On 04/26/2017 04:46 PM, Eric Farman wrote:
> 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 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.

Out of curiosity. Why is the guest kernel submitting "short enough" requests?
If it querying the device itself via scsi commands before issuing commands?


Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Eric Farman 6 years, 12 months ago

On 04/26/2017 11:48 AM, Christian Borntraeger wrote:
> On 04/26/2017 04:46 PM, Eric Farman wrote:
>> 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 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.
>
> Out of curiosity. Why is the guest kernel submitting "short enough" requests?
> If it querying the device itself via scsi commands before issuing commands?
>

Looking at some old traces I have, I think I misspoke that it's the 
guest kernel.  In the failing case, the host kernel is processing an 
ioctl system call via sg_ioctl, and just passing our I/O transaction to 
the block driver.  It blows up because the number of iovecs needed for 
the transaction exceeds UIO_MAXIOV.  In the working case (boot from 
virtio-scsi as /dev/sdX or virtio-blk), the host kernel goes through 
read system call, and the I/O is broken up by do_generic_file_read.


Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Fam Zheng 6 years, 11 months ago
On Wed, 04/26 16:46, Eric Farman wrote:
> The short version of what happens is the host 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 2-N in this series do that, but rely on us to specify the max_sectors
> parameter for the virtio-scsi-ccw device:
> 
>   /usr/bin/qemu-system-s390x ...
>     -device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001,max_sectors=2048

Can you instead do an INQUIRY from the bios code to check the Block Limits page?
The response is intercepted by hw/scsi/scsi-generic.c to merge in the host LUN's
limits. That's how Linux kernel finds the granularity for request splitting.

That way, patch 1 is not necessary too. I don't like it because it doesn't
always work considering LUN hotplug.

Fam

Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Eric Farman 6 years, 11 months ago

On 05/05/2017 03:41 AM, Fam Zheng wrote:
> On Wed, 04/26 16:46, Eric Farman wrote:
>> The short version of what happens is the host 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 2-N in this series do that, but rely on us to specify the max_sectors
>> parameter for the virtio-scsi-ccw device:
>>
>>   /usr/bin/qemu-system-s390x ...
>>     -device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001,max_sectors=2048
>
> Can you instead do an INQUIRY from the bios code to check the Block Limits page?
> The response is intercepted by hw/scsi/scsi-generic.c to merge in the host LUN's
> limits. That's how Linux kernel finds the granularity for request splitting.

It's a good idea (Thanks Christian, Paolo, and Fam :), but this leads to 
other difficulties.

We get a value of x3fffff when sending that to a scsi-disk from bios 
code.  That's fully emulated though, in scsi_disk_emulate_inquiry.  And 
that's the scenario that already works.

While there is indeed code in hw/scsi/scsi-generic.c to wire that in, 
that only happens after the I/O goes to the device itself.  The Block 
Limits page isn't supported [1] and thus it gets rejected with "invalid 
field in cdb".  We never get to that fixup code you reference, since the 
returned len is zero.

Should I be refactoring this code to always patch in that block limit 
regardless of a response from the host/device?  (That is, when page xb0 
isn't supported by the hw.)

  - Eric

[1] If I issue an EVPD page x00 from the QEMU bios code, I only see 
pages xb1, xc0, and c1 are supported.  If I look at the supported pages 
from the host, I see a few more but still not xb0:

$ sg_inq --page=0 /dev/sda
VPD INQUIRY: Supported VPD pages page
    Supported VPD pages:
      0x0	Supported VPD pages
      0x80	Unit serial number
      0x83	Device identification
      0x86	Extended INQUIRY data
      0xb1	Block device characteristics (sbc3)
      0xc0	vendor: Firmware numbers (seagate); Unit path report (EMC)
      0xc1	vendor: Date code (seagate)
$ sg_inq --page=0 /dev/sg0
VPD INQUIRY: Supported VPD pages page
    Supported VPD pages:
      0x0	Supported VPD pages
      0x80	Unit serial number
      0x83	Device identification
      0x86	Extended INQUIRY data
      0xb1	Block device characteristics (sbc3)
      0xc0	vendor: Firmware numbers (seagate); Unit path report (EMC)
      0xc1	vendor: Date code (seagate)


>
> That way, patch 1 is not necessary too. I don't like it because it doesn't
> always work considering LUN hotplug.
>
> Fam
>


Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Paolo Bonzini 6 years, 11 months ago

On 05/05/2017 17:03, Eric Farman wrote:
> We get a value of x3fffff when sending that to a scsi-disk from bios
> code.  That's fully emulated though, in scsi_disk_emulate_inquiry.  And
> that's the scenario that already works.
> 
> While there is indeed code in hw/scsi/scsi-generic.c to wire that in,
> that only happens after the I/O goes to the device itself.  The Block
> Limits page isn't supported [1] and thus it gets rejected with "invalid
> field in cdb".  We never get to that fixup code you reference, since the
> returned len is zero.
> 
> Should I be refactoring this code to always patch in that block limit
> regardless of a response from the host/device?  (That is, when page xb0
> isn't supported by the hw.)

What is the BLKSECTGET value you get?  Is there a sensible default value
that you can use when page 0xb0 isn't supported by the hardware?

Thanks,

Paolo

Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Eric Farman 6 years, 11 months ago

On 05/05/2017 11:13 AM, Paolo Bonzini wrote:
>
>
> On 05/05/2017 17:03, Eric Farman wrote:
>> We get a value of x3fffff when sending that to a scsi-disk from bios
>> code.  That's fully emulated though, in scsi_disk_emulate_inquiry.  And
>> that's the scenario that already works.
>>
>> While there is indeed code in hw/scsi/scsi-generic.c to wire that in,
>> that only happens after the I/O goes to the device itself.  The Block
>> Limits page isn't supported [1] and thus it gets rejected with "invalid
>> field in cdb".  We never get to that fixup code you reference, since the
>> returned len is zero.
>>
>> Should I be refactoring this code to always patch in that block limit
>> regardless of a response from the host/device?  (That is, when page xb0
>> isn't supported by the hw.)
>
> What is the BLKSECTGET value you get?

x140000 bytes when using /dev/sg0 (xa00 sectors when using /dev/sda).

>  Is there a sensible default value
> that you can use when page 0xb0 isn't supported by the hardware?

I was setting max_sectors to x800 with good success, which was the 
power-of-2 floor that BLKSECTGET gave us.  That kept us within the 
limits of the host biovec code.  But it's a long way from the 
virtio-scsi value of xFFFF when max_sectors isn't specified, so don't 
know what side effects that may cause.

>
> Thanks,
>
> Paolo
>


Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Paolo Bonzini 6 years, 11 months ago

On 05/05/2017 18:12, Eric Farman wrote:
> 
> 
> On 05/05/2017 11:13 AM, Paolo Bonzini wrote:
>>
>>
>> On 05/05/2017 17:03, Eric Farman wrote:
>>> We get a value of x3fffff when sending that to a scsi-disk from bios
>>> code.  That's fully emulated though, in scsi_disk_emulate_inquiry.  And
>>> that's the scenario that already works.
>>>
>>> While there is indeed code in hw/scsi/scsi-generic.c to wire that in,
>>> that only happens after the I/O goes to the device itself.  The Block
>>> Limits page isn't supported [1] and thus it gets rejected with "invalid
>>> field in cdb".  We never get to that fixup code you reference, since the
>>> returned len is zero.
>>>
>>> Should I be refactoring this code to always patch in that block limit
>>> regardless of a response from the host/device?  (That is, when page xb0
>>> isn't supported by the hw.)
>>
>> What is the BLKSECTGET value you get?
> 
> x140000 bytes when using /dev/sg0 (xa00 sectors when using /dev/sda).
> 
>>  Is there a sensible default value
>> that you can use when page 0xb0 isn't supported by the hardware?
> 
> I was setting max_sectors to x800 with good success, which was the
> power-of-2 floor that BLKSECTGET gave us.  That kept us within the
> limits of the host biovec code.  But it's a long way from the
> virtio-scsi value of xFFFF when max_sectors isn't specified, so don't
> know what side effects that may cause.

It's just slower, but 0x800 is already a megabyte worth of data so it's
not going to be that much slower.

Paolo

Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Christian Borntraeger 6 years, 11 months ago
On 05/06/2017 10:24 AM, Paolo Bonzini wrote:
> 
> 
> On 05/05/2017 18:12, Eric Farman wrote:
>>
>>
>> On 05/05/2017 11:13 AM, Paolo Bonzini wrote:
>>>
>>>
>>> On 05/05/2017 17:03, Eric Farman wrote:
>>>> We get a value of x3fffff when sending that to a scsi-disk from bios
>>>> code.  That's fully emulated though, in scsi_disk_emulate_inquiry.  And
>>>> that's the scenario that already works.
>>>>
>>>> While there is indeed code in hw/scsi/scsi-generic.c to wire that in,
>>>> that only happens after the I/O goes to the device itself.  The Block
>>>> Limits page isn't supported [1] and thus it gets rejected with "invalid
>>>> field in cdb".  We never get to that fixup code you reference, since the
>>>> returned len is zero.
>>>>
>>>> Should I be refactoring this code to always patch in that block limit
>>>> regardless of a response from the host/device?  (That is, when page xb0
>>>> isn't supported by the hw.)
>>>
>>> What is thec value you get?
>>
>> x140000 bytes when using /dev/sg0 (xa00 sectors when using /dev/sda).
>>
>>>  Is there a sensible default value
>>> that you can use when page 0xb0 isn't supported by the hardware?
>>
>> I was setting max_sectors to x800 with good success, which was the
>> power-of-2 floor that BLKSECTGET gave us.  That kept us within the
>> limits of the host biovec code.  But it's a long way from the
>> virtio-scsi value of xFFFF when max_sectors isn't specified, so don't
>> know what side effects that may cause.
> 
> It's just slower, but 0x800 is already a megabyte worth of data so it's
> not going to be that much slower.
> 
> Paolo
> 

Eric, maybe that would be a safe variant. The bios boot code is not
performance optimized anyway. Lets just always use a maximum size that 
will always work.


Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
Posted by Eric Farman 6 years, 11 months ago

On 05/08/2017 03:00 AM, Christian Borntraeger wrote:
> On 05/06/2017 10:24 AM, Paolo Bonzini wrote:
>>
>>
>> On 05/05/2017 18:12, Eric Farman wrote:
>>>
>>>
>>> On 05/05/2017 11:13 AM, Paolo Bonzini wrote:
>>>>
>>>>
>>>> On 05/05/2017 17:03, Eric Farman wrote:
>>>>> We get a value of x3fffff when sending that to a scsi-disk from bios
>>>>> code.  That's fully emulated though, in scsi_disk_emulate_inquiry.  And
>>>>> that's the scenario that already works.
>>>>>
>>>>> While there is indeed code in hw/scsi/scsi-generic.c to wire that in,
>>>>> that only happens after the I/O goes to the device itself.  The Block
>>>>> Limits page isn't supported [1] and thus it gets rejected with "invalid
>>>>> field in cdb".  We never get to that fixup code you reference, since the
>>>>> returned len is zero.
>>>>>
>>>>> Should I be refactoring this code to always patch in that block limit
>>>>> regardless of a response from the host/device?  (That is, when page xb0
>>>>> isn't supported by the hw.)
>>>>
>>>> What is thec value you get?
>>>
>>> x140000 bytes when using /dev/sg0 (xa00 sectors when using /dev/sda).
>>>
>>>>  Is there a sensible default value
>>>> that you can use when page 0xb0 isn't supported by the hardware?
>>>
>>> I was setting max_sectors to x800 with good success, which was the
>>> power-of-2 floor that BLKSECTGET gave us.  That kept us within the
>>> limits of the host biovec code.  But it's a long way from the
>>> virtio-scsi value of xFFFF when max_sectors isn't specified, so don't
>>> know what side effects that may cause.
>>
>> It's just slower, but 0x800 is already a megabyte worth of data so it's
>> not going to be that much slower.
>>
>> Paolo
>>
>
> Eric, maybe that would be a safe variant. The bios boot code is not
> performance optimized anyway. Lets just always use a maximum size that
> will always work.
>

Sounds good to me.  Let me work on getting my very ugly code to be 
slightly less ugly, and I'll send a v2 here.  Thanks, everyone.

  - Eric