All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
@ 2017-04-26 14:46 Eric Farman
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi Eric Farman
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Eric Farman @ 2017-04-26 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck,
	Christian Borntraeger, Alexander Graf, 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 = 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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi
  2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
@ 2017-04-26 14:46 ` Eric Farman
  2017-05-05  7:39   ` Paolo Bonzini
  2017-05-05  7:50   ` Christian Borntraeger
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 2/5] pc-bios/s390-ccw: Remove duplicate blk_factor adjustment Eric Farman
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Eric Farman @ 2017-04-26 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck,
	Christian Borntraeger, Alexander Graf, Eric Farman

The virtio spec states that the max_sectors field is
"a hint to the driver for the maximum transfer size"
that would be used for a virtio-scsi request.

It's currently hardcoded to xFFFF unless one is established
by the max_sectors parameter on the command line, but let's
roll through the associated devices and set it to anything
lower if one is set for the underlying block device and
retrieved by the BLKSECTGET ioctl.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
---
 hw/scsi/virtio-scsi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 46a3e3f..bca9461 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -640,7 +640,11 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
                                    uint8_t *config)
 {
     VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
+    VirtIOSCSI *vs = VIRTIO_SCSI(vdev);
     VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(vdev);
+    SCSIDevice *d;
+    BusChild *kid;
+    unsigned int max_transfer;
 
     virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues);
     virtio_stl_p(vdev, &scsiconf->seg_max, 128 - 2);
@@ -652,6 +656,14 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
     virtio_stw_p(vdev, &scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL);
     virtio_stw_p(vdev, &scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET);
     virtio_stl_p(vdev, &scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN);
+
+    QTAILQ_FOREACH(kid, &vs->bus.qbus.children, sibling) {
+        d = SCSI_DEVICE(kid->child);
+        max_transfer = blk_get_max_transfer(d->conf.blk) / d->blocksize;
+        virtio_stl_p(vdev,
+                     &scsiconf->max_sectors,
+                     MIN_NON_ZERO(max_transfer, scsiconf->max_sectors));
+    }
 }
 
 static void virtio_scsi_set_config(VirtIODevice *vdev,
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [RFC PATCH v1 2/5] pc-bios/s390-ccw: Remove duplicate blk_factor adjustment
  2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi Eric Farman
@ 2017-04-26 14:46 ` Eric Farman
  2017-05-05  7:10   ` Christian Borntraeger
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 3/5] pc-bios/s390-ccw: Move SCSI block factor to outer read Eric Farman
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Eric Farman @ 2017-04-26 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck,
	Christian Borntraeger, Alexander Graf, Eric Farman

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.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
---
 pc-bios/s390-ccw/virtio-scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
index d850a8d..69b7a93 100644
--- a/pc-bios/s390-ccw/virtio-scsi.c
+++ b/pc-bios/s390-ccw/virtio-scsi.c
@@ -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);
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [RFC PATCH v1 3/5] pc-bios/s390-ccw: Move SCSI block factor to outer read
  2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi Eric Farman
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 2/5] pc-bios/s390-ccw: Remove duplicate blk_factor adjustment Eric Farman
@ 2017-04-26 14:46 ` Eric Farman
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples Eric Farman
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 22+ messages in thread
From: Eric Farman @ 2017-04-26 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck,
	Christian Borntraeger, Alexander Graf, Eric Farman

Simple refactoring so that the blk_factor adjustment is
moved into virtio_scsi_read_many routine, in preparation
for another change.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
---
 pc-bios/s390-ccw/virtio-scsi.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
index 69b7a93..6d070e2 100644
--- a/pc-bios/s390-ccw/virtio-scsi.c
+++ b/pc-bios/s390-ccw/virtio-scsi.c
@@ -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");
     }
 
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples
  2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
                   ` (2 preceding siblings ...)
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 3/5] pc-bios/s390-ccw: Move SCSI block factor to outer read Eric Farman
@ 2017-04-26 14:46 ` Eric Farman
  2017-04-26 15:17   ` Eric Blake
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 5/5] pc-bios/s390-ccw.img: rebuild image Eric Farman
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Eric Farman @ 2017-04-26 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck,
	Christian Borntraeger, Alexander Graf, Eric Farman

A 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 from the device and break up
all virtio-scsi requests (both sd and sg) to avoid problem from
the host drivers.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
---
 pc-bios/s390-ccw/s390-ccw.h    |  4 ++++
 pc-bios/s390-ccw/virtio-scsi.c | 19 ++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
index ded67bc..e1f3751 100644
--- a/pc-bios/s390-ccw/s390-ccw.h
+++ b/pc-bios/s390-ccw/s390-ccw.h
@@ -42,6 +42,10 @@ typedef unsigned long long __u64;
 #ifndef NULL
 #define NULL    0
 #endif
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b));
+#endif
+
 
 #include "cio.h"
 #include "iplb.h"
diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
index 6d070e2..90a8cc8 100644
--- a/pc-bios/s390-ccw/virtio-scsi.c
+++ b/pc-bios/s390-ccw/virtio-scsi.c
@@ -254,12 +254,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(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;
 }
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [RFC PATCH v1 5/5] pc-bios/s390-ccw.img: rebuild image
  2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
                   ` (3 preceding siblings ...)
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples Eric Farman
@ 2017-04-26 14:46 ` Eric Farman
  2017-04-26 15:48 ` [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Christian Borntraeger
  2017-05-05  7:41 ` Fam Zheng
  6 siblings, 0 replies; 22+ messages in thread
From: Eric Farman @ 2017-04-26 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck,
	Christian Borntraeger, Alexander Graf, Eric Farman

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%NDI4pOUnnb
z)vUb5O>??tg<=LpIo+#eYBnh#_(%#Qu9*Fkpmsz4yU#|*<+}e`%>MqpzrD{s`|NZ6
zvuHZWn@;lbM(>#gjGmbVueN*<I4!yF?N13+{5{hnRfcyq=@-p()oim5?H;Dh8vS){
z^)kgw1@DH#s`a*&u1k#hcDuqE3w@mMuL6f}gh#zT;;CR!Pvh5NzB(f6u&}Z(g*D`R
zVm?5)gYYzg!#b<?s1I{Rm=21y;UOV`tp)>Qs?LiZEmLVcogYaK7U^;$@fp~wE#u=L
zRu>g>q(SM?8kln}Gl?L<i$y@6PQsrOz9jIV7vNdl6x*TJ@FI-aT2*9as#7DRW&?8-
zqt|ixLANr<L;RJQ;Zif9<>aY{Mc&=Er9$KVi_qBJgnt$|^lz}r=RvzYfmGFG-b?rc
zGEafaKGD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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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples Eric Farman
@ 2017-04-26 15:17   ` Eric Blake
  2017-04-26 15:24     ` Eric Farman
  2017-04-26 15:47     ` Cornelia Huck
  0 siblings, 2 replies; 22+ messages in thread
From: Eric Blake @ 2017-04-26 15:17 UTC (permalink / raw)
  To: Eric Farman, qemu-devel
  Cc: Michael S . Tsirkin, Alexander Graf, Christian Borntraeger,
	Cornelia Huck, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]

On 04/26/2017 09:46 AM, Eric Farman wrote:
> A 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 from the device and break up
> all virtio-scsi requests (both sd and sg) to avoid problem from
> the host drivers.
> 
> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
> ---
>  pc-bios/s390-ccw/s390-ccw.h    |  4 ++++
>  pc-bios/s390-ccw/virtio-scsi.c | 19 ++++++++++++++-----
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
> index ded67bc..e1f3751 100644
> --- a/pc-bios/s390-ccw/s390-ccw.h
> +++ b/pc-bios/s390-ccw/s390-ccw.h
> @@ -42,6 +42,10 @@ typedef unsigned long long __u64;
>  #ifndef NULL
>  #define NULL    0
>  #endif
> +#ifndef MIN
> +#define MIN(a, b) (((a) < (b)) ? (a) : (b));
> +#endif

osdep.h defines MIN() for ALL files, so this hunk is spurious.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples
  2017-04-26 15:17   ` Eric Blake
@ 2017-04-26 15:24     ` Eric Farman
  2017-04-26 16:00       ` Eric Farman
  2017-04-26 15:47     ` Cornelia Huck
  1 sibling, 1 reply; 22+ messages in thread
From: Eric Farman @ 2017-04-26 15:24 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: Cornelia Huck, Christian Borntraeger, Paolo Bonzini,
	Alexander Graf, Michael S . Tsirkin



On 04/26/2017 11:17 AM, Eric Blake wrote:
> On 04/26/2017 09:46 AM, Eric Farman wrote:
>> A 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 from the device and break up
>> all virtio-scsi requests (both sd and sg) to avoid problem from
>> the host drivers.
>>
>> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
>> ---
>>  pc-bios/s390-ccw/s390-ccw.h    |  4 ++++
>>  pc-bios/s390-ccw/virtio-scsi.c | 19 ++++++++++++++-----
>>  2 files changed, 18 insertions(+), 5 deletions(-)
>>
>> diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
>> index ded67bc..e1f3751 100644
>> --- a/pc-bios/s390-ccw/s390-ccw.h
>> +++ b/pc-bios/s390-ccw/s390-ccw.h
>> @@ -42,6 +42,10 @@ typedef unsigned long long __u64;
>>  #ifndef NULL
>>  #define NULL    0
>>  #endif
>> +#ifndef MIN
>> +#define MIN(a, b) (((a) < (b)) ? (a) : (b));
>> +#endif
>
> osdep.h defines MIN() for ALL files, so this hunk is spurious.

Ah, so it does.  Okay, removed.  Thanks!

I guess it would make sense for the hunk that uses it to use 
MIN_NON_ZERO instead, which is also defined there.

>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples
  2017-04-26 15:17   ` Eric Blake
  2017-04-26 15:24     ` Eric Farman
@ 2017-04-26 15:47     ` Cornelia Huck
  1 sibling, 0 replies; 22+ messages in thread
From: Cornelia Huck @ 2017-04-26 15:47 UTC (permalink / raw)
  To: Eric Blake
  Cc: Eric Farman, qemu-devel, Michael S . Tsirkin, Alexander Graf,
	Christian Borntraeger, Paolo Bonzini

On Wed, 26 Apr 2017 10:17:36 -0500
Eric Blake <eblake@redhat.com> wrote:

> On 04/26/2017 09:46 AM, Eric Farman wrote:
> > A 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 from the device and break up
> > all virtio-scsi requests (both sd and sg) to avoid problem from
> > the host drivers.
> > 
> > Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
> > ---
> >  pc-bios/s390-ccw/s390-ccw.h    |  4 ++++
> >  pc-bios/s390-ccw/virtio-scsi.c | 19 ++++++++++++++-----
> >  2 files changed, 18 insertions(+), 5 deletions(-)
> > 
> > diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
> > index ded67bc..e1f3751 100644
> > --- a/pc-bios/s390-ccw/s390-ccw.h
> > +++ b/pc-bios/s390-ccw/s390-ccw.h
> > @@ -42,6 +42,10 @@ typedef unsigned long long __u64;
> >  #ifndef NULL
> >  #define NULL    0
> >  #endif
> > +#ifndef MIN
> > +#define MIN(a, b) (((a) < (b)) ? (a) : (b));
> > +#endif
> 
> osdep.h defines MIN() for ALL files, so this hunk is spurious.
> 

This is a separate binary, which does not include the normal qemu
headers, though.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
                   ` (4 preceding siblings ...)
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 5/5] pc-bios/s390-ccw.img: rebuild image Eric Farman
@ 2017-04-26 15:48 ` Christian Borntraeger
  2017-04-26 16:13   ` Eric Farman
  2017-05-05  7:41 ` Fam Zheng
  6 siblings, 1 reply; 22+ messages in thread
From: Christian Borntraeger @ 2017-04-26 15:48 UTC (permalink / raw)
  To: Eric Farman, qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck, Alexander Graf

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?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples
  2017-04-26 15:24     ` Eric Farman
@ 2017-04-26 16:00       ` Eric Farman
  0 siblings, 0 replies; 22+ messages in thread
From: Eric Farman @ 2017-04-26 16:00 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: Cornelia Huck, Christian Borntraeger, Michael S . Tsirkin,
	Alexander Graf, Paolo Bonzini



On 04/26/2017 11:24 AM, Eric Farman wrote:
>
>
> On 04/26/2017 11:17 AM, Eric Blake wrote:
>> On 04/26/2017 09:46 AM, Eric Farman wrote:
>>> A 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 from the device and break up
>>> all virtio-scsi requests (both sd and sg) to avoid problem from
>>> the host drivers.
>>>
>>> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
>>> ---
>>>  pc-bios/s390-ccw/s390-ccw.h    |  4 ++++
>>>  pc-bios/s390-ccw/virtio-scsi.c | 19 ++++++++++++++-----
>>>  2 files changed, 18 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
>>> index ded67bc..e1f3751 100644
>>> --- a/pc-bios/s390-ccw/s390-ccw.h
>>> +++ b/pc-bios/s390-ccw/s390-ccw.h
>>> @@ -42,6 +42,10 @@ typedef unsigned long long __u64;
>>>  #ifndef NULL
>>>  #define NULL    0
>>>  #endif
>>> +#ifndef MIN
>>> +#define MIN(a, b) (((a) < (b)) ? (a) : (b));
>>> +#endif
>>
>> osdep.h defines MIN() for ALL files, so this hunk is spurious.
>
> Ah, so it does.  Okay, removed.  Thanks!

Er, not.  Changing this header file didn't force virtio-scsi.c to 
recompile, so it bombs out as Cornelia points out.

>
> I guess it would make sense for the hunk that uses it to use
> MIN_NON_ZERO instead, which is also defined there.
>
>>
>
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-04-26 15:48 ` [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Christian Borntraeger
@ 2017-04-26 16:13   ` Eric Farman
  0 siblings, 0 replies; 22+ messages in thread
From: Eric Farman @ 2017-04-26 16:13 UTC (permalink / raw)
  To: Christian Borntraeger, qemu-devel
  Cc: Cornelia Huck, Paolo Bonzini, Alexander Graf, Michael S . Tsirkin



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.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 2/5] pc-bios/s390-ccw: Remove duplicate blk_factor adjustment
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 2/5] pc-bios/s390-ccw: Remove duplicate blk_factor adjustment Eric Farman
@ 2017-05-05  7:10   ` Christian Borntraeger
  0 siblings, 0 replies; 22+ messages in thread
From: Christian Borntraeger @ 2017-05-05  7:10 UTC (permalink / raw)
  To: Eric Farman, qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck, Alexander Graf

On 04/26/2017 04:46 PM, Eric Farman wrote:
> 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.
> 
> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  pc-bios/s390-ccw/virtio-scsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
> index d850a8d..69b7a93 100644
> --- a/pc-bios/s390-ccw/virtio-scsi.c
> +++ b/pc-bios/s390-ccw/virtio-scsi.c
> @@ -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);
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi Eric Farman
@ 2017-05-05  7:39   ` Paolo Bonzini
  2017-05-05  7:50   ` Christian Borntraeger
  1 sibling, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2017-05-05  7:39 UTC (permalink / raw)
  To: Eric Farman, qemu-devel
  Cc: Michael S . Tsirkin, Alexander Graf, Christian Borntraeger,
	Cornelia Huck



On 26/04/2017 16:46, Eric Farman wrote:
> The virtio spec states that the max_sectors field is
> "a hint to the driver for the maximum transfer size"
> that would be used for a virtio-scsi request.
> 
> It's currently hardcoded to xFFFF unless one is established
> by the max_sectors parameter on the command line, but let's
> roll through the associated devices and set it to anything
> lower if one is set for the underlying block device and
> retrieved by the BLKSECTGET ioctl.

Have you tried looking at the block limits VPD page in the firmware?
QEMU is passing BLKSECTGET down by patching that VPD page.  Your
solution would not work with hotplug.

Thanks,

Paolo

> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
> ---
>  hw/scsi/virtio-scsi.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index 46a3e3f..bca9461 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -640,7 +640,11 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
>                                     uint8_t *config)
>  {
>      VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
> +    VirtIOSCSI *vs = VIRTIO_SCSI(vdev);
>      VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(vdev);
> +    SCSIDevice *d;
> +    BusChild *kid;
> +    unsigned int max_transfer;
>  
>      virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues);
>      virtio_stl_p(vdev, &scsiconf->seg_max, 128 - 2);
> @@ -652,6 +656,14 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
>      virtio_stw_p(vdev, &scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL);
>      virtio_stw_p(vdev, &scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET);
>      virtio_stl_p(vdev, &scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN);
> +
> +    QTAILQ_FOREACH(kid, &vs->bus.qbus.children, sibling) {
> +        d = SCSI_DEVICE(kid->child);
> +        max_transfer = blk_get_max_transfer(d->conf.blk) / d->blocksize;
> +        virtio_stl_p(vdev,
> +                     &scsiconf->max_sectors,
> +                     MIN_NON_ZERO(max_transfer, scsiconf->max_sectors));
> +    }
>  }
>  
>  static void virtio_scsi_set_config(VirtIODevice *vdev,
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
                   ` (5 preceding siblings ...)
  2017-04-26 15:48 ` [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Christian Borntraeger
@ 2017-05-05  7:41 ` Fam Zheng
  2017-05-05 15:03   ` Eric Farman
  6 siblings, 1 reply; 22+ messages in thread
From: Fam Zheng @ 2017-05-05  7:41 UTC (permalink / raw)
  To: Eric Farman
  Cc: qemu-devel, Michael S . Tsirkin, Alexander Graf,
	Christian Borntraeger, Cornelia Huck, Paolo Bonzini

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi
  2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi Eric Farman
  2017-05-05  7:39   ` Paolo Bonzini
@ 2017-05-05  7:50   ` Christian Borntraeger
  1 sibling, 0 replies; 22+ messages in thread
From: Christian Borntraeger @ 2017-05-05  7:50 UTC (permalink / raw)
  To: Eric Farman, qemu-devel
  Cc: Paolo Bonzini, Michael S . Tsirkin, Cornelia Huck, Alexander Graf

On 04/26/2017 04:46 PM, Eric Farman wrote:
> The virtio spec states that the max_sectors field is
> "a hint to the driver for the maximum transfer size"
> that would be used for a virtio-scsi request.
> 
> It's currently hardcoded to xFFFF unless one is established
> by the max_sectors parameter on the command line, but let's
> roll through the associated devices and set it to anything
> lower if one is set for the underlying block device and
> retrieved by the BLKSECTGET ioctl.
> 
> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>

So since nobody else commented, I looked into this (not knowing anything 
about scsi before)

Your patch basically limits the HBA limit to the lowest size of all child devices.
This will certainly work, as guests will use the minimum of per-device size
and hba size.
Now: I think this might have some impact on cases where a HBA will have different
scsi disks or even non disk type scsi devices (what does blk_get_max_transfer 
return for a scsi cdrom or old scsi-1 devices?)

So in essence I think what could be a better solution is to enhance the 
ccw bios to actually read the per-device config in addition to the hba config.

Linux seems to use the Block Limits VPD any maybe the ccw bios should do the
same. So basically keep patch 4 and add an additional call to read the block VPD
and use the minimum of HBA and device value?

> ---
>  hw/scsi/virtio-scsi.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index 46a3e3f..bca9461 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -640,7 +640,11 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
>                                     uint8_t *config)
>  {
>      VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
> +    VirtIOSCSI *vs = VIRTIO_SCSI(vdev);
>      VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(vdev);
> +    SCSIDevice *d;
> +    BusChild *kid;
> +    unsigned int max_transfer;
> 
>      virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues);
>      virtio_stl_p(vdev, &scsiconf->seg_max, 128 - 2);
> @@ -652,6 +656,14 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
>      virtio_stw_p(vdev, &scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL);
>      virtio_stw_p(vdev, &scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET);
>      virtio_stl_p(vdev, &scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN);
> +
> +    QTAILQ_FOREACH(kid, &vs->bus.qbus.children, sibling) {
> +        d = SCSI_DEVICE(kid->child);
> +        max_transfer = blk_get_max_transfer(d->conf.blk) / d->blocksize;
> +        virtio_stl_p(vdev,
> +                     &scsiconf->max_sectors,
> +                     MIN_NON_ZERO(max_transfer, scsiconf->max_sectors));
> +    }
>  }
> 
>  static void virtio_scsi_set_config(VirtIODevice *vdev,
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-05-05  7:41 ` Fam Zheng
@ 2017-05-05 15:03   ` Eric Farman
  2017-05-05 15:13     ` Paolo Bonzini
  0 siblings, 1 reply; 22+ messages in thread
From: Eric Farman @ 2017-05-05 15:03 UTC (permalink / raw)
  To: Fam Zheng
  Cc: Michael S . Tsirkin, Alexander Graf, qemu-devel,
	Christian Borntraeger, Cornelia Huck, Paolo Bonzini



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
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-05-05 15:03   ` Eric Farman
@ 2017-05-05 15:13     ` Paolo Bonzini
  2017-05-05 16:12       ` Eric Farman
  0 siblings, 1 reply; 22+ messages in thread
From: Paolo Bonzini @ 2017-05-05 15:13 UTC (permalink / raw)
  To: Eric Farman, Fam Zheng
  Cc: Michael S . Tsirkin, Alexander Graf, qemu-devel,
	Christian Borntraeger, Cornelia Huck



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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-05-05 15:13     ` Paolo Bonzini
@ 2017-05-05 16:12       ` Eric Farman
  2017-05-06  8:24         ` Paolo Bonzini
  0 siblings, 1 reply; 22+ messages in thread
From: Eric Farman @ 2017-05-05 16:12 UTC (permalink / raw)
  To: Paolo Bonzini, Fam Zheng
  Cc: Michael S . Tsirkin, Alexander Graf, qemu-devel,
	Christian Borntraeger, Cornelia Huck



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
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-05-05 16:12       ` Eric Farman
@ 2017-05-06  8:24         ` Paolo Bonzini
  2017-05-08  7:00           ` Christian Borntraeger
  0 siblings, 1 reply; 22+ messages in thread
From: Paolo Bonzini @ 2017-05-06  8:24 UTC (permalink / raw)
  To: Eric Farman, Fam Zheng
  Cc: Michael S . Tsirkin, Alexander Graf, qemu-devel,
	Christian Borntraeger, Cornelia Huck



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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-05-06  8:24         ` Paolo Bonzini
@ 2017-05-08  7:00           ` Christian Borntraeger
  2017-05-08 15:00             ` Eric Farman
  0 siblings, 1 reply; 22+ messages in thread
From: Christian Borntraeger @ 2017-05-08  7:00 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Farman, Fam Zheng
  Cc: Michael S . Tsirkin, Alexander Graf, qemu-devel, Cornelia Huck

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.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX
  2017-05-08  7:00           ` Christian Borntraeger
@ 2017-05-08 15:00             ` Eric Farman
  0 siblings, 0 replies; 22+ messages in thread
From: Eric Farman @ 2017-05-08 15:00 UTC (permalink / raw)
  To: Christian Borntraeger, Paolo Bonzini, Fam Zheng
  Cc: qemu-devel, Cornelia Huck, Alexander Graf, Michael S . Tsirkin



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

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-05-08 15:01 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi Eric Farman
2017-05-05  7:39   ` Paolo Bonzini
2017-05-05  7:50   ` Christian Borntraeger
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 2/5] pc-bios/s390-ccw: Remove duplicate blk_factor adjustment Eric Farman
2017-05-05  7:10   ` Christian Borntraeger
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 3/5] pc-bios/s390-ccw: Move SCSI block factor to outer read Eric Farman
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples Eric Farman
2017-04-26 15:17   ` Eric Blake
2017-04-26 15:24     ` Eric Farman
2017-04-26 16:00       ` Eric Farman
2017-04-26 15:47     ` Cornelia Huck
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 5/5] pc-bios/s390-ccw.img: rebuild image Eric Farman
2017-04-26 15:48 ` [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Christian Borntraeger
2017-04-26 16:13   ` Eric Farman
2017-05-05  7:41 ` Fam Zheng
2017-05-05 15:03   ` Eric Farman
2017-05-05 15:13     ` Paolo Bonzini
2017-05-05 16:12       ` Eric Farman
2017-05-06  8:24         ` Paolo Bonzini
2017-05-08  7:00           ` Christian Borntraeger
2017-05-08 15:00             ` Eric Farman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.