]> Git Repo - qemu.git/commitdiff
scsi/scsi_bus: Add scsi_device_get
authorMaxim Levitsky <[email protected]>
Tue, 6 Oct 2020 12:39:02 +0000 (15:39 +0300)
committerPaolo Bonzini <[email protected]>
Mon, 12 Oct 2020 15:50:51 +0000 (11:50 -0400)
Add scsi_device_get which finds the scsi device
and takes a reference to it.

Suggested-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Message-Id: <20200913160259[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
hw/scsi/scsi-bus.c
include/hw/scsi/scsi.h

index 7599113efec3684a2029f3adf0fa24706b5a391d..eda8cb7e70f5d0d4e807cbff0551caf4a7a0af95 100644 (file)
@@ -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);
index 7a55cdbd74e1c6ed9f01627863b8a99ed05976a6..09fa5c9d2a03f35f876e83f21373c273a5a3a62f 100644 (file)
@@ -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;
This page took 0.029172 seconds and 4 git commands to generate.