Skip to content

Commit

Permalink
s390x: follow qdev tree to detect SCSI device on a CCW bus
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bonzini committed Apr 6, 2022
1 parent d870118 commit 7d2eb76
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions hw/s390x/ipl.c
Expand Up @@ -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;
}
}
}
}
}
Expand Down

0 comments on commit 7d2eb76

Please sign in to comment.