History | View | Annotate | Download (53.9 kB)
scsi-block: always use SG_IO for MMC devices
CD burning messes up the state of the host page cache and host blockdevice. Just pass all operations down to the device, even though thatmight have slightly worse performance. Everything else just is notreliable in combination with burning....
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: remove block descriptors from CDs
Reported-by: Thomas Schmitt <scdbackup@gmx.net>Tested-by: Thomas Schmitt <scdbackup@gmx.net>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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-disk: guess geometry
Old operating systems rely on correct geometry to convert from CHSaddresses to LBA. Providing correct data is necessary for them to boot.
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-disk: implement eject requests
scsi-disk: do not duplicate BlockDriverState member
Same as for scsi-generic, avoid duplication even if it causes longerlines.
scsi-disk: remove cluster_size
This field is redundant, and having it makes it more complicatedto share reqops between the upcoming scsi-block and scsi-generic.
scsi-disk: small clean up to INQUIRY
Set s->removable, s->qdev.blocksize and s->qdev.type in the callersof scsi_initfn.
With this in place, s->qdev.type is allowed, and we can just reuse itas the first byte in VPD data (just like we do in standard INQUIRY data)....
scsi: move max_lba to SCSIDevice
The field is only in scsi-disk for now. Moving it up to SCSIDevice makesit easier to reuse the scsi-generic reqops elsewhere.
At the same time, make scsi-generic get max_lba from snooped READ CAPACITYcommands as well....
scsi: make reqops const
Also delete a stale occurrence of SCSIReqOps inside SCSIDeviceInfo.
scsi: pass cdb to alloc_req
This will let scsi-block choose between passthrough and emulation.
scsi-disk: bump SCSIRequest reference count until aio completion runs
In some cases a request may be canceled before the completion callbackruns. Keep a reference to the request between starting an AIO operationand the corresponding scsi_req_cancel or scsi_*_complete....
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-disk: add scsi-block for device passthrough
scsi-block is a new device that supports device passthrough of Linuxblock devices (i.e. /dev/sda, not /dev/sg0). It uses SG_IO for commandsother than I/O commands, and regular AIO read/writes for I/O commands....
scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION
This adds support for media change notification via the GET EVENT STATUSNOTIFICATION command, used by Linux versions 2.6.38 and newer.
scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)
scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0
Tested by the Windows Logo Kit SCSI Compliance test. From SBC-3, paragraph5.25: "The LOGICAL BLOCK ADDRESS field shall be set to zero if the PMIbit is set to zero. If the PMI bit is set to zero and the LOGICAL BLOCK...
scsi-disk: fix retrying a flush
Flush does not go anymore through scsi_disk_emulate_command.
scsi: pass correct sense code for ENOMEDIUM
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-disk: report media changed via unit attention sense codes
Building on the previous patch, this one adds a media change callbackto scsi-disk.
scsi-disk: fix coding style issues (braces)
scsi-disk: add stubs for more MMC commands
This patch adds a few stub implementations for MMC commands toscsi-disk, to be filled in later in the series. It also adds toscsi-defs.h constants for commands implemented by ide/atapi.c,when missing.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
scsi-disk: store valid mode pages in a table
A small refactoring of the MODE SENSE implementation in scsi-disk.
atapi/scsi-disk: make mode page values coherent between the two
This patch adds to scsi-disk the missing mode page 0x01 for both diskand CD-ROM drives, and mode page 0x0e for CD drives only.
A few offsets were wrong in atapi.c. Also change the 2Ah mode page to...
scsi-disk: support DVD profile in GET CONFIGURATION
scsi-disk: support READ DVD STRUCTURE
scsi: Support I/O status
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
RunState: Rename enum values as generated by the QAPI
Next commit will convert the query-status command to use theRunState type as generated by the QAPI.
In order to "transparently" replace the current enum by the QAPIone, we have to make some changes to some enum values....
Merge remote-tracking branch 'kwolf/for-anthony' into staging
scsi-disk: commonize iovec creation between reads and writes
Also, consistently use qiov.size instead of iov.iov_len.
scsi-disk: lazily allocate bounce buffer
It will not be needed for reads and writes if the HBA provides a sglist.In addition, this lets scsi-disk refuse commands with an excessiveallocation length, as well as limit memory on usual well-behaved guests....
Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),we pass a VMSTOP macro as the 'reason' argument. This is not idealbecause the VMSTOP macros tell why qemu stopped and not exactlywhat the current VM state is....
block: New bdrv_set_buffer_alignment()
Device models should be able to set it without an unclean include ofblock_int.h.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: New change_media_cb() parameter load
To let device models distinguish between eject and load.
ide/atapi scsi-disk: Make monitor eject -f, then change work
change fails while the tray is locked by the guest. eject -f forcesit open and removes any media. Unfortunately, the tray closes againinstantly. Since the lock remains as it is, there is no way to insert...
scsi-disk: Fix START_STOP to fail when it can't eject
Don't fail when tray is already open.
block: Clean up remaining users of "removable"
BlockDriverState member removable is a confused mess. It is true whenan ide-cd, scsi-cd or floppy qdev is attached, or when theBlockDriverState was created with -drive if={floppy,sd} or -driveif={ide,scsi,xen,none},media=cdrom ("created removable"), except when...
block: Drop BlockDriverState member removable
It's a confused mess (see previous commit). No users remain.
block: Show whether the virtual tray is open in info block
Need to ask the device, so this requires new BlockDevOps memberis_tray_open().
block: Move BlockConf & friends from block_int.h to block.h
It's convenience stuff for block device models, so block.h isn't theideal 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>...
scsi-disk: Factor out scsi_disk_emulate_start_stop()
scsi-disk: Track tray open/close state
We already track it in BlockDriverState since commit 4be9762a. Asdiscussed in that commit's message, we should track it in the devicedevice models instead, because it's device state.
block: Revert entanglement of bdrv_is_inserted() with tray status
Commit 4be9762a changed bdrv_is_inserted() to fail when the tray isopen. Unfortunately, there are two different kinds of users, withconflicting needs.
1. Device models using bdrv_eject(), currently ide-cd and scsi-cd....
scsi-disk: Track tray locked state
We already track it in BlockDriverState. Just like tray open/closestate, we should track it in the device models instead, because it'sdevice state.
block: Leave enforcing tray lock to device models
The device model knows best when to accept the guest's eject command.No need to detour through the block layer.
bdrv_eject() can't fail anymore. Make it void.
block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked(). Implement for IDEand SCSI CD-ROMs.
block: Rename bdrv_set_locked() to bdrv_lock_medium()
While there, make the locked parameter bool.
scsi: improve MODE SENSE emulation
- do not return extra pages when requesting all pages (PAGE CODE = 0x3f)
- return correct sense code for PC = 3 (saved parameters not supported)
- do not return geometry pages for CD devices
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.
scsi: fix accounting of writes
Writes go through scsi_write_complete at least twice, the first timeto get some data without having actually written anything. Becauseof this, the first time scsi_write_complete is called it will callbdrv_acct_done and account a read incorrectly. Fix this by looking...
scsi: execute SYNCHRONIZE_CACHE asynchronously
block: explicit I/O accounting
Decouple the I/O accounting from bdrv_aio_readv/writev/flush andmake the hardware models call directly into the accounting helpers.
This means: - we do not count internal requests from image formats in addition to guest originating I/O...
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-disk: fix DPRINTF
The variable 'status' does not exist anymore, adjust DPRINTFaccordingly.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
scsi: report unit attention on reset
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi: move handling of REQUEST SENSE to common code
scsi: move handling of REPORT LUNS and invalid LUNs to common code
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: 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-disk: no need to call scsi_req_data on a short read
In fact, if the HBA's transfer_data callback goes on with scsi_req_continuethe request will be completed successfully instead of showing a failure.It can even cause a segmentation fault.
An easy way to trigger it is "eject -f cd" during installation (during media...
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-disk: Codingstyle fixes
Replace tabs with spaces.
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-disk: Remove 'drive_kind'
Instead of using its own definitions scsi-disk shouldbe using the device type of the parent device.
Correct spelling of licensed
Correct typos of "licenced" to "licensed".
Reviewed-by: Stefan Weil <weil@mail.berlios.de>Reviewed-by: Andreas F=E4rber <andreas.faerber@web.de>Signed-off-by: Matthew Fernandez <matthew.fernandez@gmail.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi-disk: Fixup debugging statement
A debugging statement wasn't converted to the new interface.
Signed-off-by: Hannes Reinecke <hare@suse.de>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
scsi-disk: Mask out serial number EVPD
If the serial number is not set we should mask it out in thelist of supported VPD pages and mark it as not supported.
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: make write_data return void
The return value is unused anyway.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Christoph Hellwig <hch@lst.de>
scsi: ignore LUN field in the CDB
The LUN field in the CDB is a historical relic. Ignore it as reserved,which is what modern SCSI specifications actually say.
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.
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-disk: add data direction checking
scsi_req_parse() already provides for a data direction setting,so we should be using it to check for correct direction.And we should return the sense code 'INVALID FIELD IN CDB'in these cases.
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_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: introduce scsi_req_data
This abstracts calling the command_complete callback, reducing churnin the following patches.
blockdev: Store -drive option media in DriveInfo
DriveInfo is closely tied to -drive, and like -drive, it mixesinformation about host and guest part of the block device. UnlikeDriveInfo, BlockDriverState should be about the host part only.
One of the remaining guest bits there is the "type hint". -drive...
scsi: Split qdev "scsi-disk" into "scsi-hd" and "scsi-cd"
A "scsi-disk" is either a hard disk or a CD-ROM, depending on theassociated BlockDriverState's type hint. Unclean; disk vs. CD belongsto the guest part, not the host part.
Have separate qdevs "scsi-hd" and "scsi-cd" to model disk vs. CD in...
Improve vm_stop reason declarations
Define and use dedicated constants for vm_stop reasons, they actuallyhave nothing to do with the EXCP_* defines used so far. At this chance,specify more detailed reasons so that VM state change handlers canevaluate them....
scsi-disk: Allow overriding SCSI INQUIRY removable bit
Provide the "removable" qdev property bit to override the SCSI INQUIRYremovable (RMB) bit for non-CDROM devices. This will be used by USBMass Storage Devices, which sometimes have this guest-visible bit set...
scsi-disk: support WRITE SAME (16) with unmap bit
Support discards via the WRITE SAME command with the unmap bit set, andtell the initiator about the support for it via the block limit and thenew thin provisioning EVPD pages. Also fix the comment which incorrectly...
Add bootindex parameter to net/block/fd device
If bootindex is specified on command line a string that describes devicein firmware readable way is added into sorted list. Later this list willbe passed into firmware to control boot order.
Signed-off-by: Gleb Natapov <gleb@redhat.com>...
Introduce fw_name field to DeviceInfo structure.
Add "fw_name" to DeviceInfo to use in device path building. Incontrast to "name" "fw_name" should refer to functionality deviceprovides instead of particular device model like "name" does.
scsi-disk: Remove duplicate cdb parsing
We parse the CDB twice, which is completely unnecessary.
Signed-off-by: Hannes Reinecke <hare@suse.de>Acked-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Kevin Wolf <kwolf@redhat.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: INQUIRY VPD fixes
We should announce and support the block device characterics pageonly on block devices, not on CDROMs. And the VPD page 0x83 hasan off-by-one error.
Signed-off-by: Hannes Reinecke <hare@suse.de>Acked-by: Christoph Hellwig <hch@lst.de>...
scsi-disk: Move active request asserts
SCSI read/write requests should not be re-issued before the currentfragment of I/O completes. There are asserts in scsi-disk.c that guardthis constraint but they trigger on SPARC Linux 2.4. It turns out thatthe asserts are too early in the code path and don't allow for read...
scsi-disk: Fix immediate failure of bdrv_aio_*
Fix scsi-disk to use the usual completion paths that involve rerror/werrorhandling instead of directly completing the requests in cases wherebdrv_aio_readv/writev returns NULL.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
scsi-disk: Implement rerror option
This implements the rerror option for SCSI disks.
It also includes minor changes to the write path where the same code is usedthat was criticized in the review for the changes to the read path required forrerror support....
scsi-disk: Complete failed requests in scsi_disk_emulate_command
This pulls the request completion for error cases from the caller toscsi_disk_emulate_command. This should not change semantics, but allows toreuse scsi_handle_write_error() for flushes in the next patch....
scsi-disk: Implement werror for flushes
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>