summaryrefslogtreecommitdiffstats
path: root/hw/virtio-scsi.c
Commit message (Collapse)AuthorAgeFilesLines
* virtio-scsi: abort in-flight I/O when the device is resetPaolo Bonzini2013-01-101-0/+4
| | | | | | | | When the device is reset, the SCSI bus should also be reset so that in-flight I/O is cancelled. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio-scsi: Fix subtle (guest) endian bugDavid Gibson2012-11-281-2/+2
| | | | | | | | | | | | | | | | | | | The virtio-scsi config space is, by specification, in guest endian (which is ill-defined, but there you go). In virtio_scsi_get_config() we set up all the fields in there, using stl_raw(). Which is a problem for the max_channel and max_target fields, which are 16-bit, not 32-bit. For little-endian targets we get away with it by accident, since the first two bytes will still be correct, and the extra two bytes written (with zeroes) will be overwritten correctly by the next store. But for big-endian guests, this means the max_target field ends up as zero, which means the guest will only recognize a single disk on the virtio-scsi bus. This patch fixes the problem. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Paul 'Rusty' Russell <rusty@rustcorp.com.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: Fix some endian bugs with virtio-scsiDavid Gibson2012-11-281-3/+5
| | | | | | | | | | | | | | | | | | | | The virtio-scsi specification does not specify the correct endianness for fields in the request structure. It's therefore best to assume that it is "guest native" endian since that's the (stupid and poorly defined) norm in virtio. However, the qemu device for virtio-scsi has no byteswaps at all, and so will break if the guest has different endianness from the host. This patch fixes it by adding tswap() calls for the sense_len and resid fields in the request structure. In theory status_qualifier needs swaps as well, but that field is never actually touched. The tag field is a uint64_t, but since its value is completely arbitrary, it might as well be uint8_t[8] and so it does not need swapping. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Paul 'Rusty' Russell <rusty@rustcorp.com.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: use dma_context_memoryPaolo Bonzini2012-11-121-1/+1
| | | | | | | | | | Until address_space_rw was introduced, NULL was accepted as a placeholder for DMA with no IOMMU (to address_space_memory). This does not work anymore, and dma_context_memory needs to be specified explicitly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: factor checks for VIRTIO_SCSI_S_DRIVER_OK when reporting eventsPaolo Bonzini2012-11-121-3/+5
| | | | | | Suggested by Laszlo Ersek. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Rename target_phys_addr_t to hwaddrAvi Kivity2012-10-231-1/+1
| | | | | | | | | | | | | | | target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio-scsi: add backwards-compatibility properties for 1.1 and earlier machinesPaolo Bonzini2012-08-201-7/+0
| | | | | | | Hotplug and parameter change are new in 1.2, disable them via compat properties for pc-1.1 and earlier. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tagsPaolo Bonzini2012-08-091-2/+8
| | | | | | | | | | | | | | | | | | | This patch fixes a problem in handling task management functions in virtio-scsi. The cause of the problem is a mismatch between the size of the tag in QEMU (32-bit) and virtio-scsi (64-bit). Changing the QEMU size is hard because the migration format uses 32 bits to store the tag; so just don't use the QEMU tag (virtio-scsi only uses the tag for task management functions anyway) and look up the full 64-bit tag in the hba_private field. The reproducer is a bit obscure. If you cause an I/O timeout (for example with rerror=stop and doing 'cont' on the monitor continuously without fixing the error), sooner or later the guest will try to abort the command and reissue it. At this point, QEMU will report _two_ errors instead of one when you hit 'c', because the first error has not been canceled correctly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: report parameter change eventsPaolo Bonzini2012-07-271-0/+16
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: do not report dropped events after resetPaolo Bonzini2012-07-271-0/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: Report missed eventsPaolo Bonzini2012-07-271-18/+36
| | | | | | | When an event is reported but no buffers are present in the event vq, we can set a flag and report a dummy event as soon as one is added. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: Implement hotplug support for virtio-scsiCong Meng2012-07-271-2/+70
| | | | | | | | | | | | Implement the hotplug() and hot_unplug() interfaces in virtio-scsi, by signal the virtio_scsi.ko in guest kernel via event virtual queue. The counterpart patch of virtio_scsi.ko will be sent soon in another thread. Signed-off-by: Sen Wang <senwang@linux.vnet.ibm.com> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com> [ Add memset, fix LUN field, placate checkpatch - Paolo ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: do not crash on adding buffers to the event queuePaolo Bonzini2012-07-021-1/+5
| | | | | | | | | | | The event queue is not supported yet and the handler does not have to do much anyway when buffers are added. However, the handler is called unconditionally by the virtio layer, and this results in a crash as soon as buffers are added to the event queue because we pass NULL. Reported-by: Bryan Venteicher <bryanv@daemoninthecloset.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qbus: Make child devices linksAnthony Liguori2012-06-181-3/+3
| | | | | | | | | | | | Make qbus children show up as link<> properties. There is no stable addressing for qbus children so we use an unstable naming convention. This is okay in QOM though because the composition name is expected to be what's stable. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* virtio: check virtio_load return codeOrit Wassermann2012-05-211-1/+6
| | | | | | | | | Otherwise we crash on error. Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com> Signed-off-by: Orit Wassermann <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio-scsi: add multiqueue capabilityPaolo Bonzini2012-04-191-10/+15
| | | | | | | Adding multiqueue is as simple as creating more than one virtqueues, and saving the queue number for each request. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: prepare migration format for multiqueuePaolo Bonzini2012-04-191-0/+5
| | | | | | | | | | | In order to restore requests correctly from a multitude of virtqueues, we need to store the id of the request queue that each request came from. Do this even for single-queue, by storing a hard-coded zero, to simplify future implementation of multiqueue. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: call unregister_savevm properlyPaolo Bonzini2012-03-191-0/+2
| | | | | | This fixes a use-after-free when migrating after hot-unplug. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: add migration supportPaolo Bonzini2012-02-241-1/+49
| | | | | Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: process control queue requestsPaolo Bonzini2012-02-241-8/+126
| | | | | Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: add basic SCSI bus operationPaolo Bonzini2012-02-221-13/+98
| | | | | Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: Add basic request processing infrastructureStefan Hajnoczi2012-02-221-2/+140
| | | | | | Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: Add virtio-scsi stub deviceStefan Hajnoczi2012-02-221-0/+228
Add a useless virtio SCSI HBA device: qemu -device virtio-scsi-pci Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud