mirror of https://github.com/xemu-project/xemu.git
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>
This commit is contained in:
parent
d8701185f4
commit
7d2eb76d04
|
@ -375,17 +375,21 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype)
|
||||||
object_dynamic_cast(OBJECT(dev_st),
|
object_dynamic_cast(OBJECT(dev_st),
|
||||||
TYPE_SCSI_DEVICE);
|
TYPE_SCSI_DEVICE);
|
||||||
if (sd) {
|
if (sd) {
|
||||||
SCSIBus *bus = scsi_bus_from_device(sd);
|
SCSIBus *sbus = scsi_bus_from_device(sd);
|
||||||
VirtIOSCSI *vdev = container_of(bus, VirtIOSCSI, bus);
|
VirtIODevice *vdev = (VirtIODevice *)
|
||||||
VirtIOSCSICcw *scsi_ccw = container_of(vdev, VirtIOSCSICcw,
|
object_dynamic_cast(OBJECT(sbus->qbus.parent),
|
||||||
vdev);
|
TYPE_VIRTIO_DEVICE);
|
||||||
|
if (vdev) {
|
||||||
ccw_dev = (CcwDevice *)object_dynamic_cast(OBJECT(scsi_ccw),
|
ccw_dev = (CcwDevice *)
|
||||||
|
object_dynamic_cast(OBJECT(qdev_get_parent_bus(DEVICE(vdev))->parent),
|
||||||
TYPE_CCW_DEVICE);
|
TYPE_CCW_DEVICE);
|
||||||
|
if (ccw_dev) {
|
||||||
tmp_dt = CCW_DEVTYPE_SCSI;
|
tmp_dt = CCW_DEVTYPE_SCSI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (devtype) {
|
if (devtype) {
|
||||||
*devtype = tmp_dt;
|
*devtype = tmp_dt;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue