@@ -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),
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 <pbonzini@redhat.com> --- hw/scsi-disk.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)