cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-pc-bios-s390-ccw-Scan-through-all-devices-if-no-boot.patch

a19a21
From 911dc631f9ab68c6acfd4b401fbcfaa3b58a4fb6 Mon Sep 17 00:00:00 2001
a19a21
From: Thomas Huth <thuth@redhat.com>
a19a21
Date: Fri, 9 Oct 2020 10:08:46 -0400
a19a21
Subject: [PATCH 10/14] pc-bios/s390-ccw: Scan through all devices if no boot
a19a21
 device specified
a19a21
a19a21
RH-Author: Thomas Huth <thuth@redhat.com>
a19a21
Message-id: <20201009100849.264994-7-thuth@redhat.com>
a19a21
Patchwork-id: 98600
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 6/9] pc-bios/s390-ccw: Scan through all devices if no boot device specified
a19a21
Bugzilla: 1846975
a19a21
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
a19a21
RH-Acked-by: David Hildenbrand <david@redhat.com>
a19a21
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
a19a21
a19a21
If no boot device has been specified (via "bootindex=..."), the s390-ccw
a19a21
bios scans through all devices to find a bootable device. But so far, it
a19a21
stops at the very first block device (including virtio-scsi controllers
a19a21
without attached devices) that it finds, no matter whether it is bootable
a19a21
or not. That leads to some weird situatation where it is e.g. possible
a19a21
to boot via:
a19a21
a19a21
 qemu-system-s390x -hda /path/to/disk.qcow2
a19a21
a19a21
but not if there is e.g. a virtio-scsi controller specified before:
a19a21
a19a21
 qemu-system-s390x -device virtio-scsi -hda /path/to/disk.qcow2
a19a21
a19a21
While using "bootindex=..." is clearly the preferred way of booting
a19a21
on s390x, we still can make the life for the users at least a little
a19a21
bit easier if we look at all available devices to find a bootable one.
a19a21
a19a21
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1846975
a19a21
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
a19a21
Message-Id: <20200806105349.632-7-thuth@redhat.com>
a19a21
Signed-off-by: Thomas Huth <thuth@redhat.com>
a19a21
(cherry picked from commit 869d0e2f593dd37297c366203f006b9acd1b7b45)
a19a21
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a19a21
---
a19a21
 pc-bios/s390-ccw/main.c | 46 +++++++++++++++++++++++++++--------------
a19a21
 1 file changed, 31 insertions(+), 15 deletions(-)
a19a21
a19a21
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
a19a21
index 456733fbee..5c1c98341d 100644
a19a21
--- a/pc-bios/s390-ccw/main.c
a19a21
+++ b/pc-bios/s390-ccw/main.c
a19a21
@@ -191,20 +191,8 @@ static void boot_setup(void)
a19a21
 static void find_boot_device(void)
a19a21
 {
a19a21
     VDev *vdev = virtio_get_device();
a19a21
-    int ssid;
a19a21
     bool found;
a19a21
 
a19a21
-    if (!have_iplb) {
a19a21
-        for (ssid = 0; ssid < 0x3; ssid++) {
a19a21
-            blk_schid.ssid = ssid;
a19a21
-            found = find_subch(-1);
a19a21
-            if (found) {
a19a21
-                return;
a19a21
-            }
a19a21
-        }
a19a21
-        panic("Could not find a suitable boot device (none specified)\n");
a19a21
-    }
a19a21
-
a19a21
     switch (iplb.pbt) {
a19a21
     case S390_IPL_TYPE_CCW:
a19a21
         debug_print_int("device no. ", iplb.ccw.devno);
a19a21
@@ -270,14 +258,42 @@ static void ipl_boot_device(void)
a19a21
     }
a19a21
 }
a19a21
 
a19a21
+/*
a19a21
+ * No boot device has been specified, so we have to scan through the
a19a21
+ * channels to find one.
a19a21
+ */
a19a21
+static void probe_boot_device(void)
a19a21
+{
a19a21
+    int ssid, sch_no, ret;
a19a21
+
a19a21
+    for (ssid = 0; ssid < 0x3; ssid++) {
a19a21
+        blk_schid.ssid = ssid;
a19a21
+        for (sch_no = 0; sch_no < 0x10000; sch_no++) {
a19a21
+            ret = is_dev_possibly_bootable(-1, sch_no);
a19a21
+            if (ret < 0) {
a19a21
+                break;
a19a21
+            }
a19a21
+            if (ret == true) {
a19a21
+                ipl_boot_device();      /* Only returns if unsuccessful */
a19a21
+            }
a19a21
+        }
a19a21
+    }
a19a21
+
a19a21
+    sclp_print("Could not find a suitable boot device (none specified)\n");
a19a21
+}
a19a21
+
a19a21
 int main(void)
a19a21
 {
a19a21
     sclp_setup();
a19a21
     css_setup();
a19a21
     boot_setup();
a19a21
-    find_boot_device();
a19a21
-    enable_subchannel(blk_schid);
a19a21
-    ipl_boot_device();
a19a21
+    if (have_iplb) {
a19a21
+        find_boot_device();
a19a21
+        enable_subchannel(blk_schid);
a19a21
+        ipl_boot_device();
a19a21
+    } else {
a19a21
+        probe_boot_device();
a19a21
+    }
a19a21
 
a19a21
     panic("Failed to load OS from hard disk\n");
a19a21
     return 0; /* make compiler happy */
a19a21
-- 
a19a21
2.27.0
a19a21