summary refs log tree commit diff stats
path: root/hw/scsi-disk.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* scsi: prepare migration code for usb-storage supportGerd Hoffmann2012-06-071-2/+14
| | | | | | | | | | | | | | | | | usb-storage can't handle requests in one go as the data transfer can be splitted into lots of usb packets. Because of that there can be normal in-flight requests at savevm time and we need to handle that. With other scsi hba's this happens only in case i/o is stopped due to errors and there are pending requests which need to be restarted (req->retry = true). So, first we need to save req->retry and then handle the req->retry = false case. Write requests are handled fine already. For read requests we have to save the buffer as we will not restart the request (and thus not refill the buffer) on the target host. Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* scsi: remove useless debug messagesPaolo Bonzini2012-05-071-13/+0
| | | | | | | | Optional inquiry information is declared obsolete in the latest versions of the standard; invalid CDBs or unsupported VPD pages are supported can be diagnosed with trace_scsi_inquiry. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: do not require a minimum allocation length for INQUIRYPaolo Bonzini2012-05-071-11/+0
| | | | | | | 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-disk: add dpofua propertyPaolo Bonzini2012-05-071-1/+6
| | | | | | | | | Linux expects REQ_FUA to be advertised only if WRITE+FUA is faster than WRITE+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 to set it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: change "removable" field to host many featuresPaolo Bonzini2012-05-071-8/+15
| | | | | | | | 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. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: fix WRITE SAME transfer length and directionPaolo Bonzini2012-05-041-1/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: fix refcounting for readsPaolo Bonzini2012-05-041-0/+7
| | | | | | | | | | | | | Recently introduced FUA support also gave us a use-after-free of the BlockAcctCookie within a SCSIDiskReq, due to unbalanced reference counting. The patch fixes this by making scsi_do_read look like a combination of scsi_*_complete + scsi_*_data. It does both a ref (like scsi_read_data) and an unref (like scsi_flush_complete). Reported-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* SCSI emulation: should tell the guest that we actually support thin provisioningRonnie Sahlberg2012-04-191-1/+1
| | | | | | | | | 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 (resource-provisioned, they call it). Newer drafts assign respectively 1 and 2 - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* SCSI emulation: Support unmap via WRITE_SAME_10.Ronnie Sahlberg2012-04-191-2/+3
| | | | | | | | | | This was added in SBC r26 in place of the reserved bits that were present 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> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: advertise DPOFUAPaolo Bonzini2012-04-191-1/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: small refactoring of MMC mode-sensePaolo Bonzini2012-04-191-7/+12
| | | | | | Make DBD a boolean value, and force device-specific parameter to zero. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: support FUA on readsPaolo Bonzini2012-04-191-10/+42
| | | | | | To force unit access on reads, flush the cache *before* doing the read. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: add a started field to SCSIDiskReqPaolo Bonzini2012-04-191-0/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: force unit access on VERIFYPaolo Bonzini2012-04-191-4/+23
| | | | | | | Also DMA data from the host, to avoid that the host reports an underrun. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: add support for FUA on writesPaolo Bonzini2012-04-191-2/+47
| | | | | | | | To force unit access, add a flush operation after the actual write. WRITE AND VERIFY commands always flush according to SBC, so do it even though we do not perform the reread. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: move scsi_flush_complete aroundPaolo Bonzini2012-04-191-18/+18
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: make code more homogeneous in AIO callback functionsPaolo Bonzini2012-04-191-7/+4
| | | | | | | | | First scsi_flush_complete, like scsi_dma_complete, is always called with an active AIOCB. Second, always test for "ret < 0" to check for errors. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: add missing test for cancelled requestPaolo Bonzini2012-04-191-1/+3
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: copy serial number into VPD page 0x83Paolo Bonzini2012-03-191-3/+4
| | | | | | | | | | | | | Currently QEMU passes the qdev device id to the guest in an ASCII-string designator in page 0x83. While this is fine, it does not match what real hardware does; usually the ASCII-string designator there hosts another copy of the serial number (there can be other designators, for example with a world-wide name). Do the same for QEMU SCSI disks. ATAPI does not support VPD pages, so it does not matter there. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-cd: check ready condition before processing several commandsPaolo Bonzini2012-03-191-13/+29
| | | | | | | | | | | | | | 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 option in the Linux CD-ROM driver. The actual chain of events is quite complex and somehow involves udev helpers; the actual command that matters is READ TOC, though honestly it's not really clear to me how because it should always be invoked after autoclose, not before. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Merge remote-tracking branch 'qmp/queue/qmp' into stagingAnthony Liguori2012-02-241-5/+8
|\ | | | | | | | | | | | | | | | | * qmp/queue/qmp: qmp: add DEVICE_TRAY_MOVED event ide: drop ide_tray_state_post_load() block: Don't call bdrv_eject() if the tray state didn't change block: bdrv_eject(): Make eject_flag a real bool block: Rename bdrv_mon_event() & BlockMonEventAction
| * block: Don't call bdrv_eject() if the tray state didn't changeLuiz Capitulino2012-02-221-2/+5
| | | | | | | | | | | | | | | | | | | | | | It's not needed. Besides we can then assume that bdrv_eject() is only called when there's a tray state change, which is useful to the DEVICE_TRAY_MOVED event (going to be added in a future commit). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
| * block: Rename bdrv_mon_event() & BlockMonEventActionLuiz Capitulino2012-02-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | They are QMP events, not monitor events. Rename them accordingly. Also, move bdrv_emit_qmp_error_event() up in the file. A new event will be added soon and it's good to have them next each other. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
* | scsi-block: always use scsi_generic_ops for cache != nonePaolo Bonzini2012-02-241-4/+14
| | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | scsi-disk: add migration supportPaolo Bonzini2012-02-221-4/+55
| | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | scsi-disk: enable scatter/gather functionalityPaolo Bonzini2012-02-221-13/+50
|/ | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: Unify type registrationAndreas Färber2012-02-151-2/+3
| | | | | | | | | | | | | 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 where necessary and don't put a semicolon after the closing brace. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: malc <av1474@comtv.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: register all types natively through QEMU Object ModelAnthony Liguori2012-02-031-50/+66
| | | | | | | | | | | | | | | | | | | | | This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi: convert to QEMU Object ModelAnthony Liguori2012-01-271-63/+96
| | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi: Guard against buflen exceeding req->cmd.xfer in scsi_disk_emulate_commandThomas Higdon2012-01-261-9/+1
| | | | | | | | | | | | | | | | | Limit the return value (corresponding to the length of the buffer to be DMAed back to the intiator) to the value in req->cmd.xfer, which is the amount of data that the initiator expects. Eliminate now-duplicate code that does this guarding in the functions for individual commands. Without this, the SCRIPTS code in the emulated LSI device eventually raises a DMA interrupt for a data overrun when an INQUIRY command whose buflen exceeds req->cmd.xfer is processed. It's the responsibility of the client to provide a request buffer and allocation length that are large enough for the result of the command. Signed-off-by: Thomas Higdon <thigdon@akamai.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi virtio-blk usb-msd: Clean up device init error messagesMarkus Armbruster2012-01-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 device scsi-hd and scsi-cd, "virtio-blk-pci" for virtio-blk-s390, and "usb-msd" for usb-storage. There is no real need to put a device name in the message, because error_report() points to the offending command line option already: $ qemu-system-x86_64 --nodefaults --enable-kvm -vnc :0 -S -monitor stdio -usb -device virtio-blk-pci upstream-qemu: -device virtio-blk-pci: virtio-blk-pci: drive property not set upstream-qemu: -device virtio-blk-pci: Device 'virtio-blk-pci' could not be initialized And for a monitor command, it's obvious anyway: $ qemu-system-x86_64 --nodefaults --enable-kvm -vnc :0 -S -monitor stdio -usb (qemu) device_add virtio-blk-pci virtio-blk-pci: drive property not set Device 'virtio-blk-pci' could not be initialized Reported-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* block: bdrv_aio_* do not return NULLPaolo Bonzini2011-12-151-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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) { ... } | - if (E) { <... S ...> } ) which however missed the occurrence in block/blkverify.c (as it should have done), and left behind some unused variables. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-block: always use SG_IO for MMC devicesPaolo Bonzini2011-11-181-2/+14
| | | | | | | | | | | CD burning messes up the state of the host page cache and host block device. Just pass all operations down to the device, even though that might have slightly worse performance. Everything else just is not reliable in combination with burning. Reported-by: Thomas Schmitt <scdbackup@gmx.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: pass down REQUEST SENSE to the device when there is no stored sensePaolo Bonzini2011-11-181-2/+6
| | | | | | | | | | This will let scsi-block/scsi-generic report progress on long operations. Reported-by: Thomas Schmitt <scdbackup@gmxbackup.net> Tested-by: Thomas Schmitt <scdbackup@gmxbackup.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: remove block descriptors from CDsPaolo Bonzini2011-11-181-1/+2
| | | | | | | 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 commandsPaolo Bonzini2011-11-181-3/+1
| | | | | | | | | Add more commands and their names, and remove SEEK(6) 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 geometryPaolo Bonzini2011-11-181-2/+2
| | | | | | | | Old operating systems rely on correct geometry to convert from CHS addresses 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 pathPaolo Bonzini2011-11-181-1/+1
| | | | | | | | | | The pre-1.0 firmware path for SCSI devices already included the LUN using the suffix argument to add_boot_device_path. I missed that when making channel and LUN customizable. Avoid that it is included twice, and convert the colons to commas for consistency with other kinds of devices Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: implement eject requestsPaolo Bonzini2011-11-111-3/+21
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: add scsi-block for device passthroughPaolo Bonzini2011-10-281-0/+118
| | | | | | | | | | | | scsi-block is a new device that supports device passthrough of Linux block devices (i.e. /dev/sda, not /dev/sg0). It uses SG_IO for commands other than I/O commands, and regular AIO read/writes for I/O commands. Besides being simpler to configure (no mapping required to scsi-generic device names), this removes the need for a large bounce buffer and, in the future, will get scatter/gather support for free from scsi-disk. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: push request restart to SCSIDevicePaolo Bonzini2011-10-281-69/+7
| | | | | | | | | | | | | | | | The request restart mechanism is generic and could be reused for scsi-generic. In the meanwhile, pushing it to SCSIDevice avoids that scsi_dma_restart_bh looks at SCSIGenericReqs when working on a scsi-block device. The code is the same that is already in hw/scsi-disk.c, with the type flags replaced by req->cmd.mode and a more generic way to requeue SCSI_XFER_NONE commands. I also added a missing call to qemu_del_vm_change_state_handler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: bump SCSIRequest reference count until aio completion runsPaolo Bonzini2011-10-281-3/+45
| | | | | | | | | | | | | In some cases a request may be canceled before the completion callback runs. Keep a reference to the request between starting an AIO operation and the corresponding scsi_req_cancel or scsi_*_complete. When a request has to be retried, the request can be dropped because scsi_dma_restart_bh only looks at requests that are enqueued. As such, they always have at least a reference. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: pass cdb to alloc_reqPaolo Bonzini2011-10-281-2/+2
| | | | | | | This will let scsi-block choose between passthrough and emulation. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: make reqops constPaolo Bonzini2011-10-281-1/+1
| | | | | | | 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: move max_lba to SCSIDevicePaolo Bonzini2011-10-281-8/+7
| | | | | | | | | | | The field is only in scsi-disk for now. Moving it up to SCSIDevice makes it easier to reuse the scsi-generic reqops elsewhere. At the same time, make scsi-generic get max_lba from snooped READ CAPACITY commands as well. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: small clean up to INQUIRYPaolo Bonzini2011-10-281-25/+21
| | | | | | | | | | | | Set s->removable, s->qdev.blocksize and s->qdev.type in the callers of scsi_initfn. With this in place, s->qdev.type is allowed, and we can just reuse it as the first byte in VPD data (just like we do in standard INQUIRY data). Also set s->removable is set consistently and we can use it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: remove cluster_sizePaolo Bonzini2011-10-281-19/+16
| | | | | | | | This field is redundant, and having it makes it more complicated to share reqops between the upcoming scsi-block and scsi-generic. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: do not duplicate BlockDriverState memberPaolo Bonzini2011-10-281-47/+45
| | | | | | | | Same as for scsi-generic, avoid duplication even if it causes longer lines. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: fix retrying a flushPaolo Bonzini2011-10-281-6/+3
| | | | | | | Flush does not go anymore through scsi_disk_emulate_command. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0Paolo Bonzini2011-10-281-0/+6
| | | | | | | | | | | | Tested by the Windows Logo Kit SCSI Compliance test. From SBC-3, paragraph 5.25: "The LOGICAL BLOCK ADDRESS field shall be set to zero if the PMI bit is set to zero. If the PMI bit is set to zero and the LOGICAL BLOCK ADDRESS field is not set to zero, then the device server shall terminate the command with CHECK CONDITION status with the sense key set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD IN CDB". Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>