File 0166-scsi-generic-check-for-additional-S.patch of Package qemu.28156

From: Hannes Reinecke <hare@suse.de>
Date: Wed, 11 Nov 2020 15:40:52 +0100
Subject: scsi-generic: check for additional SG_IO status on completion

References: bsc#1178049

SG_IO may return additional status in the 'status', 'driver_status',
and 'host_status' fields. When either of these fields are set the
command has not been executed normally, so we should not continue
processing this command but rather return an error.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bruce Rogers <brogers@suse.com>
---
 hw/scsi/scsi-generic.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 4c2867abaf22f08d1ed5f2daced6..56a69c1118afc98a5e0babbfbf45 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -251,7 +251,10 @@ static void scsi_read_complete(void * opaque, int ret)
 
     aio_context_acquire(blk_get_aio_context(s->conf.blk));
 
-    if (ret || r->req.io_canceled) {
+    if (ret || r->req.io_canceled ||
+        r->io_header.status ||
+        r->io_header.driver_status ||
+        r->io_header.host_status) {
         scsi_command_complete_noio(r, ret);
         goto done;
     }
@@ -361,7 +364,10 @@ 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) {
+    if (ret || r->req.io_canceled ||
+        r->io_header.status ||
+        r->io_header.driver_status ||
+        r->io_header.host_status) {
         scsi_command_complete_noio(r, ret);
         goto done;
     }
openSUSE Build Service is sponsored by