History | View | Annotate | Download (40.4 kB)
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>
use qemu_blockalign consistently
Use qemu_blockalign for all allocations in the block layer. This allowsincreasing the required alignment, which is need to support O_DIRECT ondevices with large block sizes.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
scsi-disk: propagate the required alignment
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
scsi-disk: add some optional scsi commands
I use a legacy OS which depends on some optional SCSI commands.In fact this implementation does nothing special, but provides minimumsupport for the following commands:
REZERO UNITWRITE AND VERIFYWRITE AND VERIFY...
scsi: fix and improve debug prints
Some of them are not compile clean.
Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
scsi-disk: fix the check of the DBD bit in the MODE SENSE command
The DBD bit does not work as expected.
SCSI-Spec:http://ldkelley.com/SCSI2/SCSI2/SCSI2-08.html#8.2.10"A disable block descriptors (DBD) bit of zero indicates that the targetmay return zero or more block descriptors in the returned MODE SENSE...
scsi-disk: return CHECK CONDITION for unknown page codes in the MODE SENSE command
SCSI-Spec:http://ldkelley.com/SCSI2/SCSI2/SCSI2-08.html#8.2.10"An initiator may request any one or all of the supported mode pagesfrom a target. If an initiator issues a MODE SENSE command with a...
scsi-disk: fix the block descriptor returned by the MODE SENSE command
The block descriptor contains the number of blocks, not the highest LBA.Real hard disks return 0 if the number of blocks exceed the maximum 0xFFFFFF.
SCSI-Spec:http://ldkelley.com/SCSI2/SCSI2/SCSI2-08.html#8.3.3...
scsi-disk: respect the page control (PC) field in the MODE SENSE command
The page control (PC) field defines the type of mode parameter valuesto be returned in the mode pages:
PC=0 : Current valuesPC=1 : Changeable valuesPC=2 : Default valuesPC=3 : Saved values...
scsi-disk: fix the mode data header returned by the MODE SENSE command
The header for the MODE SENSE command is 8 bytes long.
scsi-disk: fix the mode data length field returned by the MODE SENSE command
The MODE DATA LENGTH field indicates the length in bytes of the followingdata that is available to be transferred. The mode data length does not includethe number of bytes in the MODE DATA LENGTH field....
Rearrange block headers
Changing block.h or blockdev.h resulted in recompiling most objects.
Move DriveInfo typedef and BlockInterfaceType enum definitionsto qemu-common.h and rearrange blockdev.h use to decrease churn.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
ide scsi virtio-blk: Reject empty drives unless media is removable
Disks without media make no sense. For SCSI, a Linux guest kernelcomplains during boot. I didn't try other combinations.
scsi-generic doesn't need the additional check, because it already...
scsi: Reject unimplemented error actions
drive_init() doesn't permit rerror for if=scsi, but that's worthless:we get it via if=none and -device.
Moreover, scsi-generic doesn't support werror. Since drive_init()doesn't catch that, option werror was silently ignored even with...
qdev: Decouple qdev_prop_drive from DriveInfo
Make the property point to BlockDriverState, cutting out the DriveInfomiddleman. This prepares the ground for block devices that don't havea DriveInfo.
Currently all user-defined ones have a DriveInfo, because the only way...
block: Fix virtual media change for if=none
BlockDriverState member removable controls whether virtual mediachange (monitor commands change, eject) is allowed. It is set whenthe "type hint" is BDRV_TYPE_CDROM or BDRV_TYPE_FLOPPY.
The type hint is only set by drive_init(). It sets BDRV_TYPE_FLOPPY...
blockdev: Clean up automatic drive deletion
We automatically delete blockdev host parts on unplug of the guestdevice. Too much magic, but we can't change that now.
The delete happens early in the guest device teardown, before theconnection to the host part is severed. Thus, the guest part's...
block: Move error actions from DriveInfo to BlockDriverState
That's where they belong semantically (block device host part), eventhough the actions are actually executed by guest device code.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev: Collect block device code in new blockdev.c
Anything that moves hundreds of lines out of vl.c can't be all bad.
scsi: Fix info qtree for scsi-disk.ver
Show the actual default value instead of <null> when the property hasnot been set.
scsi: Turn drive serial into a qdev property scsi-disk.serial
It needs to be a qdev property, because it belongs to the drive'sguest part.
Bonus: info qtree now shows the serial number.
SCSI: Add disk reset handler
Ensure that pending requests of an SCSI disk are purged on system resetand also restore max_lba. The latter is no only present in the resethandler as that one is called after init as well.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
scsi-disk: Clear aiocb on read completion
Once the I/O completion callback returned, aiocb will be released by thecontroller. So we have to clear the reference not only inscsi_write_complete, but also in scsi_read_complete. Otherwise we riskinconsistencies when a reset hits us before the related request is...
scsi-disk: fix buffer overflow
In case s->version is shorter than 4 bytes we overflow the memcpy srcbuffer. Fix it by clearing the target buffer, then copy only theamount of bytes we actually have.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
read-only: Another minor cleanup
Don't rely on CDROM hint for read_only attribute
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: add logical_block_size property
Add a logical block size attribute as various guest side tools onlyincrease the filesystem sector size based on it, not the advisoryphysical block size.
For scsi we already have support for a different logical block size...
error: Replace qemu_error() by error_report()
error_report() terminates the message with a newline. Strip it itfrom its arguments.
This fixes a few error messages lacking a newline:net_handle_fd_param()'s "No file descriptor named %s found", andtap_open()'s "vnet_hdr=1 requested, but no kernel support for...
error: Move qemu_error & friends into their own header
scsi: Make device scsi-disk reject /dev/sg*
You're supposed to use scsi-generic for that. Which rejects anythingbut /dev/sg*.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: Emit BLOCK_IO_ERROR before vm_stop() call
The next commit will move the STOP event into do_vm_stop(), tohave the expected event sequence we need to emit the I/O errorevent before calling vm_stop().
The expected sequence is:
{ "event": "BLOCK_IO_ERROR" [...] }...
scsi: update comment on the standards revision
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
scsi: add topology support
Export the physical block size in the READ CAPACITY (16) command,and add the new block limits VPD page to export the minimum andoptiomal I/O sizes.
Note that we also need to bump the scsi revision level to SPC-2as that is the minimum requirement by at least the Linux kernel...
block: add topology qdev properties
Add three new qdev properties to export block topology information tothe guest. This is needed to get optimal I/O alignment for RAID arraysor SSDs.
The options are:
- physical_block_size to specify the physical block size of the device,...
scsi: Generate BLOCK_IO_ERROR QMP event
Just call bdrv_mon_event() in the right place.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
win32: pair qemu_memalign() with qemu_vfree()
Win32 suffers from a very big memory leak when dealing with SCSI devices.Each read/write request allocates memory with qemu_memalign (ieVirtualAlloc) but frees it with qemu_free (ie free).Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks....
scsi: device version property
This patch adds a new property named 'ver' to scsi-disk which allows tospecify the version which the virtual disk/cdrom should report to theguest. By default this is the qemu version (i.e. 0.12). usage:
-drive if=none,id=disk,file=......
scsi-disk: Inquiry with allocation length of CDB < 36 (v4)
According to the SCSI-2 specification,http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2-08.html#8.2.5 ,"if the allocation length of the command descriptor block (CDB) is toosmall to transfer all of the parameters, the additional length shall...
scsi: fix incorrect ?: use
Fixes OpenBSD build.
SCSI: Fix Standard INQUIRY data
Vendor identification, product identification and product revision levelshould be padded with spaces without a terminating NULL character, seeSCSI-2 standard, 8.2.5.1 Standard INQUIRY data.
Signed-off-by: Laszlo Ast <laszlo.ast@siemens-enterprise.com>...
Rename DriveInfo.onerror to on_write_error
Either rename variables and functions to refer to write errors (which is whatthey actually do) or introduce a parameter to distinguish reads and writes.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
scsi-disk: restruct emulation: GET_CONFIGURATION
Move GET_CONFIGURATION emulation from scsi_send_command() toscsi_disk_emulate_command().
Also add GET_CONFIGURATION to scsi-defs.h and scsi_command_name().
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>...
scsi-disk: restruct emulation: SERVICE_ACTION_IN
Move SERVICE_ACTION_IN emulation from scsi_send_command() toscsi_disk_emulate_command().
Also add SERVICE_ACTION_IN to scsi-defs.h and scsi_command_name().
scsi-disk: restruct emulation: REPORT_LUNS
Move REPORT_LUNS emulation from scsi_send_command() toscsi_disk_emulate_command().
Also add REPORT_LUNS to scsi-defs.h and scsi_command_name().
scsi-disk: restruct emulation: VERIFY
Move VERIFY emulation from scsi_send_command() toscsi_disk_emulate_command().
scsi: add read/write 16 commands.
Add READ_16 + friends to scsi-defs.h, scsi_command_name() and therequest parsing helper functions.
Use them in scsi-disk.c too.
scsi-disk: restruct emulation: INQUIRY
Move INQUIRY emulation from scsi_send_command() toscsi_disk_emulate_command(). Also split the longish INQUITY emulationcode into the new scsi_disk_emulate_inquiry() function. Serial numberhandling is slightly changed, we don't copy it any more but look it up...
scsi-disk: restruct emulation: RESERVE+RELEASE
Move RESERVE+RELEASE emulation from scsi_send_command() toscsi_disk_emulate_command().
scsi-disk: restruct emulation: MODE_SENSE
Move MODE_SENSE emulation from scsi_send_command() toscsi_disk_emulate_command(). Create two helper functions:mode_sense_page() which writes the actual mode pages andscsi_disk_emulate_mode_sense() which holds the longish MODE_SENSE...
scsi-disk: restruct emulation: START_STOP
Move START_STOP emulation from scsi_send_command() toscsi_disk_emulate_command().
scsi-disk: restruct emulation: ALLOW_MEDIUM_REMOVAL
Move ALLOW_MEDIUM_REMOVAL emulation from scsi_send_command() toscsi_disk_emulate_command().
scsi-disk: restruct emulation: READ_CAPACITY
Move READ_CAPACITY emulation from scsi_send_command() toscsi_disk_emulate_command().
scsi-disk: restruct emulation: SYNCHRONIZE_CACHE
Move SYNCHRONIZE_CACHE emulation from scsi_send_command() toscsi_disk_emulate_command().
scsi-disk: restruct emulation: READ_TOC
Move READ_TOC emulation from scsi_send_command() toscsi_disk_emulate_command(). Add scsi_disk_emulate_read_toc() functionwhich holds the longisch READ_TOC emulation code.
scsi-disk: restruct emulation: core + TEST_UNIT_READY.
Add new scsi_disk_emulate_command() function, which will -- whenfinished -- handle all scsi disk command emulation except actual I/O(READ+WRITE commands) which goes to the block layer. The function...
scsi-disk: restruct emulation: REQUEST_SENSE
Move REQUEST_SENSE emulation from scsi_send_command() toscsi_disk_emulate_command().
scsi: move sense to SCSIDevice, create SCSISense struct.
scsi: move dinfo to SCSIDevice
scsi: move status to SCSIRequest.
Also add and use the scsi_req_complete() helper function for calling thecompletion callback.
scsi: create common SCSIRequest structure.
Rename the SCSIRequest structs in scsi-disk.c and scsi-generic.c toSCSIDiskReq and SCSIGenericReq. Create a SCSIRequest struct and movethe common elements over.
scsi: move request lists to QTAILQ.
Changes: * Move from open-coded lists to QTAILQ macros. * Move the struct elements to the common data structures (SCSIDevice + SCSIRequest). * Drop free request pools. * Fix request cleanup in the destroy callback....
scsi: move SCSIRequest management to common code.
Create generic functions to allocate, find and release SCSIRequeststructs. Make scsi-disk and scsi-generic use them.
scsi: move blocksize from SCSIGenericState to SCSIDevice
scsi: add scsi-defs.h
Largely based on <scsi/scsi.h> from linux. Added into the tree so wecan use the defines everywhere, not just in scsi-generic.c (which islinux-specific).
scsi: move type from SCSIGenericState to SCSIDevice
scsi: use command defines in scsi-disk.c
scsi: move scsi-disk.h -> scsi.h
Pass the drive's readonly attribute to the guest OS
Implemented for virtio-blk and for scsi
scsi disk block descriptor v2
The SCSI-2 documentation suggests, that although the blockdescriptor is optional for an arbitrary SCSI-2 device (chapter 8.2.10,http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2/SCSI2-08.html )it is mandatory for a disk: chapters 9.1.2, 9.3.3...
drive cleanup fixes.
Changes: * drive_uninit() wants a DriveInfo now. * drive_uninit() also calls bdrv_delete(), so callers don't need to do that. * drive_uninit() calls are moved over to the ->exit() callbacks, destroy_bdrvs() is zapped. * setting bdrv->private is not needed any more as the...
Implement scsi device destruction
block: add enable_write_cache flag
Add a enable_write_cache flag in the block driver state, and use it todecide if we claim to have a volatile write cache that needs controlledflushing from the guest. The flag is off if cache=writethrough isdefined because O_DSYNC guarantees that every write goes to stable...
qdev/scsi: add scsi bus support to qdev, convert drivers.
Adding scsi disks via -device works now, i.e. you can do:
-drive id=sda,if=none,......
Fix VM state change handlers running out of order
When a VM state change handler changes VM state, other VM state changehandlers can see the state transitions out of order.
bmdma_map(), scsi_disk_init() and virtio_blk_init() install VM statechange handlers to restart DMA. These handlers can vm_stop() by...
Fix most warnings (errors with -Werror) when debugging is enabled
I used the following command to enable debugging:perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * /* *//*
Replace gcc variadic macro extension with C99 version