[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 30/39] scsi/scsi_bus: switch search direction in scsi_device_find
From: |
Paolo Bonzini |
Subject: |
[PULL 30/39] scsi/scsi_bus: switch search direction in scsi_device_find |
Date: |
Sat, 10 Oct 2020 03:57:30 -0400 |
From: Maxim Levitsky <mlevitsk@redhat.com>
This change will allow us to convert the bus children list to RCU,
while not changing the logic of this function
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200913160259.32145-2-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi/scsi-bus.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 3284a5d1fb..6b1ed7ae9a 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1572,7 +1572,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel,
int id, int lun)
BusChild *kid;
SCSIDevice *target_dev = NULL;
- QTAILQ_FOREACH_REVERSE(kid, &bus->qbus.children, sibling) {
+ QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) {
DeviceState *qdev = kid->child;
SCSIDevice *dev = SCSI_DEVICE(qdev);
@@ -1580,7 +1580,15 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel,
int id, int lun)
if (dev->lun == lun) {
return dev;
}
- target_dev = dev;
+
+ /*
+ * If we don't find exact match (channel/bus/lun),
+ * we will return the first device which matches channel/bus
+ */
+
+ if (!target_dev) {
+ target_dev = dev;
+ }
}
}
return target_dev;
--
2.26.2
- [PULL 12/39] exec: split out non-softmmu-specific parts, (continued)
- [PULL 12/39] exec: split out non-softmmu-specific parts, Paolo Bonzini, 2020/10/10
- [PULL 25/39] device-plug-test: use qtest_qmp to send the device_del command, Paolo Bonzini, 2020/10/10
- [PULL 22/39] qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict, Paolo Bonzini, 2020/10/10
- [PULL 20/39] build-sys: fix git version from -version, Paolo Bonzini, 2020/10/10
- [PULL 18/39] qtest: unify extra_qtest_srcs and extra_qtest_deps, Paolo Bonzini, 2020/10/10
- [PULL 26/39] qtest: switch users back to qtest_qmp_receive, Paolo Bonzini, 2020/10/10
- [PULL 24/39] qtest: remove qtest_qmp_receive_success, Paolo Bonzini, 2020/10/10
- [PULL 29/39] qdev: add "check if address free" callback for buses, Paolo Bonzini, 2020/10/10
- [PULL 23/39] qtest: Reintroduce qtest_qmp_receive, Paolo Bonzini, 2020/10/10
- [PULL 21/39] meson.build: Re-enable KVM support for MIPS, Paolo Bonzini, 2020/10/10
- [PULL 30/39] scsi/scsi_bus: switch search direction in scsi_device_find,
Paolo Bonzini <=
- [PULL 27/39] qtest: check that drives are really appearing and disappearing, Paolo Bonzini, 2020/10/10
- [PULL 28/39] qemu-iotests, qtest: rewrite test 067 as a qtest, Paolo Bonzini, 2020/10/10
- [PULL 36/39] scsi/scsi_bus: Add scsi_device_get, Paolo Bonzini, 2020/10/10
- [PULL 35/39] scsi/scsi-bus: scsi_device_find: don't return unrealized devices, Paolo Bonzini, 2020/10/10
- [PULL 37/39] virtio-scsi: use scsi_device_get, Paolo Bonzini, 2020/10/10
- [PULL 32/39] device-core: use RCU for list of children of a bus, Paolo Bonzini, 2020/10/10
- [PULL 33/39] scsi: switch to bus->check_address, Paolo Bonzini, 2020/10/10
- [PULL 34/39] device-core: use atomic_set on .realized property, Paolo Bonzini, 2020/10/10
- [PULL 31/39] device_core: use drain_call_rcu in in qmp_device_add, Paolo Bonzini, 2020/10/10
- [PULL 38/39] scsi/scsi_bus: fix races in REPORT LUNS, Paolo Bonzini, 2020/10/10