Patchwork [v3] s390/ipl: Fix boot order

login
register
mail settings
Submitter Christian Borntraeger
Date June 18, 2013, 12:31 p.m.
Message ID <1371558712-43580-1-git-send-email-borntraeger@de.ibm.com>
Download mbox | patch
Permalink /patch/252341/
State New
Headers show

Comments

Christian Borntraeger - June 18, 2013, 12:31 p.m.
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 <borntraeger@de.ibm.com>
CC: qemu-stable@nongnu.org
---
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(-)
Andreas Färber - June 18, 2013, 12:36 p.m.
Am 18.06.2013 14:31, schrieb Christian Borntraeger:
> 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 <borntraeger@de.ibm.com>
> CC: qemu-stable@nongnu.org
> ---
> Changelog:
> 
> Version 2: Review feedback from Andreas Faerber
> Version 3: use object_dynamic_cast to avoid crashes with !ccw

Reviewed-by: Andreas Färber <afaerber@suse.de>

Thanks a lot,
Andreas

> 
>  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;
> +            }
>          }
>      }
>  
>
Alexander Graf - June 24, 2013, 12:57 p.m.
On 18.06.2013, at 14:31, Christian Borntraeger wrote:

> 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 <borntraeger@de.ibm.com>
> CC: qemu-stable@nongnu.org

Thanks, applied to s390-next.


Alex

Patch

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;
+            }
         }
     }