[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 4/6] scsi-disk: allow customization of the lun
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [RFC PATCH 4/6] scsi-disk: allow customization of the lun |
Date: |
Fri, 20 May 2011 17:03:35 +0200 |
This will not work until there is a device that can answer REPORT LUNS
for disks with LUN != 0. However, it provides the infrastructure.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi-disk.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index b14c32f..f41550a 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -66,6 +66,7 @@ struct SCSIDiskState
/* The qemu block layer uses a fixed 512 byte sector size.
This is the number of 512 byte blocks in a single scsi sector. */
int cluster_size;
+ uint32_t lun;
uint32_t removable;
uint64_t max_lba;
QEMUBH *bh;
@@ -516,7 +517,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req,
uint8_t *outbuf)
memset(outbuf, 0, buflen);
- if (req->lun) {
+ if (req->lun != s->lun) {
outbuf[0] = 0x7f; /* LUN not supported */
return buflen;
}
@@ -955,6 +956,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r,
uint8_t *outbuf)
DPRINTF("Unsupported Service Action In\n");
goto illegal_request;
case REPORT_LUNS:
+ assert(!s->lun);
if (req->cmd.xfer < 16)
goto illegal_request;
memset(outbuf, 0, 16);
@@ -1022,14 +1024,12 @@ static int32_t scsi_send_command(SCSIRequest *req,
uint8_t *buf)
}
#endif
- if (req->lun) {
- /* Only LUN 0 supported. */
+ if (command != REQUEST_SENSE && command != INQUIRY && req->lun != s->lun) {
+ /* Only one LUN supported. */
DPRINTF("Unimplemented LUN %d\n", req->lun);
- if (command != REQUEST_SENSE && command != INQUIRY) {
- scsi_command_complete(r, CHECK_CONDITION,
- SENSE_CODE(LUN_NOT_SUPPORTED));
- return 0;
- }
+ scsi_command_complete(r, CHECK_CONDITION,
+ SENSE_CODE(LUN_NOT_SUPPORTED));
+ return 0;
}
switch (command) {
case TEST_UNIT_READY:
@@ -1247,6 +1247,7 @@ static SCSIDeviceInfo scsi_disk_info = {
.get_sense = scsi_get_sense,
.qdev.props = (Property[]) {
DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf),
+ DEFINE_PROP_UINT32("lun", SCSIDiskState, lun, 0),
DEFINE_PROP_STRING("ver", SCSIDiskState, version),
DEFINE_PROP_STRING("serial", SCSIDiskState, serial),
DEFINE_PROP_BIT("removable", SCSIDiskState, removable, 0, false),
--
1.7.4.4
[Qemu-devel] [RFC PATCH 1/6] scsi: ignore LUN field in the CDB, Paolo Bonzini, 2011/05/20
[Qemu-devel] [RFC PATCH 4/6] scsi-disk: allow customization of the lun,
Paolo Bonzini <=
[Qemu-devel] [RFC PATCH 5/6] scsi: let a SCSIDevice have children devices, Paolo Bonzini, 2011/05/20
[Qemu-devel] [RFC PATCH 6/6] scsi: add walking of hierarchical LUNs, Paolo Bonzini, 2011/05/20
Re: [Qemu-devel] [RFC PATCH 0/6] SCSI series part 2, rewrite LUN parsing, Christoph Hellwig, 2011/05/20