summaryrefslogtreecommitdiff
path: root/hw/scsi.h
AgeCommit message (Collapse)AuthorFilesLines
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19block: move include files to include/block/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-09-21scsi: introduce scsi_cdb_length and scsi_data_cdb_lengthPaolo Bonzini1-0/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-07-27scsi: report parameter changes to HBA driversPaolo Bonzini1-0/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-07-27scsi-disk: report resized disk via sense codesPaolo Bonzini1-0/+2
Linux will not use these, but a very similar mechanism will be used to report the condition via virtio-scsi events. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-07-27scsi: establish precedence levels for unit attentionPaolo Bonzini1-0/+1
When a device is resized, we will report a unit attention condition for CAPACITY DATA HAS CHANGED. However, we should ensure that this condition does not override a more important unit attention condition. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-07-27scsi: introduce hotplug() and hot_unplug() interfaces for SCSI busCong Meng1-0/+2
Add two interfaces hotplug() and hot_unplug() to scsi bus info. The scsi bus can implement these two interfaces to signal the HBA driver of guest kernel to add/remove the scsi device in question. Signed-off-by: Sen Wang <senwang@linux.vnet.ibm.com> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com> [ Fixed braces and indentation - Paolo ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-07-26scsi-disk: Fail medium writes with proper sense for readonly LUNsRonnie Sahlberg1-0/+2
Add sense code for DATA_PROTECT/WRITE_PROTECTED and return this error for any WRITE*/WRITE_VERIFY* calls if the device is readonly=on, i.e. write-protected Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-07-26scsi-disk: parse MODE SELECT commands and parametersPaolo Bonzini1-0/+4
This adds the bulk of the parsing code for MODE SELECT, including breaking out changes to different mode pages, and checking that only changeable values are modified. In order to report errors correctly two passes are made through the parameters; the first only looks for errors, the second actually applies the changes to the mode page. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-07-18Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori1-0/+1
* kwolf/for-anthony: (41 commits) fdc-test: Clean up a bit fdc-test: introduce test_relative_seek fdc: fix relative seek qemu-iotests: Valgrind support coroutine-ucontext: Help valgrind understand coroutines qemu-io: Fix memory leaks hw/block-common: Factor out fall back to legacy -drive cyls=... blockdev: Don't limit DriveInfo serial to 20 characters hw/block-common: Factor out fall back to legacy -drive serial=... hw/block-common: Move BlockConf & friends from block.h Relax IDE CHS limits from 16383,16,63 to 65535,16,255 blockdev: Drop redundant CHS validation for if=ide hd-geometry: Compute BIOS CHS translation in one place qtest: Test we don't put hard disk info into CMOS for a CD-ROM ide pc: Put hard disk info into CMOS only for hard disks block: Geometry and translation hints are now useless, purge them qtest: Cover qdev property for BIOS CHS translation ide: qdev property for BIOS CHS translation qdev: New property type chs-translation qdev: Collect private helpers in one place ...
2012-07-17hw/block-common: Move BlockConf & friends from block.hMarkus Armbruster1-0/+1
This stuff doesn't belong to block layer, and was put there only because a better home didn't exist then. Now it does. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-10scsi: add free_request callbackPaolo Bonzini1-0/+1
Most device models have a simple lifecycle for the hba_private field and they can free it when a request is completed or cancelled. However, in some cases it may be simpler to tie the lifetime of hba_private to that of the included SCSIRequest. This patch adds a free_request callback to SCSIBusInfo that lets an HBA device model do exactly that. Normally, device models use req->hba_private == NULL to flag requests that have been completed already. Device models that use free_request will still need to track this using a flag. This is the reason why "converting" existing HBAs to use free_request adds complexity and makes little sense. It is simply an additional convenience that is provided by the SCSI layer. USB-attached storage will be the first user. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-18qdev: Convert busses to QEMU Object ModelAnthony Liguori1-0/+3
This is far less interesting than it sounds. We simply add an Object to each BusState and then register the types appropriately. Most of the interesting refactoring will follow in the next patches. Since we're changing fundamental type names (BusInfo -> BusClass), it all needs to convert at once. Fortunately, not a lot of code is affected. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Made all new bus TypeInfos static const.] [AF: Made qbus_free() call object_delete(), required {qom,glib}_allocated] Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-02-22scsi: add SCSIDevice vmstate definitionsPaolo Bonzini1-0/+16
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-22scsi: add scatter/gather functionalityPaolo Bonzini1-0/+3
Scatter/gather functionality uses the newly added DMA helpers. The device can choose between doing DMA itself, or calling scsi_req_data as usual, which will use the newly added DMA helpers to copy piecewise to/from the destination area(s). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-22scsi: pass residual amount to command_completePaolo Bonzini1-1/+2
With the upcoming sglist support, HBAs will not see any transfer_data call and will not have a way to detect short transfers. So pass the residual amount of data upon command completion. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-03qdev: register all types natively through QEMU Object ModelAnthony Liguori1-1/+0
This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27scsi: convert to QEMU Object ModelAnthony Liguori1-13/+18
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-22usb-msd: do not register twice in the boot orderPaolo Bonzini1-1/+1
USB mass storage devices are registered twice in the boot order. To avoid having to keep the two paths in sync, pass the bootindex property down to the scsi-disk device and let it register itself. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-18scsi: pass down REQUEST SENSE to the device when there is no stored sensePaolo Bonzini1-0/+2
This will let scsi-block/scsi-generic report progress on long operations. Reported-by: Thomas Schmitt <scdbackup@gmxbackup.net> Tested-by: Thomas Schmitt <scdbackup@gmxbackup.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: push request restart to SCSIDevicePaolo Bonzini1-0/+5
The request restart mechanism is generic and could be reused for scsi-generic. In the meanwhile, pushing it to SCSIDevice avoids that scsi_dma_restart_bh looks at SCSIGenericReqs when working on a scsi-block device. The code is the same that is already in hw/scsi-disk.c, with the type flags replaced by req->cmd.mode and a more generic way to requeue SCSI_XFER_NONE commands. I also added a missing call to qemu_del_vm_change_state_handler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: do not call transfer_data after canceling a requestPaolo Bonzini1-0/+1
Otherwise, if cancellation is "faked" by the AIO layer and goes through qemu_aio_flush, the whole request is completed synchronously during scsi_req_cancel. Using the enqueued flag would work here, but not in the next patches, so I'm introducing a new io_canceled flag. That's because scsi_req_data is a synchronous callback and the enqueued flag might be reset by the time it returns. scsi-disk cannot unref the request until after calling scsi_req_data. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: pass cdb to alloc_reqPaolo Bonzini1-1/+1
This will let scsi-block choose between passthrough and emulation. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: export scsi_generic_reqopsPaolo Bonzini1-0/+3
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: make reqops constPaolo Bonzini1-4/+3
Also delete a stale occurrence of SCSIReqOps inside SCSIDeviceInfo. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: move max_lba to SCSIDevicePaolo Bonzini1-0/+1
The field is only in scsi-disk for now. Moving it up to SCSIDevice makes it easier to reuse the scsi-generic reqops elsewhere. At the same time, make scsi-generic get max_lba from snooped READ CAPACITY commands as well. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: add channel to addressingPaolo Bonzini1-2/+3
This also requires little more than adding the new argument to scsi_device_find, and the qdev property. All devices by default end up on channel 0. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: allow arbitrary LUNsPaolo Bonzini1-1/+2
This only requires changes in two places: in SCSIBus, we need to look for a free LUN if somebody creates a device with a pre-existing scsi-id but the default LUN (-1, meaning "search for a free spot"); in vSCSI, we need to actually parse the LUN according to the SCSI spec. For vSCSI, max_target/max_lun are set according to the logical unit addressing format in SAM. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: remove devs array from SCSIBusPaolo Bonzini1-2/+1
Change the devs array into a linked list, and add a scsi_device_find function to navigate the children list instead. This lets the SCSI bus use more complex addressing, and HBAs can talk to the correct device when there are multiple LUNs per target. scsi_device_find may return another LUN on the same target if none is found that matches exactly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)Paolo Bonzini1-6/+5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi-disk: report media changed via unit attention sense codesPaolo Bonzini1-0/+2
Building on the previous patch, this one adds a media change callback to scsi-disk. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: notify the device when unit attention is reportedPaolo Bonzini1-0/+2
Reporting media change events via unit attention sense codes requires a small state machine: first report "NO MEDIUM", then report "MEDIUM MAY HAVE CHANGED". Unfortunately there is no good hooking point for the device to notice that its pending unit attention condition has been reported. This patch reworks the generic machinery to add one. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12block: Move BlockConf & friends from block_int.h to block.hMarkus Armbruster1-1/+0
It's convenience stuff for block device models, so block.h isn't the ideal home either, but better than block_int.h. Permits moving some #include "block_int.h" from device model .h into .c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12scsi-disk: Fix START_STOP to fail when it can't ejectMarkus Armbruster1-0/+4
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-08-12scsi: report unit attention on resetPaolo Bonzini1-1/+1
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-0/+2
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/+12
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-1/+0
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-7/+10
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-2/+2
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-6/+7
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12scsi: introduce SCSIReqOpsPaolo Bonzini1-1/+7
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-2/+8
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-1/+1
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-07-19scsi: Add 'hba_private' to SCSIRequestHannes Reinecke1-3/+7
'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-05-26scsi: split command_complete callback in twoPaolo Bonzini1-7/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: make write_data return voidPaolo Bonzini1-1/+1
The return value is unused anyway. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: Implement 'get_sense' callbackHannes Reinecke1-0/+2
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/+1
... 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>