qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [qemu-s390x] [PATCH 1/3] s390: Refactor IPL parameter block generati


From: Thomas Huth
Subject: Re: [qemu-s390x] [PATCH 1/3] s390: Refactor IPL parameter block generation
Date: Fri, 6 Apr 2018 09:52:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 05.04.2018 17:07, Viktor Mihajlovski wrote:
> Splitting out the the CCW device extraction allows reuse.
> 
> Signed-off-by: Viktor Mihajlovski <address@hidden>
> ---
>  hw/s390x/ipl.c | 81 
> ++++++++++++++++++++++++++++++++++++----------------------
>  1 file changed, 51 insertions(+), 30 deletions(-)
> 
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index fdeaec3..58e33c5 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -279,44 +279,52 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl)
>      *timeout = cpu_to_be32(splash_time);
>  }
>  
> +static CcwDevice *s390_get_ccw_device(DeviceState *dev_st)
> +{
> +    CcwDevice *ccw_dev = NULL;
> +
> +    if (dev_st) {
> +        VirtioCcwDevice *virtio_ccw_dev = (VirtioCcwDevice *)
> +            object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent),
> +                                TYPE_VIRTIO_CCW_DEVICE);
> +        if (virtio_ccw_dev) {
> +            ccw_dev = CCW_DEVICE(virtio_ccw_dev);
> +        } else {
> +            SCSIDevice *sd = (SCSIDevice *)
> +                object_dynamic_cast(OBJECT(dev_st),
> +                                    TYPE_SCSI_DEVICE);
> +            if (sd) {
> +                SCSIBus *bus = scsi_bus_from_device(sd);
> +                VirtIOSCSI *vdev = container_of(bus, VirtIOSCSI, bus);
> +                VirtIOSCSICcw *scsi_ccw = container_of(vdev, VirtIOSCSICcw,
> +                                                       vdev);
> +
> +                ccw_dev = (CcwDevice *)object_dynamic_cast(OBJECT(scsi_ccw),
> +                                                           TYPE_CCW_DEVICE);
> +            }
> +        }
> +    }
> +    return ccw_dev;
> +}
> +
>  static bool s390_gen_initial_iplb(S390IPLState *ipl)
>  {
>      DeviceState *dev_st;
> +    CcwDevice *ccw_dev = NULL;
>  
>      dev_st = get_boot_device(0);
>      if (dev_st) {
> -        VirtioCcwDevice *virtio_ccw_dev = (VirtioCcwDevice *)
> -            object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent),
> -                TYPE_VIRTIO_CCW_DEVICE);
> +        ccw_dev = s390_get_ccw_device(dev_st);
> +    }
> +
> +    /*
> +     * Currently allow IPL only from CCW devices.
> +     */
> +    if (ccw_dev) {
>          SCSIDevice *sd = (SCSIDevice *) object_dynamic_cast(OBJECT(dev_st),
>                                                              
> TYPE_SCSI_DEVICE);

The SCSIDevice dynamic cast now has to be done twice ... but I guess
that's ok (we're only doing this for the boot device, so it this should
not be time-critical, right?).

Reviewed-by: Thomas Huth <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]