[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 36/39] scsi/scsi_bus: Add scsi_device_get
From: |
Paolo Bonzini |
Subject: |
[PULL 36/39] scsi/scsi_bus: Add scsi_device_get |
Date: |
Sat, 10 Oct 2020 03:57:36 -0400 |
From: Maxim Levitsky <mlevitsk@redhat.com>
Add scsi_device_get which finds the scsi device
and takes a reference to it.
Suggested-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20200913160259.32145-8-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201006123904.610658-12-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi/scsi-bus.c | 11 +++++++++++
include/hw/scsi/scsi.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 7599113efe..eda8cb7e70 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -73,6 +73,17 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int
id, int lun)
return do_scsi_device_find(bus, channel, id, lun, false);
}
+SCSIDevice *scsi_device_get(SCSIBus *bus, int channel, int id, int lun)
+{
+ SCSIDevice *d;
+ RCU_READ_LOCK_GUARD();
+ d = do_scsi_device_find(bus, channel, id, lun, false);
+ if (d) {
+ object_ref(d);
+ }
+ return d;
+}
+
static void scsi_device_realize(SCSIDevice *s, Error **errp)
{
SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s);
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index 7a55cdbd74..09fa5c9d2a 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -190,6 +190,7 @@ int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf,
int len, bool fixed);
int scsi_SG_IO_FROM_DEV(BlockBackend *blk, uint8_t *cmd, uint8_t cmd_size,
uint8_t *buf, uint8_t buf_size);
SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int target, int lun);
+SCSIDevice *scsi_device_get(SCSIBus *bus, int channel, int target, int lun);
/* scsi-generic.c. */
extern const SCSIReqOps scsi_generic_req_ops;
--
2.26.2
- [PULL 20/39] build-sys: fix git version from -version, (continued)
- [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, 2020/10/10
- [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 <=
- [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
- [PULL 39/39] meson: identify more sections of meson.build, Paolo Bonzini, 2020/10/10
- Re: [PULL 00/39] SCSI, qdev, qtest, meson patches for 2020-10-10, no-reply, 2020/10/10
- Re: [PULL 00/39] SCSI, qdev, qtest, meson patches for 2020-10-10, Peter Maydell, 2020/10/12