From patchwork Tue Jun 18 12:31:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 252341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 46A0C2C009E for ; Tue, 18 Jun 2013 22:32:06 +1000 (EST) Received: from localhost ([::1]:33187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uov4u-00051B-C0 for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 08:32:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uov4Z-0004xi-9i for qemu-devel@nongnu.org; Tue, 18 Jun 2013 08:31:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uov4V-0000pU-HK for qemu-devel@nongnu.org; Tue, 18 Jun 2013 08:31:43 -0400 Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:48986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uov4V-0000mm-8x for qemu-devel@nongnu.org; Tue, 18 Jun 2013 08:31:39 -0400 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Jun 2013 13:26:22 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp18.uk.ibm.com (192.168.101.148) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 18 Jun 2013 13:26:20 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id CEF931B08061; Tue, 18 Jun 2013 13:31:31 +0100 (BST) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5ICVKHE53084260; Tue, 18 Jun 2013 12:31:20 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r5ICVUFa001821; Tue, 18 Jun 2013 08:31:30 -0400 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r5ICVTJM001816; Tue, 18 Jun 2013 08:31:30 -0400 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id C3DBA1224437; Tue, 18 Jun 2013 14:31:29 +0200 (CEST) From: Christian Borntraeger To: =?UTF-8?q?Andreas=5FF=C3=A4rber?= Date: Tue, 18 Jun 2013 14:31:52 +0200 Message-Id: <1371558712-43580-1-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371547326-40342-1-git-send-email-borntraeger@de.ibm.com> References: <1371547326-40342-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13061812-6892-0000-0000-00000574B93A X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.114 Cc: qemu-stable@nongnu.org, qemu-devel , Dominik Dingel , Alexander Graf , Christian Borntraeger , Anthony Liguori , =?UTF-8?q?KONRAD=20Fr=C3=A9d=C3=A9ric?= Subject: [Qemu-devel] [PATCH v3] s390/ipl: Fix boot order X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The latest ipl code adaptions collided with some of the virtio refactoring rework. This resulted in always booting the first disk. Let's fix booting from a given ID. The new code also checks for command lines without bootindex to avoid random behaviour when accessing dev_st (==0). Signed-off-by: Christian Borntraeger CC: qemu-stable@nongnu.org Reviewed-by: Andreas Färber --- Changelog: Version 2: Review feedback from Andreas Faerber Version 3: use object_dynamic_cast to avoid crashes with !ccw hw/s390x/ipl.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 0aeb003..d69adb2 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -154,17 +154,19 @@ static void s390_ipl_reset(DeviceState *dev) env->psw.mask = IPL_PSW_MASK; if (!ipl->kernel) { - /* booting firmware, tell what device to boot from */ + /* Tell firmware, if there is a preferred boot device */ + env->regs[7] = -1; DeviceState *dev_st = get_boot_device(0); - VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *) object_dynamic_cast( - OBJECT(&(dev_st->parent_obj)), "virtio-blk-ccw"); - - if (ccw_dev) { - env->regs[7] = ccw_dev->sch->cssid << 24 | - ccw_dev->sch->ssid << 16 | - ccw_dev->sch->devno; - } else { - env->regs[7] = -1; + if (dev_st) { + VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *) object_dynamic_cast( + OBJECT(qdev_get_parent_bus(dev_st)->parent), + TYPE_VIRTIO_CCW_DEVICE); + + if (ccw_dev) { + env->regs[7] = ccw_dev->sch->cssid << 24 | + ccw_dev->sch->ssid << 16 | + ccw_dev->sch->devno; + } } }