thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-pc-bios-s390-ccw-Do-not-bail-out-early-if-not-findin.patch

f66865
From 6f44767aeda52048e7c9ee4b5fcc30353c71cbc1 Mon Sep 17 00:00:00 2001
f66865
From: Thomas Huth <thuth@redhat.com>
f66865
Date: Fri, 9 Oct 2020 10:08:45 -0400
f66865
Subject: [PATCH 09/14] pc-bios/s390-ccw: Do not bail out early if not finding
f66865
 a SCSI disk
f66865
f66865
RH-Author: Thomas Huth <thuth@redhat.com>
f66865
Message-id: <20201009100849.264994-6-thuth@redhat.com>
f66865
Patchwork-id: 98599
f66865
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 5/9] pc-bios/s390-ccw: Do not bail out early if not finding a SCSI disk
f66865
Bugzilla: 1846975
f66865
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
f66865
RH-Acked-by: David Hildenbrand <david@redhat.com>
f66865
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
f66865
f66865
In case the user did not specify a boot device, we want to continue
f66865
looking for other devices if there are no valid SCSI disks on a virtio-
f66865
scsi controller. As a first step, do not panic in this case and let
f66865
the control flow carry the error to the upper functions instead.
f66865
f66865
Message-Id: <20200806105349.632-6-thuth@redhat.com>
f66865
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
f66865
Signed-off-by: Thomas Huth <thuth@redhat.com>
f66865
(cherry picked from commit 605751b5a5334e187761b0b8a8266a216897bf70)
f66865
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
f66865
---
f66865
 pc-bios/s390-ccw/main.c          | 14 ++++++++++----
f66865
 pc-bios/s390-ccw/s390-ccw.h      |  2 +-
f66865
 pc-bios/s390-ccw/virtio-blkdev.c |  7 +++++--
f66865
 pc-bios/s390-ccw/virtio-scsi.c   | 28 ++++++++++++++++++++--------
f66865
 pc-bios/s390-ccw/virtio-scsi.h   |  2 +-
f66865
 5 files changed, 37 insertions(+), 16 deletions(-)
f66865
f66865
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
f66865
index d6fd218074..456733fbee 100644
f66865
--- a/pc-bios/s390-ccw/main.c
f66865
+++ b/pc-bios/s390-ccw/main.c
f66865
@@ -227,7 +227,7 @@ static void find_boot_device(void)
f66865
     IPL_assert(found, "Boot device not found\n");
f66865
 }
f66865
 
f66865
-static void virtio_setup(void)
f66865
+static int virtio_setup(void)
f66865
 {
f66865
     VDev *vdev = virtio_get_device();
f66865
     QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
f66865
@@ -242,9 +242,14 @@ static void virtio_setup(void)
f66865
         sclp_print("Network boot device detected\n");
f66865
         vdev->netboot_start_addr = qipl.netboot_start_addr;
f66865
     } else {
f66865
-        virtio_blk_setup_device(blk_schid);
f66865
+        int ret = virtio_blk_setup_device(blk_schid);
f66865
+        if (ret) {
f66865
+            return ret;
f66865
+        }
f66865
         IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
f66865
     }
f66865
+
f66865
+    return 0;
f66865
 }
f66865
 
f66865
 static void ipl_boot_device(void)
f66865
@@ -255,8 +260,9 @@ static void ipl_boot_device(void)
f66865
         dasd_ipl(blk_schid, cutype); /* no return */
f66865
         break;
f66865
     case CU_TYPE_VIRTIO:
f66865
-        virtio_setup();
f66865
-        zipl_load(); /* no return */
f66865
+        if (virtio_setup() == 0) {
f66865
+            zipl_load(); /* no return */
f66865
+        }
f66865
         break;
f66865
     default:
f66865
         print_int("Attempting to boot from unexpected device type", cutype);
f66865
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
f66865
index ae432c40b8..e7cf36eb91 100644
f66865
--- a/pc-bios/s390-ccw/s390-ccw.h
f66865
+++ b/pc-bios/s390-ccw/s390-ccw.h
f66865
@@ -70,7 +70,7 @@ int sclp_read(char *str, size_t count);
f66865
 unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
f66865
                                  ulong subchan_id, void *load_addr);
f66865
 bool virtio_is_supported(SubChannelId schid);
f66865
-void virtio_blk_setup_device(SubChannelId schid);
f66865
+int virtio_blk_setup_device(SubChannelId schid);
f66865
 int virtio_read(ulong sector, void *load_addr);
f66865
 u64 get_clock(void);
f66865
 ulong get_second(void);
f66865
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
f66865
index 11c56261ca..7d35050292 100644
f66865
--- a/pc-bios/s390-ccw/virtio-blkdev.c
f66865
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
f66865
@@ -263,9 +263,10 @@ uint64_t virtio_get_blocks(void)
f66865
     return 0;
f66865
 }
f66865
 
f66865
-void virtio_blk_setup_device(SubChannelId schid)
f66865
+int virtio_blk_setup_device(SubChannelId schid)
f66865
 {
f66865
     VDev *vdev = virtio_get_device();
f66865
+    int ret = 0;
f66865
 
f66865
     vdev->schid = schid;
f66865
     virtio_setup_ccw(vdev);
f66865
@@ -288,9 +289,11 @@ void virtio_blk_setup_device(SubChannelId schid)
f66865
             "Config: CDB size mismatch");
f66865
 
f66865
         sclp_print("Using virtio-scsi.\n");
f66865
-        virtio_scsi_setup(vdev);
f66865
+        ret = virtio_scsi_setup(vdev);
f66865
         break;
f66865
     default:
f66865
         panic("\n! No IPL device available !\n");
f66865
     }
f66865
+
f66865
+    return ret;
f66865
 }
f66865
diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
f66865
index 4fe4b9d261..88691edb89 100644
f66865
--- a/pc-bios/s390-ccw/virtio-scsi.c
f66865
+++ b/pc-bios/s390-ccw/virtio-scsi.c
f66865
@@ -192,7 +192,12 @@ static bool scsi_read_capacity(VDev *vdev,
f66865
 
f66865
 /* virtio-scsi routines */
f66865
 
f66865
-static void virtio_scsi_locate_device(VDev *vdev)
f66865
+/*
f66865
+ * Tries to locate a SCSI device and and adds the information for the found
f66865
+ * device to the vdev->scsi_device structure.
f66865
+ * Returns 0 if SCSI device could be located, or a error code < 0 otherwise
f66865
+ */
f66865
+static int virtio_scsi_locate_device(VDev *vdev)
f66865
 {
f66865
     const uint16_t channel = 0; /* again, it's what QEMU does */
f66865
     uint16_t target;
f66865
@@ -218,7 +223,7 @@ static void virtio_scsi_locate_device(VDev *vdev)
f66865
         IPL_check(sdev->channel == 0, "non-zero channel requested");
f66865
         IPL_check(sdev->target <= vdev->config.scsi.max_target, "target# high");
f66865
         IPL_check(sdev->lun <= vdev->config.scsi.max_lun, "LUN# high");
f66865
-        return;
f66865
+        return 0;
f66865
     }
f66865
 
f66865
     for (target = 0; target <= vdev->config.scsi.max_target; target++) {
f66865
@@ -245,18 +250,20 @@ static void virtio_scsi_locate_device(VDev *vdev)
f66865
              */
f66865
             sdev->lun = r->lun[0].v16[0]; /* it's returned this way */
f66865
             debug_print_int("Have to use LUN", sdev->lun);
f66865
-            return; /* we have to use this device */
f66865
+            return 0; /* we have to use this device */
f66865
         }
f66865
         for (i = 0; i < luns; i++) {
f66865
             if (r->lun[i].v64) {
f66865
                 /* Look for non-zero LUN - we have where to choose from */
f66865
                 sdev->lun = r->lun[i].v16[0];
f66865
                 debug_print_int("Will use LUN", sdev->lun);
f66865
-                return; /* we have found a device */
f66865
+                return 0; /* we have found a device */
f66865
             }
f66865
         }
f66865
     }
f66865
-    panic("\n! Cannot locate virtio-scsi device !\n");
f66865
+
f66865
+    sclp_print("Warning: Could not locate a usable virtio-scsi device\n");
f66865
+    return -ENODEV;
f66865
 }
f66865
 
f66865
 int virtio_scsi_read_many(VDev *vdev,
f66865
@@ -320,17 +327,20 @@ static void scsi_parse_capacity_report(void *data,
f66865
     }
f66865
 }
f66865
 
f66865
-void virtio_scsi_setup(VDev *vdev)
f66865
+int virtio_scsi_setup(VDev *vdev)
f66865
 {
f66865
     int retry_test_unit_ready = 3;
f66865
     uint8_t data[256];
f66865
     uint32_t data_size = sizeof(data);
f66865
     ScsiInquiryEvpdPages *evpd = &scsi_inquiry_evpd_pages_response;
f66865
     ScsiInquiryEvpdBl *evpd_bl = &scsi_inquiry_evpd_bl_response;
f66865
-    int i;
f66865
+    int i, ret;
f66865
 
f66865
     vdev->scsi_device = &default_scsi_device;
f66865
-    virtio_scsi_locate_device(vdev);
f66865
+    ret = virtio_scsi_locate_device(vdev);
f66865
+    if (ret < 0) {
f66865
+        return ret;
f66865
+    }
f66865
 
f66865
     /* We have to "ping" the device before it becomes readable */
f66865
     while (!scsi_test_unit_ready(vdev)) {
f66865
@@ -415,4 +425,6 @@ void virtio_scsi_setup(VDev *vdev)
f66865
     }
f66865
     scsi_parse_capacity_report(data, &vdev->scsi_last_block,
f66865
                                (uint32_t *) &vdev->scsi_block_size);
f66865
+
f66865
+    return 0;
f66865
 }
f66865
diff --git a/pc-bios/s390-ccw/virtio-scsi.h b/pc-bios/s390-ccw/virtio-scsi.h
f66865
index 4c4f4bbc31..4b14c2c2f9 100644
f66865
--- a/pc-bios/s390-ccw/virtio-scsi.h
f66865
+++ b/pc-bios/s390-ccw/virtio-scsi.h
f66865
@@ -67,7 +67,7 @@ static inline bool virtio_scsi_response_ok(const VirtioScsiCmdResp *r)
f66865
         return r->response == VIRTIO_SCSI_S_OK && r->status == CDB_STATUS_GOOD;
f66865
 }
f66865
 
f66865
-void virtio_scsi_setup(VDev *vdev);
f66865
+int virtio_scsi_setup(VDev *vdev);
f66865
 int virtio_scsi_read_many(VDev *vdev,
f66865
                           ulong sector, void *load_addr, int sec_num);
f66865
 
f66865
-- 
f66865
2.27.0
f66865