summary refs log tree commit diff stats
path: root/hw/scsi-disk.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* scsi-disk: use scsi_data_cdb_lengthPaolo Bonzini2012-09-211-9/+5
| | | | | | | This simplifies and unifies the parsing of READ, WRITE and WRITE SAME commands. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: fix check for out-of-range LBAPaolo Bonzini2012-09-211-1/+5
| | | | | | | This fix is needed to correctly handle 0-block read and writes. Without it, a 0-block access at LBA 0 would underflow. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: introduce check_lba_rangePaolo Bonzini2012-09-211-8/+16
| | | | | | | Abstract the test for an out-of-range (starting block, block count) pair. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: Fix typo (uint32 -> uint32_t)Stefan Weil2012-08-291-1/+1
| | | | | | 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 devicesPaolo Bonzini2012-08-281-0/+1
| | | | | | | | | | | | | Commit 0384783 (scsi-block: remove properties that are not relevant for passthrough, 2012-07-09) removed one property that should have been left there, "bootindex". It also did not touch scsi-generic, while it should have. Fix both problems. Reported-by: Alexandre DERUMIER <aderumier@odiso.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Merge remote-tracking branch 'bonzini/scsi-next' into stagingAnthony Liguori2012-08-111-10/+102
|\ | | | | | | | | | | | | | | | | | | | | * bonzini/scsi-next: scsi-disk: add support for the UNMAP command scsi-disk: improve out-of-range LBA detection for WRITE SAME scsi-disk: more assertions and resets for aiocb virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags iscsi: Pick default initiator-name based on the name of the VM iscsi: reorganize code for parse_initiator_name iscsi: do not leak initiator_name
| * scsi-disk: add support for the UNMAP commandPaolo Bonzini2012-08-091-1/+92
| | | | | | | | | | | | | | | | The unmap command can reuse the same infrastructure as MODE SELECT for reading the descriptor list into memory. The descriptors are processed sequentially. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| * scsi-disk: improve out-of-range LBA detection for WRITE SAMEPaolo Bonzini2012-08-091-1/+2
| | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| * scsi-disk: more assertions and resets for aiocbPaolo Bonzini2012-08-091-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | Leaving the aiocb to a non-NULL value leads to an assertion failure when rerror/werror are set to stop or enospc, and the operation is retried. scsi-disk checks that the aiocb member is NULL before filling it. This patch correctly resets the aiocb to NULL values everywhere, and adds the dual assertion that the aiocb was non-NULL before calling bdrv_acct_done. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | ide scsi: Mess with geometry only for hard disk devicesMarkus Armbruster2012-08-061-1/+2
|/ | | | | | | | | | Legacy -drive cyls=... are now ignored completely when the drive doesn't back a hard disk device. Before, they were first checked against a hard disk's limits, then ignored. Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: fix compilation with DEBUG_SCSIPaolo Bonzini2012-08-031-11/+12
| | | | | Reported-by: Gerhard Wiesinger <lists@wiesinger.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0Ronnie Sahlberg2012-08-031-0/+6
| | | | | | | | | | | | | | | | The START STOP UNIT command will only eject/load media if power condition is zero. If power condition is !0 then LOEJ and START will be ignored. From MMC (sbc contains similar wordings too) The Power Conditions field requests the block device to be placed in the power condition defined in Table 558. If this field has a value other than 0h then the Start and LoEj bits shall be ignored. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: report parameter changes to HBA driversPaolo Bonzini2012-07-271-0/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: report resized disk via sense codesPaolo Bonzini2012-07-271-2/+22
| | | | | | | Linux will not use these, but a very similar mechanism will be used to report the condition via virtio-scsi events. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: establish precedence levels for unit attentionPaolo Bonzini2012-07-271-2/+2
| | | | | | | | When a device is resized, we will report a unit attention condition for CAPACITY DATA HAS CHANGED. However, we should ensure that this condition does not override a more important unit attention condition. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: removable hard disks support load/ejectPaolo Bonzini2012-07-271-1/+1
| | | | | | | | | | Support for the LOEJ bit of the START/STOP UNIT command right now is limited to CD-ROMs. This is wrong, since removable hard disks (in the real world: SD card readers) also support it in pretty much the same way. Without the LOEJ bit, START/STOP UNIT does nothing for all devices. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: Fail medium writes with proper sense for readonly LUNsRonnie Sahlberg2012-07-261-3/+12
| | | | | | | | | Add sense code for DATA_PROTECT/WRITE_PROTECTED and return this error for any WRITE*/WRITE_VERIFY* calls if the device is readonly=on, i.e. write-protected Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: improve the lba-out-of-range tests for read/write/verifyRonnie Sahlberg2012-07-261-2/+4
| | | | | | | | | | | | | 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 to make sure that we do not wrap. For example if an opcode would specify the LBA:0xffffffffffffffff and LEN:2 then lba+len would wrap to 1. Also verify that ALL requested blocks are available, not just the first one. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: rd/wr/vr-protect !=0 is an errorRonnie Sahlberg2012-07-261-0/+9
| | | | | | | | | | | | | | | | The QEMU SCSI emulation does not support protection information, so any READ/WRITE/VERIFY commands that has the protect bits set to non-zero should fail with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB From SCSI SBC : If the logical unit does not support protection information, then the device server should 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: Ronnie Sahlberg <ronniesahlberg@gmail.com> [ Rebase after scsi_dma_reqops introduction - Paolo ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: support toggling the write cachePaolo Bonzini2012-07-261-4/+10
| | | | | | | Finally, this uses the "plumbing" in the previous patch to add support for toggling the WCE bit of the caching mode page. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: parse MODE SELECT commands and parametersPaolo Bonzini2012-07-261-11/+155
| | | | | | | | | | | | This adds the bulk of the parsing code for MODE SELECT, including breaking out changes to different mode pages, and checking that only changeable values are modified. In order to report errors correctly two passes are made through the parameters; the first only looks for errors, the second actually applies the changes to the mode page. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: fix changeable values for MODE_PAGE_R_W_ERRORPaolo Bonzini2012-07-261-0/+3
| | | | | | The changeable values were not all-zeros for this mode page, fix it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: adjust offsets in MODE SENSE by 2Paolo Bonzini2012-07-261-66/+74
| | | | | | | | | This will make offsets the same when implementing MODE SELECT. This is because 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 to the descriptions in the SCSI specs, which include the header. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: support emulated TO_DEV requestsPaolo Bonzini2012-07-261-8/+28
| | | | | | | | | | | This adds the implementation of write_data for the emulated command 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(10) can now be re-enabled, but they will not do much. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: separate read_data/write_data implementation for emulate_reqopsPaolo Bonzini2012-07-261-11/+25
| | | | | | | | | | | 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. read_data passes the data buffer that was prepared and completes the command. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: split scsi-disk reqopsPaolo Bonzini2012-07-261-68/+123
| | | | | | | | | | | Only checks for present medium were still done in scsi_send_command for emulated commands. So move those to scsi_disk_emulate_command and return different SCSIReqOps depending on the kind of command. Checks for present medium can be done unconditionally for the scsi_disk_dma_reqops case. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: move all non-DMA commands to scsi_disk_emulate_commandPaolo Bonzini2012-07-261-86/+66
| | | | | | | | | | | | | | | We want to use separate SCSIReqOps for emulated commands needing an allocated buffer vs. those that are zerocopy when the HBA supports S/G lists. Ensure that all of the former are in scsi_disk_emulate_command. Commands that do not have any parameters are more similar to emulated commands, so also move them, even if they do I/O. Finally, MODE SELECT and MODE SELECT(10) are broken because we do not yet support passing parameter data _to_ emulated commands, so disable them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: make discard asynchronousPaolo Bonzini2012-07-261-12/+10
| | | | | | | By making discard asynchronous, we can reuse all the error handling code that is used for other commands. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-disk: let the user customize vendor and product nameDmitry Fleytman2012-07-261-10/+21
| | | | | | | | | | | This patch adds two new properties vendor and product to SCSI disks. These options let the user customize the inquiry data returned by the disk. Signed-off-by: Yan Vugenfirer <yan@ravellosystems.com> Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com> [ Use vendor and product property names, avoid "if" statements. - PB ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi-block: remove properties that are not relevant for passthroughPaolo Bonzini2012-07-261-1/+1
| | | | | | | | | scsi-block is a passthrough device and does not allow customization of vendor, product, removable, DPOFUA, block size or any other piece of information. Thus, drop DEFINE_SCSI_DISK_PROPERTIES() from the list of qdev properties. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* hw/block-common: Factor out fall back to legacy -drive cyls=...Markus Armbruster2012-07-171-28/+3
| | | | | 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 serial=...Markus Armbruster2012-07-171-7/+1
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-hd: qdev properties for disk geometryMarkus Armbruster2012-07-171-23/+46
| | | | | | | | | | | | | | | | Geometry needs to be qdev properties, because it belongs to the disk's guest part. Maintain backward compatibility exactly like for serial: fall back to DriveInfo's geometry, set with -drive cyls=... Do this only for scsi-hd. scsi-disk is legacy. scsi-cd doesn't have a geometry. scsi-block should get geometry from the host disk. Bonus: info qtree now shows the geometry. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* hd-geometry: Switch to uint32_t to match BlockConfMarkus Armbruster2012-07-171-1/+1
| | | | | | | | | | | Best to use the same type, to avoid unwanted truncation or sign extension. BlockConf can't use plain int for cyls, heads and secs, because integer properties require an exact width. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* hd-geometry: Cut out block layer translation middlemanMarkus Armbruster2012-07-171-2/+2
| | | | | | | | | | | | | hd_geometry_guess() picks geometry and translation. Callers can get the geometry directly, via parameters, but for translation they need to go through the block layer. Add a parameter for translation, so it can optionally be gotten just like geometry. In preparation of purging translation from the block layer, which will happen later in this series. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* hd-geometry: Move disk geometry guessing back from block.cMarkus Armbruster2012-07-171-2/+3
| | | | | | | | | | | Commit f3d54fc4 factored it out of hw/ide.c for reuse. Sensible, except it was put into block.c. Device-specific functionality should be kept in device code, not the block layer. Move it to hw/hd-geometry.c, and make stylistic changes required to keep checkpatch.pl happy. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi-disk: implement READ DISC INFORMATIONPaolo Bonzini2012-07-021-0/+40
| | | | | | | | | This command is not necessary for CD-ROM and DVD-ROM, but some versions of udev 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: add a qdev property for the disk's WWNPaolo Bonzini2012-07-021-1/+13
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* scsi: simplify handling of the VPD page length fieldPaolo Bonzini2012-07-021-8/+7
| | | | | | The last four bytes of the thin provisioning page were cut out. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Allow machines to configure the QEMU_VERSION that's exposed via hardwareCrístian Viana2012-06-191-1/+1
| | | | | | | | | | | | 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 switch the QEMU version). There is a new field now on the struct QEmuMachine, hw_version, which may contain the version that the specific machine should report. If that field is set, then that machine will report that version to the guest. Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi-disk: Don't peek behind the BlockDriverState abstractionMarkus Armbruster2012-06-151-2/+1
| | | | | | | | 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 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>