History | View | Annotate | Download (39.5 kB)
scsi: pass down REQUEST SENSE to the device when there is no stored sense
This will let scsi-block/scsi-generic report progress on longoperations.
Reported-by: Thomas Schmitt <scdbackup@gmxbackup.net>Tested-by: Thomas Schmitt <scdbackup@gmxbackup.net>...
scsi: fix parsing of allocation length field
- several MMC commands were parsed wrong by QEMU because their allocationlength/parameter list length is placed in a non-standard position inthe CDB (i.e. it is different from most commands with the same value in...
scsi: update list of commands
Add more commands and their names, and remove SEEK which is obsolete.Instead, use SET_CAPACITY which is still in SSC.
Tested-by: Thomas Schmitt <scdbackup@gmx.net>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
scsi: fix fw path
The pre-1.0 firmware path for SCSI devices already included the LUNusing the suffix argument to add_boot_device_path. I missed that whenmaking channel and LUN customizable. Avoid that it is included twice, andconvert the colons to commas for consistency with other kinds of devices...
scsi: make reqops const
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>
scsi: pass cdb to alloc_req
This will let scsi-block choose between passthrough and emulation.
scsi: do not call transfer_data after canceling a request
Otherwise, if cancellation is "faked" by the AIO layer and goesthrough qemu_aio_flush, the whole request is completed synchronouslyduring scsi_req_cancel.
Using the enqueued flag would work here, but not in the next patches,...
scsi: push request restart to SCSIDevice
The request restart mechanism is generic and could be reused forscsi-generic. In the meanwhile, pushing it to SCSIDevice avoidsthat scsi_dma_restart_bh looks at SCSIGenericReqs when working ona scsi-block device....
scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)
scsi: remove devs array from SCSIBus
Change the devs array into a linked list, and add a scsi_device_findfunction to navigate the children list instead. This lets the SCSIbus use more complex addressing, and HBAs can talk to the correct devicewhen there are multiple LUNs per target....
scsi: implement REPORT LUNS for arbitrary LUNs
scsi: allow arbitrary LUNs
This only requires changes in two places: in SCSIBus, we need to lookfor a free LUN if somebody creates a device with a pre-existing scsi-idbut the default LUN (-1, meaning "search for a free spot"); in vSCSI,we need to actually parse the LUN according to the SCSI spec....
scsi: add channel to addressing
This also requires little more than adding the new argument toscsi_device_find, and the qdev property. All devices by defaultend up on channel 0.
atapi/scsi: unify definitions for MMC
The definitions in ide/internal.h are duplicates, since ATAPI commandsactually come from SCSI. Use the ones in scsi-defs.h and move themissing ones there. Two exceptions:
- MODE_PAGE_WRITE_PARMS conflicts with the "flexible disk geometry"...
scsi: notify the device when unit attention is reported
Reporting media change events via unit attention sense codes requiresa small state machine: first report "NO MEDIUM", then report "MEDIUM MAYHAVE CHANGED". Unfortunately there is no good hooking point for the...
scsi-disk: report media changed via unit attention sense codes
Building on the previous patch, this one adds a media change callbackto scsi-disk.
scsi: fix sign extension problems
When assigning a 32-bit value to cmd->xfer (which is 64-bits)it can be erroneously sign extended because the intermediate32-bit computation is signed. Fix this by standardizing onthe ld*_be_p functions.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
scsi-disk: Fix START_STOP to fail when it can't eject
Don't fail when tray is already open.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
scsi-bus: remove duplicate table entries
Remove duplicate entries from SCSI command table, spotted byclang analyzer:/src/qemu/hw/scsi-bus.c:979:40: warning: initializer overrides prior initialization of this subobject [ ERASE_16 ] = "ERASE_16",...
scsi: fill in additional sense length correctly
Even though we do not use them, we should include the last threebytes of sense data in the additional sense length.
scsi: refine constants for READ CAPACITY 16
Rename SERVICE_ACTION_IN to SERVICE_ACTION_IN_16 to distinguishfrom the 12-byte CDB variant, and add a constant for the subcommand.
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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.xferdirectly, and instead always cap it to a fixed length. This was not donefor REQUEST SENSE, and this patch fixes it....
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 <peter.maydell@linaro.org>Acked-by: Paolo Bonzini <pbonzini@redhat.com>...
scsi: add support for unit attention conditions
Unit attention conditions override any sense data the device alreadyhas. Their signaling and clearing is handled entirely by the SCSIBuscode, and they are completely transparent to the SCSIDevices.
scsi: report unit attention on reset
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi: add special traces for common commands
Can be useful when debugging the device scan phase.
scsi: move handling of REQUEST SENSE to common code
scsi: add a bunch more common sense codes
scsi: move handling of REPORT LUNS and invalid LUNs to common code
scsi: introduce SCSICommand
This struct is currently unnamed. Give it a name and use itexplicitly to decouple (some parts of) CDB parsing fromSCSIRequest.
scsi: push lun field to SCSIDevice
This will let SCSIBus detect requests sent to an invalid LUN, andhandle them itself. However, there will be still support for only oneLUN per target
scsi: move request parsing to common code
Also introduce the first occurrence of "independent" SCSIReqOps,to handle invalid commands in common code.
scsi: move request-related callbacks from SCSIDeviceInfo to SCSIReqOps
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 requeststhrough different reqops.
Moving the memcpy to scsi_req_new is a hack that will go away as...
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.
scsi: move sense handling to generic code
With this patch, sense data is stored in the generic data structuresfor SCSI devices and requests. The SCSI layer takes care of storingsense 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...
scsi: pass status when completing
A small improvement in the SCSI request API. Pass the statusat the time the request is completed, so that we can assert thatno request is completed twice. This would have detected theproblem fixed in the previous patch....
scsi-bus: use DO_UPCAST
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>
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 <hare@suse.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
scsi: Remove REZERO_UNIT emulation
REZERO_UNIT command is obsolete. Remove support for it.
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,...
scsi: Add 'hba_private' to SCSIRequest
'tag' is just an abstraction to identify the commandfrom the driver. So we should make that explicit byreplacing 'tag' with a driver-defined pointer 'hba_private'.This saves the lookup for driver handling several commands...
scsi: fix tracing of scsi requests with simple backend
The simple backend only supports a maximum of 6 arguments. Split thescsi_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>
scsi: split command_complete callback in two
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Cc: Christoph Hellwig <hch@lst.de>
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 errorwhich is actually a violation of the spec in certain cases....
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 <pbonzini@redhat.com>Reviewed-by: Christoph Hellwig <hch@lst.de>
scsi: introduce scsi_req_new
scsi: introduce scsi_req_continue
scsi: introduce scsi_req_get_buf
... and remove some SCSIDevice variables or fields that now become unused.
scsi: Implement 'get_sense' callback
The get_sense callback copies existing sense information intothe provided buffer. This is required if sense informationshould be transferred together with the command response.
Signed-off-by: Hannes Reinecke <hare@suse.de>...
scsi: reference-count requests
With the next patch, a device may hold SCSIRequest for an indefinitetime. 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...
scsi: Use 'SCSIRequest' directly
Currently the SCSIRequest structure is abstracted away and cannot accesseddirectly from the driver. This requires the handler to do a lookup onan abstract 'tag' which identifies the SCSIRequest structure.
With this patch the SCSIRequest structure is exposed to the driver. This...
scsi: commonize purging requests
The code for canceling requests upon reset is already the same. Cleanit up and move it to scsi-bus.c.
scsi: introduce scsi_req_abort
This covers the case of canceling a request's I/O and stillcompleting it.
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 devicesregister a second callback in SCSIBusOps.
scsi: add tracing of scsi requests
scsi: introduce scsi_req_data
This abstracts calling the command_complete callback, reducing churnin the following patches.
scsi: introduce SCSIBusOps
There are more operations than a SCSI bus can handle, besides completingcommands. One example, which this series will introduce, is cleaning upafter a request is cancelled.
More long term, a "SCSI bus" can represent the LUNs attached to a...
scsi: Allow scsi_bus_legacy_add_drive() to set removable bit
scsi-disk devices may wish to override the removable bit. Add supportfor a qdev property on SCSI devices. This is will be used by usb-msd.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
Add get_fw_dev_path callback to scsi bus.
Signed-off-by: Gleb Natapov <gleb@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
scsi: Move sense handling into the driver
The current sense handling in scsi-bus is only used by thescsi-disk driver; the scsi-generic driver is using its own.So we should move the current sense handling into thescsi-disk driver.
scsi: Increase the number of possible devices
The SCSI parallel interface has a limit of 8 devices, butnot the SCSI stack in general. So we should be removing thehard-coded limit and use MAX_SCSI_DEVS instead.And we only need to scan those devices which are allocated...
scsi_bus: fix length and xfer_mode for RESERVE and RELEASE commands
For the RESERVE and RELEASE commands the length must be zeroand xfer_mode must be SCSI_XFER_NONE.
Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Rearrange block headers
Changing block.h or blockdev.h resulted in recompiling most objects.
Move DriveInfo typedef and BlockInterfaceType enum definitionsto qemu-common.h and rearrange blockdev.h use to decrease churn.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
scsi: Dequeue requests before invoking completion callback
The request completion callback of the LSI controller may start the nextrequest that can use the same tag as the completed one. As the latter isstill enqueued at that point, scsi_send_command will complain about the...
scsi: Error locations for -drive if=scsi device initialization
qdev: Decouple qdev_prop_drive from DriveInfo
Make the property point to BlockDriverState, cutting out the DriveInfomiddleman. This prepares the ground for block devices that don't havea DriveInfo.
Currently all user-defined ones have a DriveInfo, because the only way...
block: Catch attempt to attach multiple devices to a blockdev
For instance, -device scsi-disk,drive=foo -device scsi-disk,drive=foohappily 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,...
scsi: scsi_bus_legacy_handle_cmdline() can fail, fix callers
None of its callers checks for failure. scsi_hot_add() can crashbecause of that:
(qemu) drive_add 4 if=scsi,format=host_device,file=/dev/sg1scsi-generic: scsi generic interface too oldSegmentation fault (core dumped)...
scsi-bus: Add PERSISTENT_RESERVE_OUT SCSIRequest->cmd.mode setup
This patch updates hw/scsi-bus.c to add the PERSISTENT_RESERVE_OUT cdbcase in scsi_req_xfer_mode() to set SCSI_XFER_TO_DEV for outgoing WRITE data.
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>...
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 inscsi_req_length() for TYPE_ROM with MMC commands. It also adds the MAINTENANCE_OUTcase in scsi_req_xfer_mode() to set SCSI_XFER_TO_DEV for outgoing write data....
blockdev: Collect block device code in new blockdev.c
Anything that moves hundreds of lines out of vl.c can't be all bad.
error: Replace qemu_error() by error_report()
error_report() terminates the message with a newline. Strip it itfrom its arguments.
This fixes a few error messages lacking a newline:net_handle_fd_param()'s "No file descriptor named %s found", andtap_open()'s "vnet_hdr=1 requested, but no kernel support for...
error: Move qemu_error & friends into their own header
scsi: fix Sparse warning: Initializer entry defined twice
Both REWIND and REZERO_UNIT use 0x01, READ_POSITION and PRE_FETCHshare 0x34.
scsi-disk: restruct emulation: GET_CONFIGURATION
Move GET_CONFIGURATION emulation from scsi_send_command() toscsi_disk_emulate_command().
Also add GET_CONFIGURATION to scsi-defs.h and scsi_command_name().
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>...
scsi-disk: restruct emulation: SERVICE_ACTION_IN
Move SERVICE_ACTION_IN emulation from scsi_send_command() toscsi_disk_emulate_command().
Also add SERVICE_ACTION_IN to scsi-defs.h and scsi_command_name().
scsi-disk: restruct emulation: REPORT_LUNS
Move REPORT_LUNS emulation from scsi_send_command() toscsi_disk_emulate_command().
Also add REPORT_LUNS to scsi-defs.h and scsi_command_name().
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi: add read/write 16 commands.
Add READ_16 + friends to scsi-defs.h, scsi_command_name() and therequest parsing helper functions.
Use them in scsi-disk.c too.
scsi: add scsi_req_print()
Handy for debugging.
scsi: add xfer mode
scsi: move sense to SCSIDevice, create SCSISense struct.
scsi: move status to SCSIRequest.
Also add and use the scsi_req_complete() helper function for calling thecompletion callback.
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....
scsi: move SCSIRequest management to common code.
Create generic functions to allocate, find and release SCSIRequeststructs. Make scsi-disk and scsi-generic use them.
scsi: add request parsing helpers to common code.
Add helper functions for scsi request parsing to common code. Gettingcommand length, transfer size, and linear block address is handled.
scsi: move scsi-disk.h -> scsi.h
Check return value of qdev_init()
But do so only where it may actually fail. Leave the rest for thenext commit.
Patchworks-ID: 35167Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi: hotplug windup
Implement scsi device destruction
switch scsi bus to inplace allocation.
qdev/scsi: add scsi bus support to qdev, convert drivers.
Adding scsi disks via -device works now, i.e. you can do:
-drive id=sda,if=none,......