[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 48/53] s390x: follow qdev tree to detect SCSI device on a CCW bus
From: |
Paolo Bonzini |
Subject: |
[PULL 48/53] s390x: follow qdev tree to detect SCSI device on a CCW bus |
Date: |
Tue, 19 Apr 2022 07:51:04 +0200 |
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>
---
hw/s390x/ipl.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 84971e537b..2dcc24175d 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;
+ }
+ }
}
}
}
--
2.35.1
- [PULL 15/53] tests: replace free_all() usage with g_auto, (continued)
- [PULL 15/53] tests: replace free_all() usage with g_auto, Paolo Bonzini, 2022/04/19
- [PULL 31/53] include: move os_*() to os-foo.h, Paolo Bonzini, 2022/04/19
- [PULL 33/53] Move CPU softfloat unions to cpu-float.h, Paolo Bonzini, 2022/04/19
- [PULL 34/53] Move fcntl_setfl() to oslib-posix, Paolo Bonzini, 2022/04/19
- [PULL 35/53] qga: remove explicit environ argument from exec/spawn, Paolo Bonzini, 2022/04/19
- [PULL 28/53] include: move target page bits declaration to page-vary.h, Paolo Bonzini, 2022/04/19
- [PULL 29/53] include: move progress API to qemu-progress.h, Paolo Bonzini, 2022/04/19
- [PULL 45/53] hyperv: Add definitions for syndbg, Paolo Bonzini, 2022/04/19
- [PULL 46/53] hyperv: Add support to process syndbg commands, Paolo Bonzini, 2022/04/19
- [PULL 36/53] Remove qemu-common.h include from most units, Paolo Bonzini, 2022/04/19
- [PULL 48/53] s390x: follow qdev tree to detect SCSI device on a CCW bus,
Paolo Bonzini <=
- [PULL 22/53] include: move qemu_write_full() declaration to osdep.h, Paolo Bonzini, 2022/04/19
- [PULL 18/53] error-report: replace deprecated g_get_current_time() with glib >= 2.62, Paolo Bonzini, 2022/04/19
- [PULL 43/53] thread-posix: optimize qemu_sem_timedwait with zero timeout, Paolo Bonzini, 2022/04/19
- [PULL 50/53] virtio-ccw: move device type declarations to .c files, Paolo Bonzini, 2022/04/19
- [PULL 53/53] target/i386: Remove unused XMMReg, YMMReg types and CPUState fields, Paolo Bonzini, 2022/04/19
- [PULL 25/53] include: move dump_in_progress() to runstate.h, Paolo Bonzini, 2022/04/19
- [PULL 26/53] include: move C/util-related declarations to cutils.h, Paolo Bonzini, 2022/04/19
- [PULL 32/53] include: move page_size_init() to include/hw/core/cpu.h, Paolo Bonzini, 2022/04/19
- [PULL 42/53] thread-posix: implement Semaphore with QemuCond and QemuMutex, Paolo Bonzini, 2022/04/19
- [PULL 39/53] whpx: Added support for breakpoints and stepping, Paolo Bonzini, 2022/04/19