Received: from eggs.gnu.org ([2001:4830:134:3::10]:48632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uos6v-00068z-7Q for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:21:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uos6r-0006mG-Rw for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:21:57 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:43122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uos6r-0006lx-E7 for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:21:53 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Jun 2013 10:16:46 +0100 From: Christian Borntraeger Date: Tue, 18 Jun 2013 11:22:06 +0200 Message-Id: <1371547326-40342-1-git-send-email-borntraeger@de.ibm.com> In-Reply-To: <51BF85A8.9000202@suse.de> References: <51BF85A8.9000202@suse.de> Subject: [Qemu-devel] [PATCH 1/2] s390/ipl: Fix boot order List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?q?Andreas=5FF=C3=A4rber?= Cc: qemu-stable@nongnu.org, qemu-devel , Dominik Dingel , Alexander Graf , Christian Borntraeger , Anthony Liguori , =?UTF-8?q?KONRAD=20Fr=C3=A9d=C3=A9ric?= 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). We need to get a VirtioCcwDevice from the device_state (but only get a VirtIODevice). An object_get_parent() accessor would be useful here, but going via the parent_bus should also work. Signed-off-by: Christian Borntraeger CC: qemu-stable@nongnu.org --- Changelog: Version 2: Review feedback from Andreas Faerber regarding parent accesses, typos and parent_bus. hw/s390x/ipl.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 0aeb003..11397ea 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -154,17 +154,18 @@ 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 = VIRTIO_CCW_DEVICE( + OBJECT(qdev_get_parent_bus(dev_st)->parent)); + + if (ccw_dev) { + env->regs[7] = ccw_dev->sch->cssid << 24 | + ccw_dev->sch->ssid << 16 | + ccw_dev->sch->devno; + } } } -- 1.8.1.4