Statistics
| Branch: | Revision:

root / hw / scsi-bus.c @ 11d6dded

History | View | Annotate | Download (32.4 kB)

# Date Author Comment
7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

8b2a04ee 08/16/2011 10:11 pm Paolo Bonzini

scsi: do not overwrite memory on REQUEST SENSE commands with a large buffer

Other scsi_target_reqops commands were careful about not using r->cmd.xfer
directly, and instead always cap it to a fixed length. This was not done
for REQUEST SENSE, and this patch fixes it....

3b6ffe50 08/14/2011 10:34 pm Peter Maydell

hw/scsi-bus.c: Fix use of uninitialised variable

Don't use req before it has been initialised in scsi_req_new().
This fixes a compile failure due to gcc complaining about this.

Signed-off-by: Peter Maydell <>
Acked-by: Paolo Bonzini <>...

6dc06f08 08/12/2011 04:31 pm Paolo Bonzini

scsi: add support for unit attention conditions

Unit attention conditions override any sense data the device already
has. Their signaling and clearing is handled entirely by the SCSIBus
code, and they are completely transparent to the SCSIDevices.

Signed-off-by: Paolo Bonzini <>...

c7b48872 08/12/2011 04:31 pm Paolo Bonzini

scsi: report unit attention on reset

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

98254542 08/12/2011 04:31 pm Paolo Bonzini

scsi: add special traces for common commands

Can be useful when debugging the device scan phase.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

739df215 08/12/2011 04:31 pm Paolo Bonzini

scsi: move handling of REQUEST SENSE to common code

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

a872a304 08/12/2011 04:31 pm Paolo Bonzini

scsi: add a bunch more common sense codes

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

fdaef069 08/12/2011 04:30 pm Paolo Bonzini

scsi: move handling of REPORT LUNS and invalid LUNs to common code

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

2599aece 08/12/2011 04:29 pm Paolo Bonzini

scsi: introduce SCSICommand

This struct is currently unnamed. Give it a name and use it
explicitly to decouple (some parts of) CDB parsing from
SCSIRequest.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

87dcd1b2 08/12/2011 04:29 pm Paolo Bonzini

scsi: push lun field to SCSIDevice

This will let SCSIBus detect requests sent to an invalid LUN, and
handle them itself. However, there will be still support for only one
LUN per target

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

afa46c46 08/12/2011 04:29 pm Paolo Bonzini

scsi: move request parsing to common code

Also introduce the first occurrence of "independent" SCSIReqOps,
to handle invalid commands in common code.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

12010e7b 08/12/2011 04:27 pm Paolo Bonzini

scsi: move request-related callbacks from SCSIDeviceInfo to SCSIReqOps

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

c39ce112 08/12/2011 04:27 pm Paolo Bonzini

scsi: pass cdb already to scsi_req_new

Right now the CDB is not passed to the SCSIBus until scsi_req_enqueue.
Passing it to scsi_req_new will let scsi_req_new dispatch common requests
through different reqops.

Moving the memcpy to scsi_req_new is a hack that will go away as...

8dbd4574 08/12/2011 04:27 pm Paolo Bonzini

scsi: introduce SCSIReqOps

This will let allow requests to be dispatched through different callbacks,
either common or per-device.

This patch adjusts the API, the next one will move members to SCSIReqOps.

Signed-off-by: Paolo Bonzini <>...

b45ef674 08/12/2011 04:27 pm Paolo Bonzini

scsi: move sense handling to generic code

With this patch, sense data is stored in the generic data structures
for SCSI devices and requests. The SCSI layer takes care of storing
sense data in the SCSIDevice for the subsequent REQUEST SENSE command.

At the same time, get_sense is removed and scsi_req_get_sense can use...

682a9b21 08/12/2011 04:27 pm Paolo Bonzini

scsi: pass status when completing

A small improvement in the SCSI request API. Pass the status
at the time the request is completed, so that we can assert that
no request is completed twice. This would have detected the
problem fixed in the previous patch....

645a8ad6 08/11/2011 04:37 pm Zhi Yong Wu

scsi-bus: use DO_UPCAST

Signed-off-by: Zhi Yong Wu <>
Reviewed-by: Markus Armbruster <>
Signed-off-by: Stefan Hajnoczi <>

3790372c 08/01/2011 01:10 pm Hannes Reinecke

scsi: Remove references to SET_WINDOW

SET_WINDOW command is vendor-specific only.
So we shouldn't try to emulate it.

Signed-off-by: Hannes Reinecke <>
Signed-off-by: Kevin Wolf <>

8bd3e139 08/01/2011 01:10 pm Hannes Reinecke

scsi: Remove REZERO_UNIT emulation

REZERO_UNIT command is obsolete. Remove support for it.

Signed-off-by: Hannes Reinecke <>
Signed-off-by: Kevin Wolf <>

5e30a07d 08/01/2011 01:10 pm Hannes Reinecke

scsi: Sanitize command definitions

Sanitize SCSI command definitions.
Add _10 suffix to READ_CAPACITY, WRITE_VERIFY, VERIFY, READ_LONG,
WRITE_LONG, and WRITE_SAME.
Add new command definitions for LOCATE_10, UNMAP, VARLENGTH_CDB,
WRITE_FILEMARKS_16, EXTENDED_COPY, ATA_PASSTHROUGH, ACCESS_CONTROL_IN,...

c5bf71a9 07/19/2011 04:38 pm Hannes Reinecke

scsi: Add 'hba_private' to SCSIRequest

'tag' is just an abstraction to identify the command
from the driver. So we should make that explicit by
replacing 'tag' with a driver-defined pointer 'hba_private'.
This saves the lookup for driver handling several commands...

d800040f 06/05/2011 06:05 pm Paolo Bonzini

scsi: fix tracing of scsi requests with simple backend

The simple backend only supports a maximum of 6 arguments. Split the
scsi_req_parsed event in two parts to cope with the limit.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Blue Swirl <>

c6df7102 05/26/2011 01:14 pm Paolo Bonzini

scsi: split command_complete callback in two

Signed-off-by: Paolo Bonzini <>
Cc: Christoph Hellwig <>

a1f0cce2 05/26/2011 01:14 pm Hannes Reinecke

scsi: Update sense code handling

The SCSI spec has a quite detailed list of sense codes available.
It even mandates the use of specific ones for some failure cases.
The current implementation just has one type of generic error
which is actually a violation of the spec in certain cases....

fc4f0754 05/26/2011 01:14 pm Paolo Bonzini

scsi: do not call send_command directly

Move the common part of scsi-disk.c and scsi-generic.c to the SCSI layer.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

43a2b339 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce scsi_req_new

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

ad3376cc 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce scsi_req_continue

Signed-off-by: Paolo Bonzini <>
Cc: Christoph Hellwig <>

0c34459b 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce scsi_req_get_buf

... and remove some SCSIDevice variables or fields that now become unused.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

74382217 05/26/2011 01:14 pm Hannes Reinecke

scsi: Implement 'get_sense' callback

The get_sense callback copies existing sense information into
the provided buffer. This is required if sense information
should be transferred together with the command response.

Signed-off-by: Hannes Reinecke <>...

ad2d30f7 05/26/2011 01:14 pm Paolo Bonzini

scsi: reference-count requests

With the next patch, a device may hold SCSIRequest for an indefinite
time. Split a rather big patch, and protect against access errors,
by reference counting them.

There is some ugliness in scsi_send_command implementation due to...

5c6c0e51 05/26/2011 01:14 pm Hannes Reinecke

scsi: Use 'SCSIRequest' directly

Currently the SCSIRequest structure is abstracted away and cannot accessed
directly from the driver. This requires the handler to do a lookup on
an abstract 'tag' which identifies the SCSIRequest structure.

With this patch the SCSIRequest structure is exposed to the driver. This...

c557e889 05/26/2011 01:14 pm Paolo Bonzini

scsi: commonize purging requests

The code for canceling requests upon reset is already the same. Clean
it up and move it to scsi-bus.c.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

19d110ab 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce scsi_req_abort

This covers the case of canceling a request's I/O and still
completing it.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

94d3f98a 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce scsi_req_cancel

This is for when the request must be dropped in the void,
but still memory should be freed. To this end, the devices
register a second callback in SCSIBusOps.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

5138efec 05/26/2011 01:14 pm Paolo Bonzini

scsi: add tracing of scsi requests

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

ab9adc88 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce scsi_req_data

This abstracts calling the command_complete callback, reducing churn
in the following patches.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

cfdc1bb0 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce SCSIBusOps

There are more operations than a SCSI bus can handle, besides completing
commands. One example, which this series will introduce, is cleaning up
after a request is cancelled.

More long term, a "SCSI bus" can represent the LUNs attached to a...

2d1fd261 01/24/2011 10:39 pm Stefan Hajnoczi

scsi: Allow scsi_bus_legacy_add_drive() to set removable bit

scsi-disk devices may wish to override the removable bit. Add support
for a qdev property on SCSI devices. This is will be used by usb-msd.

Signed-off-by: Stefan Hajnoczi <>...

db07c0f8 12/11/2010 11:32 pm Gleb Natapov

Add get_fw_dev_path callback to scsi bus.

Signed-off-by: Gleb Natapov <>
Signed-off-by: Blue Swirl <>

a6d96eb7 11/25/2010 01:19 pm Hannes Reinecke

scsi: Move sense handling into the driver

The current sense handling in scsi-bus is only used by the
scsi-disk driver; the scsi-generic driver is using its own.
So we should move the current sense handling into the
scsi-disk driver.

Signed-off-by: Hannes Reinecke <>...

622b520f 11/25/2010 12:57 pm Hannes Reinecke

scsi: Increase the number of possible devices

The SCSI parallel interface has a limit of 8 devices, but
not the SCSI stack in general. So we should be removing the
hard-coded limit and use MAX_SCSI_DEVS instead.
And we only need to scan those devices which are allocated...

a5e3d9ef 09/21/2010 04:39 pm Bernhard Kohl

scsi_bus: fix length and xfer_mode for RESERVE and RELEASE commands

For the RESERVE and RELEASE commands the length must be zero
and xfer_mode must be SCSI_XFER_NONE.

Signed-off-by: Bernhard Kohl <>
Signed-off-by: Kevin Wolf <>

2446333c 08/24/2010 06:22 pm Blue Swirl

Rearrange block headers

Changing block.h or blockdev.h resulted in recompiling most objects.

Move DriveInfo typedef and BlockInterfaceType enum definitions
to qemu-common.h and rearrange blockdev.h use to decrease churn.

Signed-off-by: Blue Swirl <>

e8637c90 07/22/2010 06:52 am Jan Kiszka

scsi: Dequeue requests before invoking completion callback

The request completion callback of the LSI controller may start the next
request that can use the same tag as the completed one. As the latter is
still enqueued at that point, scsi_send_command will complain about the...

42e766a2 07/06/2010 06:05 pm Markus Armbruster

scsi: Error locations for -drive if=scsi device initialization

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

f8b6cc00 07/02/2010 02:18 pm Markus Armbruster

qdev: Decouple qdev_prop_drive from DriveInfo

Make the property point to BlockDriverState, cutting out the DriveInfo
middleman. This prepares the ground for block devices that don't have
a DriveInfo.

Currently all user-defined ones have a DriveInfo, because the only way...

18846dee 07/02/2010 02:18 pm Markus Armbruster

block: Catch attempt to attach multiple devices to a blockdev

For instance, -device scsi-disk,drive=foo -device scsi-disk,drive=foo
happily creates two SCSI disks connected to the same block device.
It's all downhill from there.

Device usb-storage deliberately attaches twice to the same blockdev,...

fa66b909 07/02/2010 02:18 pm Markus Armbruster

scsi: scsi_bus_legacy_handle_cmdline() can fail, fix callers

None of its callers checks for failure. scsi_hot_add() can crash
because of that:

(qemu) drive_add 4 if=scsi,format=host_device,file=/dev/sg1
scsi-generic: scsi generic interface too old
Segmentation fault (core dumped)...

01bedeba 06/22/2010 03:38 pm Nicholas Bellinger

scsi-bus: Add PERSISTENT_RESERVE_OUT SCSIRequest->cmd.mode setup

This patch updates hw/scsi-bus.c to add the PERSISTENT_RESERVE_OUT cdb
case in scsi_req_xfer_mode() to set SCSI_XFER_TO_DEV for outgoing WRITE data.

Signed-off-by: Nicholas A. Bellinger <>...

c7126d5b 06/22/2010 03:38 pm Nicholas Bellinger

scsi-bus: Add MAINTENANCE_IN and MAINTENANCE_OUT SCSIRequest xfer and mode assignments

This patch updates hw/scsi-bus.c to add MAINTENANCE_IN and MAINTENANCE_OUT case in
scsi_req_length() for TYPE_ROM with MMC commands. It also adds the MAINTENANCE_OUT
case in scsi_req_xfer_mode() to set SCSI_XFER_TO_DEV for outgoing write data....

666daa68 06/04/2010 04:20 pm Markus Armbruster

blockdev: Collect block device code in new blockdev.c

Anything that moves hundreds of lines out of vl.c can't be all bad.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

1ecda02b 03/16/2010 05:58 pm Markus Armbruster

error: Replace qemu_error() by error_report()

error_report() terminates the message with a newline. Strip it it
from its arguments.

This fixes a few error messages lacking a newline:
net_handle_fd_param()'s "No file descriptor named %s found", and
tap_open()'s "vnet_hdr=1 requested, but no kernel support for...

2f792016 03/16/2010 05:55 pm Markus Armbruster

error: Move qemu_error & friends into their own header

545557d4 12/25/2009 06:11 pm Blue Swirl

scsi: fix Sparse warning: Initializer entry defined twice

Both REWIND and REZERO_UNIT use 0x01, READ_POSITION and PRE_FETCH
share 0x34.

Signed-off-by: Blue Swirl <>

38215553 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: GET_CONFIGURATION

Move GET_CONFIGURATION emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add GET_CONFIGURATION to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <>...

5dd90e2a 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: SERVICE_ACTION_IN

Move SERVICE_ACTION_IN emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add SERVICE_ACTION_IN to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <>...

39ec9a50 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: REPORT_LUNS

Move REPORT_LUNS emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add REPORT_LUNS to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

bd536cf3 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add read/write 16 commands.

Add READ_16 + friends to scsi-defs.h, scsi_command_name() and the
request parsing helper functions.

Use them in scsi-disk.c too.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

ec766865 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add scsi_req_print()

Handy for debugging.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

97a06435 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add xfer mode

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

37659e51 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move sense to SCSIDevice, create SCSISense struct.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

ed3a34a3 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move status to SCSIRequest.

Also add and use the scsi_req_complete() helper function for calling the
completion callback.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

9af99d98 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move request lists to QTAILQ.

Changes: * Move from open-coded lists to QTAILQ macros. * Move the struct elements to the common data structures
(SCSIDevice + SCSIRequest). * Drop free request pools. * Fix request cleanup in the destroy callback....

89b08ae1 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move SCSIRequest management to common code.

Create generic functions to allocate, find and release SCSIRequest
structs. Make scsi-disk and scsi-generic use them.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

2ec749cb 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add request parsing helpers to common code.

Add helper functions for scsi request parsing to common code. Getting
command length, transfer size, and linear block address is handled.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

43b443b6 11/09/2009 04:43 pm Gerd Hoffmann

scsi: move scsi-disk.h -> scsi.h

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

33e66b86 10/07/2009 04:54 pm Markus Armbruster

Check return value of qdev_init()

But do so only where it may actually fail. Leave the rest for the
next commit.

Patchworks-ID: 35167
Signed-off-by: Markus Armbruster <>
Signed-off-by: Anthony Liguori <>

cb23117b 10/05/2009 05:32 pm Gerd Hoffmann

scsi: hotplug windup

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

01985dcf 10/05/2009 05:32 pm Gerd Hoffmann

Implement scsi device destruction

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

ca9c39fa 10/05/2009 05:32 pm Gerd Hoffmann

switch scsi bus to inplace allocation.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

d52affa7 09/09/2009 10:57 pm Gerd Hoffmann

qdev/scsi: add scsi bus support to qdev, convert drivers.

  • Add SCSIBus. * Add SCSIDeviceInfo, move device callbacks here. * add qdev/scsi helper functions. * convert drivers.

Adding scsi disks via -device works now, i.e. you can do:

-drive id=sda,if=none,......