diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-03-28 09:40:00 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-04-06 14:31:56 +0200 |
commit | 7d2eb76d0407fc391b78df16d17f1e616ec3e228 (patch) | |
tree | 368eea85a315f61c481b6f54343c5deac00c9740 | |
parent | d8701185f40cc900d23cd93411abf1554d05ed7b (diff) | |
download | qemu-7d2eb76d0407fc391b78df16d17f1e616ec3e228.zip qemu-7d2eb76d0407fc391b78df16d17f1e616ec3e228.tar.gz qemu-7d2eb76d0407fc391b78df16d17f1e616ec3e228.tar.bz2 |
s390x: follow qdev tree to detect SCSI device on a CCW bus
Do not make assumptions on the parent type of the SCSIDevice, instead
use object_dynamic_cast all the way up to the CcwDevice. This is cleaner
because there is no guarantee that the bus is on a virtio-scsi device;
that is only the case for the default configuration of QEMU's s390x
target.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | hw/s390x/ipl.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 84971e5..2dcc241 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -375,14 +375,18 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) 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); - tmp_dt = CCW_DEVTYPE_SCSI; + SCSIBus *sbus = scsi_bus_from_device(sd); + VirtIODevice *vdev = (VirtIODevice *) + object_dynamic_cast(OBJECT(sbus->qbus.parent), + TYPE_VIRTIO_DEVICE); + if (vdev) { + ccw_dev = (CcwDevice *) + object_dynamic_cast(OBJECT(qdev_get_parent_bus(DEVICE(vdev))->parent), + TYPE_CCW_DEVICE); + if (ccw_dev) { + tmp_dt = CCW_DEVTYPE_SCSI; + } + } } } } |