File hw-scsi-scsi-generic-Fixup-VPD-block-lim.patch of Package qemu.29316

From: Lin Ma <lma@suse.com>
Date: Wed, 16 Nov 2022 17:25:51 +0800
Subject: hw/scsi/scsi-generic: Fixup VPD block limits emulation

Move the check for SG_IO errors after the VPD block limits emulation,
otherwise the emulation will never the triggered.

References: bsc#1202364

Signed-off-by: Lin Ma <lma@suse.com>
---
 hw/scsi/scsi-generic.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 6e57b392364115b99dad7154eede..91f4b556acf17b577a1b33d7935f 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -310,10 +310,9 @@ static void scsi_read_complete(void * opaque, int ret)
         }
     }
 
-    if (r->io_header.host_status != SCSI_HOST_OK ||
-        (r->io_header.driver_status & SG_ERR_DRIVER_TIMEOUT) ||
-        r->io_header.status != GOOD ||
-        len == 0) {
+    if (len == 0 || r->io_header.status ||
+        r->io_header.driver_status ||
+        r->io_header.host_status) {
         scsi_command_complete_noio(r, 0);
         goto done;
     }
@@ -398,10 +397,7 @@ static void scsi_write_complete(void * opaque, int ret)
 
     aio_context_acquire(blk_get_aio_context(s->conf.blk));
 
-    if (ret || r->req.io_canceled ||
-        r->io_header.status != SCSI_HOST_OK ||
-        (r->io_header.driver_status & SG_ERR_DRIVER_TIMEOUT) ||
-        r->io_header.status != GOOD) {
+    if (ret || r->req.io_canceled) {
         scsi_command_complete_noio(r, ret);
         goto done;
     }
openSUSE Build Service is sponsored by