History | View | Annotate | Download (60.4 kB)
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.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: remove useless debug messages
Optional inquiry information is declared obsolete in the latest versionsof the standard; invalid CDBs or unsupported VPD pages are supportedcan be diagnosed with trace_scsi_inquiry.
scsi-disk: add dpofua property
Linux expects REQ_FUA to be advertised only if WRITE+FUA is faster thanWRITE+SYNCHRONIZE CACHE, so we should not set the DPOFUA bit. However,it is useful to have it for testing purposes, so add a qdev property toset it....
scsi: change "removable" field to host many features
It is pointless to add a uint32_t field for every new feature.Since we will need a new feature soon, convert accesses to "removable" to look at bit 0 only.
scsi: fix refcounting for reads
Recently introduced FUA support also gave us a use-after-freeof the BlockAcctCookie within a SCSIDiskReq, due to unbalancedreference counting.
The patch fixes this by making scsi_do_read look like a combinationof scsi_*_complete + scsi_*_data. It does both a ref (like...
scsi: fix WRITE SAME transfer length and direction
SCSI emulation: should tell the guest that we actually support thin provisioning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>[Actually, we should report it only if discard_granularity is nonzero. Older SBC drafts assigned 0 to thin provisioning and 1 to thick...
scsi: add a started field to SCSIDiskReq
scsi: support FUA on reads
To force unit access on reads, flush the cache before doing the read.
scsi: small refactoring of MMC mode-sense
Make DBD a boolean value, and force device-specific parameter to zero.
scsi: advertise DPOFUA
SCSI emulation: Support unmap via WRITE_SAME_10.
This was added in SBC r26 in place of the reserved bits that werepresent up to that version.
It is the same as WRITE_SAME_16 as far as QEMU is concerned.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>...
scsi: force unit access on VERIFY
Also DMA data from the host, to avoid that the host reports anunderrun.
scsi: make code more homogeneous in AIO callback functions
First scsi_flush_complete, like scsi_dma_complete, is always called withan active AIOCB.
Second, always test for "ret < 0" to check for errors.
scsi: move scsi_flush_complete around
scsi: add support for FUA on writes
To force unit access, add a flush operation after the actual write.WRITE AND VERIFY commands always flush according to SBC, so do iteven though we do not perform the reread.
scsi: add missing test for cancelled request
scsi-cd: check ready condition before processing several commands
This commit is more or less obvious. What it caused is less obvious:SCSI CD drives failed to eject under Linux, though for example the"change" command worked okay. This happens because of the autoclose...
scsi: copy serial number into VPD page 0x83
Currently QEMU passes the qdev device id to the guest in an ASCII-stringdesignator in page 0x83. While this is fine, it does not match whatreal hardware does; usually the ASCII-string designator there hostsanother copy of the serial number (there can be other designators,...
Merge remote-tracking branch 'qmp/queue/qmp' into staging
scsi-block: always use scsi_generic_ops for cache != none
block: Don't call bdrv_eject() if the tray state didn't change
It's not needed. Besides we can then assume that bdrv_eject() isonly called when there's a tray state change, which is useful tothe DEVICE_TRAY_MOVED event (going to be added in a futurecommit)....
block: Rename bdrv_mon_event() & BlockMonEventAction
They are QMP events, not monitor events. Rename them accordingly.
Also, move bdrv_emit_qmp_error_event() up in the file. A new event willbe added soon and it's good to have them next each other.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>...
scsi-disk: enable scatter/gather functionality
scsi-disk: add migration support
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...
scsi: convert to QEMU Object Model
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi: Guard against buflen exceeding req->cmd.xfer in scsi_disk_emulate_command
Limit the return value (corresponding to the length of the buffer to beDMAed back to the intiator) to the value in req->cmd.xfer, which is theamount of data that the initiator expects. Eliminate now-duplicate code...
scsi virtio-blk usb-msd: Clean up device init error messages
Replace
error_report("DEVICE-NAME: MESSAGE");
by just
error_report("MESSAGE");
in block device init functions.
DEVICE-NAME is bogus in some cases: it's "scsi-disk" for devicescsi-hd and scsi-cd, "virtio-blk-pci" for virtio-blk-s390, and...
block: bdrv_aio_* do not return NULL
Initially done with the following semantic patch:
rule1 expression E;statement S;@@ E =( bdrv_aio_readv | bdrv_aio_writev | bdrv_aio_flush | bdrv_aio_discard | bdrv_aio_ioctl) (...);(- if (E == NULL) { ... }...
rule1
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.
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: Remove REZERO_UNIT emulation
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>
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.