summaryrefslogtreecommitdiff
path: root/hw/scsi-bus.c
AgeCommit message (Collapse)AuthorFilesLines
2011-09-12scsi-disk: Fix START_STOP to fail when it can't ejectMarkus Armbruster1-0/+10
Don't fail when tray is already open. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-10scsi-bus: remove duplicate table entriesBlue Swirl1-3/+1
Remove duplicate entries from SCSI command table, spotted by clang analyzer: /src/qemu/hw/scsi-bus.c:979:40: warning: initializer overrides prior initialization of this subobject [ ERASE_16 ] = "ERASE_16", /src/qemu/hw/scsi-bus.c:978:40: note: previous initialization is here [ WRITE_SAME_16 ] = "WRITE_SAME_16", /src/qemu/hw/scsi-bus.c:984:40: warning: initializer overrides prior initialization of this subobject [ MAINTENANCE_IN ] = "MAINTENANCE_IN", /src/qemu/hw/scsi-bus.c:917:40: note: previous initialization is here [ MAINTENANCE_IN ] = "MAINTENANCE_IN", /src/qemu/hw/scsi-bus.c:985:40: warning: initializer overrides prior initialization of this subobject [ MAINTENANCE_OUT ] = "MAINTENANCE_OUT", /src/qemu/hw/scsi-bus.c:918:40: note: previous initialization is here [ MAINTENANCE_OUT ] = "MAINTENANCE_OUT", Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-06scsi: fill in additional sense length correctlyPaolo Bonzini1-1/+2
Even though we do not use them, we should include the last three bytes of sense data in the additional sense length. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06scsi: refine constants for READ CAPACITY 16Paolo Bonzini1-1/+2
Rename SERVICE_ACTION_IN to SERVICE_ACTION_IN_16 to distinguish from the 12-byte CDB variant, and add a constant for the subcommand. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-2/+2
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-16scsi: do not overwrite memory on REQUEST SENSE commands with a large bufferPaolo Bonzini1-1/+2
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. Reported-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-14hw/scsi-bus.c: Fix use of uninitialised variablePeter Maydell1-1/+1
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 <peter.maydell@linaro.org> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-12scsi: add special traces for common commandsPaolo Bonzini1-0/+17
Can be useful when debugging the device scan phase. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: report unit attention on resetPaolo Bonzini1-1/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: add support for unit attention conditionsPaolo Bonzini1-2/+91
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 <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: add a bunch more common sense codesPaolo Bonzini1-0/+30
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: move handling of REQUEST SENSE to common codePaolo Bonzini1-2/+10
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: move handling of REPORT LUNS and invalid LUNs to common codePaolo Bonzini1-1/+174
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: move request parsing to common codePaolo Bonzini1-15/+38
Also introduce the first occurrence of "independent" SCSIReqOps, to handle invalid commands in common code. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: push lun field to SCSIDevicePaolo Bonzini1-0/+1
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 <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: introduce SCSICommandPaolo Bonzini1-47/+48
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 <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: pass cdb already to scsi_req_newPaolo Bonzini1-5/+8
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 soon as scsi_req_new will also take care of the parsing. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: move request-related callbacks from SCSIDeviceInfo to SCSIReqOpsPaolo Bonzini1-10/+10
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: introduce SCSIReqOpsPaolo Bonzini1-2/+3
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 <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: move sense handling to generic codePaolo Bonzini1-5/+62
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 an entirely generic implementation. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: pass status when completingPaolo Bonzini1-4/+4
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. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-11scsi-bus: use DO_UPCASTZhi Yong Wu1-1/+1
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-08-01scsi: Sanitize command definitionsHannes Reinecke1-27/+42
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, ACCESS_CONTROL_OUT, COMPARE_AND_WRITE, VERIFY_16, SYNCHRONIZE_CACHE_16, LOCATE_16, ERASE_16, WRITE_LONG_16, LOAD_UNLOAD, VERIFY_12. Remove invalid definition of WRITE_LONG_2. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01scsi: Remove REZERO_UNIT emulationHannes Reinecke1-3/+0
REZERO_UNIT command is obsolete. Remove support for it. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01scsi: Remove references to SET_WINDOWHannes Reinecke1-2/+0
SET_WINDOW command is vendor-specific only. So we shouldn't try to emulate it. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-07-19scsi: Add 'hba_private' to SCSIRequestHannes Reinecke1-3/+6
'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 in parallel. 'tag' is still being kept for tracing purposes. Signed-off-by: Hannes Reinecke <hare@suse.de> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-06-05scsi: fix tracing of scsi requests with simple backendPaolo Bonzini1-1/+5
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 <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-05-26scsi: split command_complete callback in twoPaolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: Implement 'get_sense' callbackHannes Reinecke1-0/+9
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 <hare@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_get_bufPaolo Bonzini1-0/+5
... and remove some SCSIDevice variables or fields that now become unused. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_continuePaolo Bonzini1-3/+13
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_newPaolo Bonzini1-0/+5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: do not call send_command directlyPaolo Bonzini1-1/+8
Move the common part of scsi-disk.c and scsi-generic.c to the SCSI layer. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: Update sense code handlingHannes Reinecke1-1/+90
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. This patch introduces various predefined sense codes to have the sense code reporting more in line with the spec. On top of Hannes's patch I fixed the reply to REQUEST SENSE commands with DESC=0 and a small (<18) length. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_cancelPaolo Bonzini1-3/+14
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 <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_abortPaolo Bonzini1-0/+9
This covers the case of canceling a request's I/O and still completing it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: commonize purging requestsPaolo Bonzini1-0/+12
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 <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: Use 'SCSIRequest' directlyHannes Reinecke1-17/+8
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 allows use to use it directly as an argument to the SCSIDeviceInfo callback functions and remove the lookup. A new callback function 'alloc_req' is introduced matching 'free req'; unref'ing to free up resources after use is moved into the scsi_command_complete callbacks. This temporarily introduces a leak of requests that are cancelled, when they are removed from the queue and not from the driver. This is fixed later by introducing scsi_req_cancel. That patch in turn depends on this one, because the argument to scsi_req_cancel is a SCSIRequest. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: reference-count requestsPaolo Bonzini1-7/+22
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 the need to unref the request when it fails. This will go away with the next patches, which move the unref'ing to the devices. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce SCSIBusOpsPaolo Bonzini1-6/+6
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 target; in this case, while all commands will ultimately reach a logical unit, it is the target who is in charge of answering REPORT LUNs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_dataPaolo Bonzini1-0/+11
This abstracts calling the command_complete callback, reducing churn in the following patches. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: add tracing of scsi requestsPaolo Bonzini1-0/+6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-01-24scsi: Allow scsi_bus_legacy_add_drive() to set removable bitStefan Hajnoczi1-2/+6
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 <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-11Add get_fw_dev_path callback to scsi bus.Gleb Natapov1-0/+23
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-11-25scsi: Move sense handling into the driverHannes Reinecke1-10/+0
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 <hare@suse.de> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-11-25scsi: Increase the number of possible devicesHannes Reinecke1-1/+1
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 by the bus. Signed-off-by: Hannes Reinecke <hare@suse.de> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-09-21scsi_bus: fix length and xfer_mode for RESERVE and RELEASE commandsBernhard Kohl1-1/+2
For the RESERVE and RELEASE commands the length must be zero and xfer_mode must be SCSI_XFER_NONE. Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-08-24Rearrange block headersBlue Swirl1-0/+1
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 <blauwirbel@gmail.com>
2010-07-22scsi: Dequeue requests before invoking completion callbackJan Kiszka1-1/+11
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 tag reuse and cancel the completed request. That will cause a double free later on when the completion path cleans up as well. Fix this by dequeuing the request before invoking the callback. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-07-06scsi: Error locations for -drive if=scsi device initializationMarkus Armbruster1-0/+4
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>