[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] hw/s390x/ipl: Fix crash with virtio-scsi-pci de
From: |
Christian Borntraeger |
Subject: |
Re: [Qemu-devel] [PATCH] hw/s390x/ipl: Fix crash with virtio-scsi-pci device |
Date: |
Tue, 25 Apr 2017 20:18:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
On 04/25/2017 03:18 PM, Thomas Huth wrote:
> qemu-system-s390x currently crashes when it is started with a
> virtio-scsi-pci device, e.g.:
>
> qemu-system-s390x -nographic -enable-kvm -device virtio-scsi-pci \
> -drive file=/tmp/disk.dat,if=none,id=d1,format=raw \
> -device scsi-cd,drive=d1,bootindex=1
>
> The problem is that the code in s390_gen_initial_iplb() currently assumes
> that all SCSI devices are also CCW devices, which is not the case for
> virtio-scsi-pci of course. Fix it by adding an appropriate check for
> TYPE_CCW_DEVICE here.
>
> Signed-off-by: Thomas Huth <address@hidden>
Reviewed-by: Christian Borntraeger <address@hidden>
applied thanks.
> ---
> hw/s390x/ipl.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 7978c7d..f674d50 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -248,7 +248,13 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)
> SCSIBus *bus = scsi_bus_from_device(sd);
> VirtIOSCSI *vdev = container_of(bus, VirtIOSCSI, bus);
> VirtIOSCSICcw *scsi_ccw = container_of(vdev, VirtIOSCSICcw,
> vdev);
> - CcwDevice *ccw_dev = CCW_DEVICE(scsi_ccw);
> + CcwDevice *ccw_dev;
> +
> + ccw_dev = (CcwDevice *)object_dynamic_cast(OBJECT(scsi_ccw),
> + TYPE_CCW_DEVICE);
> + if (!ccw_dev) { /* It might be a PCI device instead */
> + return false;
> + }
>
> ipl->iplb.len = cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN);
> ipl->iplb.blk0_len =
>