History | View | Annotate | Download (74.2 kB)
scsi: do not return short responses for emulated commands
The inquiry command, for the case of VPD=1, was returning shortresponses; the number of returned bytes was just the number of bytesin the request, without padding to the specified allocation length...
scsi: remove superfluous call to scsi_device_set_ua
Suggested by Laszlo Ersek.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi-disk: flush cache after disabling it
SBC says that "if an application client changes the WCE bit from one tozero via a MODE SELECT command, then the device server shall writeany data in volatile cache to non-volatile medium before completingthe command"....
cleanup useless return sentence
This patch cleans up return sentences in the end of void functions.
Reported-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Amos Kong <akong@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
iostatus: change is_read to a bool
Do this while we are touching this part of the code, before introducingmore uses of "int is_read".
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
iostatus: reorganize io error code
Move the common part of IDE/SCSI/virtio error handling to the blocklayer. The new function bdrv_error_action subsumes all three ofbdrv_emit_qmp_error_event, vm_stop, bdrv_iostatus_set_err.
The same scheme will be used for errors in block jobs....
iostatus: move BlockdevOnError declaration to QAPI
This will let block-stream reuse the enum. Places that used the enumsare renamed accordingly.
iostatus: rename BlockErrorAction, BlockQMPEventAction
We want to remove knowledge of BLOCK_ERR_STOP_ENOSPC from drivers;drivers should only be told whether to stop/report/ignore the error.On the other hand, we want to keep using the nicer BlockErrorAction...
scsi-disk: use scsi_data_cdb_length
This simplifies and unifies the parsing of READ, WRITE and WRITE SAMEcommands.
SCSI: Standard INQUIRY data should report HiSup flag as set.
QEMU as far as I know only reports LUN numbers using the modes thatare described in SAM4.As such, since all LUN numbers generated by the SCSI emulation in QEMUfollow SAM4, we should set the HiSup bit in the standard INQUIRY data...
scsi-disk: introduce check_lba_range
Abstract the test for an out-of-range (starting block, block count)pair.
scsi-disk: fix check for out-of-range LBA
This fix is needed to correctly handle 0-block read and writes.Without it, a 0-block access at LBA 0 would underflow.
scsi-disk: Fix typo (uint32 -> uint32_t)
Cc: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi: more fixes to properties for passthrough devices
Commit 0384783 (scsi-block: remove properties that are not relevant forpassthrough, 2012-07-09) removed one property that should have beenleft there, "bootindex".
It also did not touch scsi-generic, while it should have....
Merge remote-tracking branch 'bonzini/scsi-next' into staging
scsi-disk: more assertions and resets for aiocb
Leaving the aiocb to a non-NULL value leads to an assertion failure whenrerror/werror are set to stop or enospc, and the operation is retried.scsi-disk checks that the aiocb member is NULL before filling it....
scsi-disk: improve out-of-range LBA detection for WRITE SAME
scsi-disk: add support for the UNMAP command
The unmap command can reuse the same infrastructure as MODE SELECTfor reading the descriptor list into memory. The descriptors areprocessed sequentially.
ide scsi: Mess with geometry only for hard disk devices
Legacy -drive cyls=... are now ignored completely when the drivedoesn't back a hard disk device. Before, they were first checkedagainst a hard disk's limits, then ignored.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
The START STOP UNIT command will only eject/load media ifpower condition is zero.
If power condition is !0 then LOEJ and START will be ignored.
From MMC (sbc contains similar wordings too)...
scsi-disk: fix compilation with DEBUG_SCSI
Reported-by: Gerhard Wiesinger <lists@wiesinger.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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: 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-disk: removable hard disks support load/eject
Support for the LOEJ bit of the START/STOP UNIT command right now islimited to CD-ROMs. This is wrong, since removable hard disks (in thereal world: SD card readers) also support it in pretty much the same way....
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: fix changeable values for MODE_PAGE_R_W_ERROR
The changeable values were not all-zeros for this mode page, fix it.
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-disk: support toggling the write cache
Finally, this uses the "plumbing" in the previous patch toadd support for toggling the WCE bit of the caching mode page.
scsi-disk: rd/wr/vr-protect !=0 is an error
The QEMU SCSI emulation does not support protection information,so any READ/WRITE/VERIFY commands that has the protect bits set tonon-zero should fail with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB
From SCSI SBC :...
scsi-disk: improve the lba-out-of-range tests for read/write/verify
Improve the tests for the LBA to cover more cases.
For the 16 byte opcodes, the lba is a uint64, so we need to check is tomake sure that we do not wrap. For example if an opcode would specify...
scsi-disk: let the user customize vendor and product name
This patch adds two new properties vendor and product to SCSI disks.These options let the user customize the inquiry data returned by thedisk.
Signed-off-by: Yan Vugenfirer <yan@ravellosystems.com>...
scsi-disk: make discard asynchronous
By making discard asynchronous, we can reuse all the error handlingcode that is used for other commands.
scsi-disk: move all non-DMA commands to scsi_disk_emulate_command
We want to use separate SCSIReqOps for emulated commands needing anallocated buffer vs. those that are zerocopy when the HBA supportsS/G lists. Ensure that all of the former are in scsi_disk_emulate_command....
scsi-disk: split scsi-disk reqops
Only checks for present medium were still done in scsi_send_commandfor emulated commands. So move those to scsi_disk_emulate_commandand return different SCSIReqOps depending on the kind of command.
Checks for present medium can be done unconditionally for the...
scsi-disk: separate read_data/write_data implementation for emulate_reqops
The previous patch only separated the send_command callback.Use different implementations also for read_data and write_data.The latter is still unreachable, so it aborts for now....
scsi-disk: support emulated TO_DEV requests
This adds the implementation of write_data for the emulatedcommand case. The first time through it asks for more data,the second time it finishes the processing of the command.
MODE SELECT and MODE SELECT can now be re-enabled, but they...
scsi-disk: adjust offsets in MODE SENSE by 2
This will make offsets the same when implementing MODE SELECT. This isbecause MODE SELECT has to deal with both 2-byte and 4-byte headers.Unfortunately, this means that the offsets are now off by two compared...
scsi-block: remove properties that are not relevant for passthrough
scsi-block is a passthrough device and does not allow customizationof vendor, product, removable, DPOFUA, block size or any other piece ofinformation. Thus, drop DEFINE_SCSI_DISK_PROPERTIES() from the...
hw/block-common: Factor out fall back to legacy -drive serial=...
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block-common: Factor out fall back to legacy -drive cyls=...
hd-geometry: Move disk geometry guessing back from block.c
Commit f3d54fc4 factored it out of hw/ide.c for reuse. Sensible,except it was put into block.c. Device-specific functionality shouldbe kept in device code, not the block layer. Move it tohw/hd-geometry.c, and make stylistic changes required to keep...
hd-geometry: Cut out block layer translation middleman
hd_geometry_guess() picks geometry and translation. Callers can getthe geometry directly, via parameters, but for translation they needto go through the block layer.
Add a parameter for translation, so it can optionally be gotten just...
hd-geometry: Switch to uint32_t to match BlockConf
Best to use the same type, to avoid unwanted truncation or signextension.
BlockConf can't use plain int for cyls, heads and secs, becauseinteger properties require an exact width.
scsi-hd: qdev properties for disk geometry
Geometry needs to be qdev properties, because it belongs to thedisk's guest part.
Maintain backward compatibility exactly like for serial: fall back toDriveInfo's geometry, set with -drive cyls=...
Do this only for scsi-hd. scsi-disk is legacy. scsi-cd doesn't have...
scsi: add a qdev property for the disk's WWN
scsi-disk: implement READ DISC INFORMATION
This command is not necessary for CD-ROM and DVD-ROM, but some versions ofudev trip on its absence.
Cc: Kevin Wolf <kwolf@redhat.com>Cc: Markus Armbruster <armbru@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: simplify handling of the VPD page length field
The last four bytes of the thin provisioning page were cut out.
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...
scsi-disk: Don't peek behind the BlockDriverState abstraction
Use the appropriate interface instead.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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: 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: 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.
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: 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.