History | View | Annotate | Download (52.8 kB)
scsi, pci, qdev, isa-bus, sysbus: don't let *_get_fw_dev_path return NULL
Use g_strdup rather than strdup, because the sole caller(qdev_get_fw_dev_path_helper) assumes it gets non-NULL, and dereferencesit. Besides, in that caller, the allocated buffer is already freed with...
scsi: introduce scsi_cdb_length and scsi_data_cdb_length
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: fix warning
hw/scsi-bus.c:758: warning: ‘xfer’ may be used uninitialized in thisfunction
Isn't true, but older gcc versions (for example 4.1 as shipped in rhel5)are not clever enougth to figure, so sprinkle in a default: line to makethem happy....
scsi-bus: remove overlapping entry
LOAD_UNLOAD and START_STOP have same value, so the tableentry is initialized twice. Spotted by Clang compiler.
Remove LOAD_UNLOAD entry since START_STOP entry alreadyrepresents both.
Reviewed-by: Markus Armbruster <armbru@redhat.com>...
scsi: add support for ATA_PASSTHROUGH_xx scsi command
Correct the command names of opcode 0x85 and 0xa1, and calculatetheir xfer size from CDB.
Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
SCSI: Update the sense code for PREVENT REMOVAL errors
Change the sense codes for failures to eject a device that is lockedby PREVENT_ALLOW_MEDIUM_REMOVAL fromthe generic MEDIA_LOAD_OR_EJECT_FAILED to the more specificMEDIUM_REMOVAL_PREVENTED.
The second sense code is more accurate, and is also listed in MMC annex F...
scsi-disk: report resized disk via sense codes
Linux will not use these, but a very similar mechanism will be used toreport the condition via virtio-scsi events.
scsi: report parameter changes to HBA drivers
scsi: introduce hotplug() and hot_unplug() interfaces for SCSI bus
Add two interfaces hotplug() and hot_unplug() to scsi bus info.The scsi bus can implement these two interfaces to signal the HBA driverof guest kernel to add/remove the scsi device in question....
scsi: establish precedence levels for unit attention
When a device is resized, we will report a unit attention conditionfor CAPACITY DATA HAS CHANGED. However, we should ensure that thiscondition does not override a more important unit attention condition....
scsi: add tracepoint for scsi_req_cancel
scsi-disk: Fail medium writes with proper sense for readonly LUNs
Add sense code for DATA_PROTECT/WRITE_PROTECTED and return this errorfor any WRITE*/WRITE_VERIFY* calls if the device is readonly=on,i.e. write-protected
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>...
scsi-disk: parse MODE SELECT commands and parameters
This adds the bulk of the parsing code for MODE SELECT, includingbreaking out changes to different mode pages, and checking that onlychangeable values are modified.
In order to report errors correctly two passes are made through the...
scsi: add free_request callback
Most device models have a simple lifecycle for the hba_private fieldand they can free it when a request is completed or cancelled.However, in some cases it may be simpler to tie the lifetimeof hba_private to that of the included SCSIRequest. This patch...
scsi: Fix data length == SCSI_SENSE_BUF_SIZE
Fix the edge case where the sense data length is exactly the sameas SCSI_SENSE_BUF_SIZE.This makes SCSI requests work that use all of the available 95 bytesense data.
Signed-off-by: Christian Hoff <christian.hoff@de.ibm.com>...
scsi: Fix LOAD_UNLOAD
Change operation code of LOAD_UNLOAD command to 0x1b as described insection 7.3 of the SCSI Stream Commands spec.
Signed-off-by: Christian Hoff <christian.hoff@de.ibm.com>Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>...
scsi: Ensure command and transfer lengths are set for all SCSI devices
scsi-generic relies on those values to be correct, so it is important thatthose values are initialized properly for all device types.
Reported-by: Christian Hoff <christian.hoff@de.ibm.com>...
scsi: Add basic support for SCSI media changer commands.
This adds basic support for SCSI media changer commands.Not all commands are supported as of now, but enough to coverbasic functionality.
scsi: Fix transfer length for READ POSITION commands.
The transfer length depends on the specific service actioncode, as defined in the SCSI stream commands spec section 7.7.Up to now only the extended form was supported.
Allow machines to configure the QEMU_VERSION that's exposed via hardware
QEMU exposes its version to the guest's hardware and in some cases that is wrong(e.g. Windows prints messages about driver updates when you switchthe QEMU version).There is a new field now on the struct QEmuMachine, hw_version, which may...
qdev: Use wrapper for qdev_get_path
This makes it easier to remove it from BusInfo.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>[AF: Drop now unnecessary NULL initialization in scsibus_get_dev_path()]...
qdev: Convert busses to QEMU Object Model
This is far less interesting than it sounds. We simply add an Object to eachBusState and then register the types appropriately. Most of the interestingrefactoring will follow in the next patches.
Since we're changing fundamental type names (BusInfo -> BusClass), it all needs...
qbus: Make child devices links
Make qbus children show up as link<> properties. There is no stableaddressing for qbus children so we use an unstable naming convention.
This is okay in QOM though because the composition name is expected tobe what's stable....
qdev: Remove qdev_prop_exists()
Can be replaced everywhere with object_property_find().
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
qom: Push error reporting to object_property_find()
Avoids duplicated error_set().
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>[AF: Also drop error_set() in object_property_del().]Signed-off-by: Andreas Färber <afaerber@suse.de>
qdev: Move bus properties to a separate global
Simple code movement in order to simplify future refactoring.
qdev: Move bus properties to abstract superclasses
In qdev, each bus in practice identified an abstract superclass, butthis was mostly hidden. In QOM, instead, these abstract classes areexplicit so we can move bus properties there.
All bus property walks are removed, and all device property walks...
scsi: prepare migration code for usb-storage support
usb-storage can't handle requests in one go as the data transfer can besplitted into lots of usb packets. Because of that there can benormal in-flight requests at savevm time and we need to handle that....
scsi: declare vmstate_info_scsi_requests to be static
Signed-off-by: Jim Meyering <meyering@redhat.com>
scsi: parse 16-byte tape CDBs
The transfer length for these commands is different from the transferlength of the corresponding disk commands, so parse it specially.
scsi: do not require a minimum allocation length for INQUIRY
The requirements on the INQUIRY buffer size are not in my copy of SPC(SPC-4 r27) and not observed by LIO. Rip them out.
scsi: do not require a minimum allocation length for REQUEST SENSE
The requirements on the REQUEST SENSE buffer size are not in my copy of SPC(SPC-4 r27) and not observed by LIO. Rip them out.
scsi: set VALID bit to 0 in fixed format sense data
The INFORMATION field (bytes 3..6) is never set by QEMU, so the VALIDbit must be 0.
scsi: Add assertion for use-after-free errors
The QEMU emulation which is currently used with Raspberry PI images(qemu-system-arm -M versatilepb ...) accesses memory which was freed.
Valgrind output (extract):
scsi: do not report bogus overruns for commands in the 0x00-0x1F range
Interpreting cdb4 == 0 as a request to transfer 256 blocks is onlyneeded for READ_6 and WRITE_6. No other command in that range needsthat special-casing, and the resulting overrun breaks scsi-testsuite's...
scsi: fix WRITE SAME transfer length and direction
scsi: Specify the xfer direction for UNMAP and ATA_PASSTHROUGH commands
scsi_cmd_xfer_mode() is used to specify the xfer direction for SCSIcommands that come in from the guest. If the direction is set incorrectlythis will eventually cause QEMU to kernel-panic the guest....
scsi: prevent data transfer overflow
Avoid sending more than 2GB of data, as that can cause overflowsin int32_t variables.
scsi: add SANITIZE command
scsi: fix memory leak
scsibus_get_dev_path is leaking id if it is not NULL. Fix it.
Reported-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: add get_dev_path
scsi: fix wrong return for target INQUIRY
scsi: fix searching for an empty id
The conditions for detecting no free target or LUN were wrong.
The LUN loop was followed by an "if" condition that is nevertrue, because the loop is exited as soon as lun becomes equalto bus->info->max_lun, and never becomes greater than it....
scsi: add scatter/gather functionality
Scatter/gather functionality uses the newly added DMA helpers. Thedevice can choose between doing DMA itself, or calling scsi_req_dataas usual, which will use the newly added DMA helpers to copy piecewiseto/from the destination area(s)....
scsi-disk: enable scatter/gather functionality
scsi: add SCSIDevice vmstate definitions
scsi: pass residual amount to command_complete
With the upcoming sglist support, HBAs will not see any transfer_datacall and will not have a way to detect short transfers. So pass theresidual amount of data upon command completion.
qom: Unify type registration
Replace device_init() with generalized type_init().
While at it, unify naming convention: type_init([$prefix_]register_types)Also, type_init() is a function, so add preceding blank line wherenecessary and don't put a semicolon after the closing brace....
qdev: register all types natively through QEMU Object Model
This was done in a mostly automated fashion. I did it in three steps and thenrebased it into a single step which avoids repeatedly touching every file inthe tree.
The first step was a sed-based addition of the parent type to the subclass...
qdev: kill off DeviceInfo
It is no longer used in the tree since everything is done natively throughQEMU Object Model.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi: convert to QEMU Object Model
usb-msd: do not register twice in the boot order
USB mass storage devices are registered twice in the boot order.To avoid having to keep the two paths in sync, pass the bootindexproperty down to the scsi-disk device and let it register itself.
Signed-off-by: Paolo Bonzini <pbonzini@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. Avoid that it isincluded twice, and convert the colons to commas for consistency withother kinds of devices
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>
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.
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.
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: introduce scsi_req_get_buf
... 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>
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>...