From nobody Sun Feb 8 05:42:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1595961696; cv=none; d=zohomail.com; s=zohoarc; b=QhPXwLk16h5iIhz5VKRYZQ3NtK8L13WRVMQNxpEN+76E8ihwW7DID0hQNs7WfvDu4uFNe4HuwHPcB5dGUZZ5roswSTuYO4yu/TA2vgfNsYrquFm3MfzzelcxShont9UgfIvizs8zjcHFd+bqPClXm8ZB40wi1DI3Y9EweaLXdXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595961696; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=QtQk+14B6MDHKRJIdVfVT1eCD7Su5ogPrM8ZDLbPp7Q=; b=arFFLHkMUs3O/AS5l0aoGZ+g5310t9zJT8iTd+loIJACBm9p1To1WtQCqROXVRDUMX5e5Wzt/P+jVafRZawUc6M+P39D2Tc4uzM94fGGGiSC+6xXk0VRwU4MhD1Q3NE/mp+EB+ixHV9OwaguerCFJWg+KIjlOlMpl+GxFCTik6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595961696984341.865755915132; Tue, 28 Jul 2020 11:41:36 -0700 (PDT) Received: from localhost ([::1]:41972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0UXf-0004Zl-Nh for importer@patchew.org; Tue, 28 Jul 2020 14:41:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0UUb-0008K3-Gs for qemu-devel@nongnu.org; Tue, 28 Jul 2020 14:38:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46926 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k0UUY-0005U4-AW for qemu-devel@nongnu.org; Tue, 28 Jul 2020 14:38:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-qCA8Z-MsO8udX1zSIxEVGQ-1; Tue, 28 Jul 2020 14:38:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B14B79EC0; Tue, 28 Jul 2020 18:38:18 +0000 (UTC) Received: from thuth.com (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9865460BF4; Tue, 28 Jul 2020 18:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595961501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=QtQk+14B6MDHKRJIdVfVT1eCD7Su5ogPrM8ZDLbPp7Q=; b=EC7o9P2OpfMvStdRMkzwQQ3LdCK1tla6jgjKdxuu5mItEamyF99HwRXZ2yo3ydoI0uSmc4 1bEcBKkKQ9J6uSARNSyu1K6sjOrp615bQemDNF2mmHhHtyY52k6wQEITyfN9XnwYDQNf4f YsQOEiO80xGrLhv/KFFwW6+D6kDYrXc= X-MC-Unique: qCA8Z-MsO8udX1zSIxEVGQ-1 From: Thomas Huth To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-5.2 5/6] pc-bios/s390-ccw: Scan through all boot devices if none has been specified Date: Tue, 28 Jul 2020 20:37:33 +0200 Message-Id: <20200728183734.7838-6-thuth@redhat.com> In-Reply-To: <20200728183734.7838-1-thuth@redhat.com> References: <20200728183734.7838-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=thuth@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/28 10:28:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason J . Herne" , Thomas Huth , Janosch Frank , Cornelia Huck , Collin Walling , Christian Borntraeger , Claudio Imbrenda Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If no boot device has been specified (via "bootindex=3D..."), the s390-ccw bios scans through all devices to find a bootable device. But so far, it stops at the very first block device (including virtio-scsi controllers without attached devices) that it finds, no matter whether it is bootable or not. That leads to some weird situatation where it is e.g. possible to boot via: qemu-system-s390x -hda /path/to/disk.qcow2 but not if there is e.g. a virtio-scsi controller specified before: qemu-system-s390x -device virtio-scsi -hda /path/to/disk.qcow2 While using "bootindex=3D..." is clearly the preferred way of booting on s390x, we still can make the life for the users at least a little bit easier if we look at all available devices to find a bootable one. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1846975 Signed-off-by: Thomas Huth Reviewed-by: Cornelia Huck --- pc-bios/s390-ccw/main.c | 46 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 3cd01cd80f..0af872f9e3 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -182,20 +182,8 @@ static void boot_setup(void) static void find_boot_device(void) { VDev *vdev =3D virtio_get_device(); - int ssid; bool found; =20 - if (!have_iplb) { - for (ssid =3D 0; ssid < 0x3; ssid++) { - blk_schid.ssid =3D ssid; - found =3D find_subch(-1); - if (found) { - return; - } - } - panic("Could not find a suitable boot device (none specified)\n"); - } - switch (iplb.pbt) { case S390_IPL_TYPE_CCW: debug_print_int("device no. ", iplb.ccw.devno); @@ -260,14 +248,42 @@ static void ipl_boot_device(void) } } =20 +/* + * No boot device has been specified, so we have to scan through the + * channels to find one. + */ +static void probe_boot_device(void) +{ + int ssid, sch_no, ret; + + for (ssid =3D 0; ssid < 0x3; ssid++) { + blk_schid.ssid =3D ssid; + for (sch_no =3D 0; sch_no < 0x10000; sch_no++) { + ret =3D check_sch_no(-1, sch_no); + if (ret < 0) { + break; + } + if (ret =3D=3D true) { + ipl_boot_device(); /* Only returns if unsuccessful */ + } + } + } + + sclp_print("Could not find a suitable boot device (none specified)\n"); +} + int main(void) { sclp_setup(); css_setup(); boot_setup(); - find_boot_device(); - enable_subchannel(blk_schid); - ipl_boot_device(); + if (have_iplb) { + find_boot_device(); + enable_subchannel(blk_schid); + ipl_boot_device(); + } else { + probe_boot_device(); + } =20 panic("Failed to load OS from hard disk\n"); return 0; /* make compiler happy */ --=20 2.18.1