[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 05/13] scsi: let the bus pick a LUN for the c
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [RFC PATCH v2 05/13] scsi: let the bus pick a LUN for the child device |
Date: |
Mon, 6 Jun 2011 18:04:14 +0200 |
The scsi-id may be a LUN value or a target id. The bus knows,
so add a callback to that end. The default value in case there is
no implementation is to always returns zero.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi-bus.c | 3 +++
hw/scsi-disk.c | 6 +++---
hw/scsi.h | 2 ++
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index b44f308..b64ed68 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -54,6 +54,9 @@ static int scsi_qdev_init(DeviceState *qdev, DeviceInfo *base)
}
bus->devs[dev->id] = dev;
+ if (bus->ops->get_child_lun) {
+ dev->lun = bus->ops->get_child_lun(dev);
+ }
dev->info = info;
QTAILQ_INIT(&dev->requests);
rc = dev->info->init(dev);
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 87e5ac8..b2c8d6e 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -518,7 +518,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req,
uint8_t *outbuf)
memset(outbuf, 0, buflen);
- if (req->lun) {
+ if (req->lun != s->qdev.lun) {
outbuf[0] = 0x7f; /* LUN not supported */
return buflen;
}
@@ -1024,8 +1024,8 @@ static int32_t scsi_send_command(SCSIRequest *req,
uint8_t *buf)
}
#endif
- if (req->lun) {
- /* Only LUN 0 supported. */
+ if (req->lun != s->qdev.lun) {
+ /* Only one LUN supported. */
DPRINTF("Unimplemented LUN %d\n", req->lun);
if (command != REQUEST_SENSE && command != INQUIRY) {
scsi_command_complete(r, CHECK_CONDITION,
diff --git a/hw/scsi.h b/hw/scsi.h
index 8d5737b..67d18cc 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -57,6 +57,7 @@ struct SCSIDevice
{
DeviceState qdev;
uint32_t id;
+ uint32_t lun;
BlockConf conf;
SCSIDeviceInfo *info;
SCSIBus *children;
@@ -90,6 +91,7 @@ struct SCSIBusOps {
void (*transfer_data)(SCSIRequest *req, uint32_t arg);
void (*complete)(SCSIRequest *req, uint32_t arg);
void (*cancel)(SCSIRequest *req);
+ int (*get_child_lun)(SCSIDevice *dev);
};
struct SCSIBus {
--
1.7.4.4
- [Qemu-devel] [RFC PATCH v2 00/13] support hierarchical LUNs, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 02/13] scsi: support parsing of SAM logical unit numbers, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 01/13] scsi: cleanup reset and destroy callbacks, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 03/13] scsi: add initiator field to SCSIRequest, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 04/13] scsi: let a SCSIDevice have children devices, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 05/13] scsi: let the bus pick a LUN for the child device,
Paolo Bonzini <=
- [Qemu-devel] [RFC PATCH v2 06/13] scsi-generic: fix passthrough of devices with LUN != 0, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 07/13] scsi: add walking of hierarchical LUNs, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 08/13] scsi: introduce the scsi-path device, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 09/13] scsi: introduce the scsi-target device, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 10/13] scsi: include bus and device levels, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 11/13] qdev: introduce automatic creation of buses, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 12/13] scsi: create scsi-path and scsi-target devices automatically, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH v2 13/13] scsi: delete handling of REPORT LUNS and unknown LUNs outside scsi-target, Paolo Bonzini, 2011/06/06