summaryrefslogtreecommitdiff
path: root/hw/scsi
AgeCommit message (Collapse)AuthorFilesLines
2013-09-12scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serialMarkus Armbruster1-1/+1
scsi_bus_legacy_add_drive() creates either a scsi-disk or a scsi-generic device. It sets property "serial" to argument serial unless null. Crashes with scsi-generic, because it doesn't have such the property. Only usb_msd_initfn_storage() passes non-null serial. Reproducer: $ qemu-system-x86_64 -nodefaults -display none -S -usb \ -drive if=none,file=/dev/sg1,id=usb-drv0 \ -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123 qemu-system-x86_64: -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123: Property '.serial' not found Aborted (core dumped) Fix by handling exactly like "removable": set the property only when it exists. Cc: qemu-stable@nongnu.org Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-09-12virtio-scsi: Make type virtio-scsi-common abstractMarkus Armbruster1-0/+1
It's the abstract base of virtio-scsi-device and vhost-scsi. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-09-12spapr-vscsi: add task managementAlexey Kardashevskiy2-27/+99
At the moment the guest kernel issues two types of task management requests to the hypervisor - task about and lun reset. This adds handling for these tasks. As spapr-vscsi starts calling scsi_req_cancel(), free_request callback was implemented. As virtio-vscsi, spapr-vscsi does not handle CLEAR_ACA either as CDB control byte does not seem to be used at all so NACA bit is not set to the guest so the guest has no good reason to call CLEAR_ACA task. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> [Fix choice of UCSOLCNT vs. SCSOLCNT. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-08-30qdev: Pass size to qbus_create_inplace()Andreas Färber1-1/+1
To be passed to object_initialize(). Since commit 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 the argument is void*, so drop some superfluous (BusState *) casts or direct parent field usages. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-08-30scsi: Pass size to scsi_bus_new()Andreas Färber8-9/+13
To be passed to qbus_create_inplace(). Use DEVICE() casts instead of direct parent field access. Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-29spapr: Rename 'dprintf' to 'DPRINTF'Peter Maydell1-28/+29
'dprintf' is the name of a POSIX standard function so we should not be stealing it for our debug macro. Rename to 'DPRINTF' (in line with a number of other source files.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Acked-by: Richard Henderson <rth@twiddle.net> Acked-by: Kevin Wolf <kwolf@redhat.com> Message-id: 1375100199-13934-5-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-07-29devices: Associate devices to their logical categoryMarcel Apfelbaum8-0/+11
The category will be used to sort the devices displayed in the command line help. Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Message-id: 1375107465-25767-4-git-send-email-marcel.a@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-07-29spapr-vscsi: fix SOLNT bit in SRP_RSPAlexey Kardashevskiy1-2/+3
The driver calculates SOLNT bit from UCSOLNT and SCSOLNT bits from the request. The iu pointer has a type of srp_iu* which points to a union, so cmd and rsp overlap. As the vscsi_send_rsp function calls memset(iu, 0, sizeof(rsp)), it clears first 36 bytes of both cmd and rsp so cmd.sol_not is always zero at the moment of calculating rsp.sol_not. This fixes the bug. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Message-id: 1375073319-17488-1-git-send-email-aik@ozlabs.ru Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-07-29pseries: savevm support for PAPR virtual SCSIDavid Gibson1-1/+81
This patch adds the necessary support for saving the state of the PAPR VIO virtual SCSI device. This also saves and restores active SCSI requests. [aik: implemented vscsi_req save/restore] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Message-id: 1374175984-8930-8-git-send-email-aliguori@us.ibm.com Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-07-29pseries: rework PAPR virtual SCSIAlexey Kardashevskiy1-93/+130
The patch reimplements handling of indirect requests in order to simplify upcoming live migration support. - all pointers (except SCSIRequest*) were replaces with integer indexes and offsets; - DMA'ed srp_direct_buf kept untouched (ie. BE format); - vscsi_fetch_desc() is added, now it is the only place where descriptors are fetched and byteswapped; - vscsi_req struct fields converted to migration-friendly types; - many dprintf()'s fixed. This also removed an unused field 'lun' from the spapr_vscsi device which is assigned, but never used. So, remove it. [David Gibson: removed unused 'lun'] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Message-id: 1374175984-8930-7-git-send-email-aliguori@us.ibm.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-07-23scsi: Improve error propagation for scsi_bus_legacy_handle_cmdline()Andreas Färber7-14/+49
Let scsi_bus_legacy_add_drive() and scsi_bus_legacy_handle_cmdline() return an Error**. Prepare qdev initfns for QOM realize error model. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23megasas: Legacy command line handling fixAndreas Färber1-1/+4
Only apply legacy command line handling when the device has not been hot-plugged. Propagate failure of legacy command line handling. Cc: qemu-stable@nongnu.org Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/esp: Use QOM realize for scsi espHu Tao1-8/+11
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> [AF: Drop sysbus_esp_init()] Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/esp: QOM'ify some moreHu Tao1-8/+13
Introduce type constant and avoid DO_UPCAST(). Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> [AF: Renamed parent field] Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/esp-pci: QOM parent field cleanupAndreas Färber1-6/+9
Replace direct uses of PCIESPState::dev with QOM casts and rename it to parent_obj. Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/esp-pci: QOM Upcast SweepPeter Crosthwaite1-5/+9
Define and use standard QOM cast macro. Remove usages of DO_UPCAST() and direct -> style upcasting. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/megasas: QOM parent field cleanupAndreas Färber1-20/+26
Replace direct uses of MegasasState::dev with QOM casts and rename it to parent_obj. Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/megasas: QOM Upcast SweepPeter Crosthwaite1-5/+10
Define and use standard QOM cast macro. Remove usages of DO_UPCAST() and direct -> style upcasting. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/lsi53c895a: QOM parent field cleanupAndreas Färber1-19/+27
Replace direct uses of LSIState::dev with QOM casts and rename it to parent_obj. Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23scsi/lsi53c895a: QOM Upcast SweepPeter Crosthwaite1-10/+16
Define and use standard QOM cast macro. Remove usages of DO_UPCAST() and direct -> style upcasting. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23hw: Avoid use of QOM type name macros in VMStateDescriptionsPeter Maydell1-2/+2
The name field in a VMStateDescription is part of the migration state versioning, so changing it will break migration. It's therefore a bad idea to use a QOM typename macro to initialize it, because in general we're free to rename QOM types as part of code refactoring and cleanup. For the handful of devices that were doing this by mistake, replace the QOM typenames with the corresponding literal strings. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> [AF: Use TYPE_PVSCSI for TypeInfo instead] Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-04hw/s*: pass owner to memory_region_init* functionsPaolo Bonzini5-10/+14
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04memory: add owner argument to initialization functionsPaolo Bonzini5-9/+9
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04dma: keep a device alive while it has SGListsPaolo Bonzini1-4/+6
Reviewed-by: Anthony Liguori <aliguori@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04scsi: keep device alive while it has requestsPaolo Bonzini1-2/+10
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-20dma: eliminate DMAContextPaolo Bonzini3-4/+4
The DMAContext is a simple pointer to an AddressSpace that is now always already available. Make everyone hold the address space directly, and clean up the DMA API to use the AddressSpace directly. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-18vhost-scsi: fix k->set_guest_notifiers() NULL dereferenceStefan Hajnoczi1-1/+1
Coverity picked up a copy-paste bug. In vhost_scsi_start() we check for !k->set_guest_notifiers and error out. The check probably got copied but instead of erroring we actually use the function pointer! Cc: Nicholas Bellinger <nab@linux-iscsi.org> Cc: Asias He <asias@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-18scsi-disk: scsi-block device for scsi pass-through should not be removablePavel Hrdina1-3/+11
This patch adds a new SCSI_DISK_F_NO_REMOVABLE_DEVOPS feature. By this feature we can set that the scsi-block (scsi pass-through) device will still be removable from the guest side, but from monitor it cannot be removed. Cc: qemu-stable@nongnu.org Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-18scsi-generic: check the return value of bdrv_aio_ioctl in execute_commandPavel Hrdina1-0/+3
This fixes the bug introduced by this commit ad54ae80c73f. The bdrv_aio_ioctl() still could return null and we should return an error in that case. Cc: qemu-stable@nongnu.org Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-18scsi-generic: fix sign extension of READ CAPACITY(10) dataPaolo Bonzini1-2/+3
Issuing the READ CAPACITY(10) command in the guest will cause QEMU to update its knowledge of the maximum accessible LBA in the disk. The recorded maximum LBA will be wrong if the disk is bigger than 1TB, because ldl_be_p returns a signed int. When this is fixed, a latent bug will be unmasked. If the READ CAPACITY(10) command reported an overflow (0xFFFFFFFF), we must not overwrite the previously-known maximum accessible LBA, or the guest will fail to access the disk above the first 2TB. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-18scsi: reset cdrom tray statuses on scsi_disk_resetPavel Hrdina1-0/+3
Tray statuses should be also reset. Some guests may lock the tray and right after resetting the guest it should be unlocked and closed. This is done on power-on, reset and resume from suspend/hibernate on bare-metal. This fix is already committed for IDE CD. Check the commit a7f3d65b65b8c86a5ff0c0abcfefb45e2ec6fe4c. Test results on bare-metal: - on reset/power-on the CD-ROM tray is closed even before the monitor is turned on - on resume from suspend/hibernate the tray is also closed before the monitor is turned on From test results it seems that this behavior is OS and probably BIOS independent. Cc: qemu-stable@nongnu.org Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-11hw/scsi: Don't increment a boolean valueStefan Weil1-1/+1
This fixes a warning from cppcheck. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-05-24exec: eliminate qemu_put_ram_ptrPaolo Bonzini1-1/+0
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-03virtio-scsi: fix the command line compatibility.KONRAD Frederic1-1/+2
The bus name is wrong since the refactoring. This keeps the behaviour of the command line. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Message-id: 1367330931-12994-6-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-05-03scsi: add bus_name parameter to scsi_bus_new.KONRAD Frederic8-9/+10
This adds the possibility to create a scsi-bus with a specified name. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Message-id: 1367330931-12994-4-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-26pseries: Convert VIO code to QOM style type safe(ish) castsDavid Gibson1-6/+9
Curerntly the pseries VIO device code contains quite a few explicit uses of DO_UPCAST and plain C casts. This is (obviously) type unsafe, and not the conventional way of doing things in the QOM model. This patch converts the code to use the QOM convention of per-type macros to do verified casts with OBJECT_CHECK(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
2013-04-24virtio: cleanup: init and exit function.KONRAD Frederic1-1/+1
This clean the init and the exit functions and rename virtio_common_cleanup to virtio_cleanup. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-7-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-24virtio: remove virtiobindings.KONRAD Frederic1-5/+9
This remove virtio-bindings, and use class instead. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-6-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-24virtio: remove the function pointer.KONRAD Frederic2-10/+0
This remove the function pointer in VirtIODevice, and use only VirtioDeviceClass function pointer. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-5-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-19vhost-scsi: new device supporting the tcm_vhost Linux kernel moduleNicholas Bellinger2-1/+293
The WWPN specified in configfs is passed to "-device vhost-scsi-pci". The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not available from the QEMU command-line. Instead, I hardcode it to zero. Changes in Patch-v2: - Add vhost_scsi_get_features() in order to determine feature bits supports by host kernel (mst + nab) - Re-enable usage of DEFINE_VIRTIO_COMMON_FEATURES, and allow EVENT_IDX to be disabled by host in vhost_scsi_get_features() - Drop unused hotplug bit in DEFINE_VHOST_SCSI_PROPERTIES Changes in Patch-v1: - Set event_idx=off by default (nab, thanks asias) - Disable hotplug feature bit for v3.9 tcm_vhost kernel code, need to re-enable in v3.10 (nab) - Update to latest qemu.git/master HEAD Changes in WIP-V3: - Drop ioeventfd vhost_scsi_properties (asias, thanks stefanha) - Add CONFIG_VHOST_SCSI (asias, thanks stefanha) - Add hotplug feature bit Changes in WIP-V2: - Add backend guest masking support (nab) - Bump ABI_VERSION to 1 (nab) - Set up set_guest_notifiers (asias) - Set up vs->dev.vq_index (asias) - Drop vs->vs.vdev.{set,clear}_vhost_endpoint (asias) - Drop VIRTIO_CONFIG_S_DRIVER check in vhost_scsi_set_status (asias) Howto: Use the latest seabios, at least commit b44a7be17b git clone git://git.seabios.org/seabios.git make cp out/bios.bin /usr/share/qemu/bios.bin qemu -device vhost-scsi-pci,wwpn=naa.6001405bd4e8476d,event_idx=off ... Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Asias He <asias@redhat.com> [ Rebase on top of VirtIOSCSICommon patch, fix bugs in feature negotiation and irqfd masking - Paolo ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-19virtio-scsi: create VirtIOSCSICommonPaolo Bonzini1-140/+72
This patch refactors existing virtio-scsi code into VirtIOSCSICommon in order to allow virtio_scsi_init_common() to be used by both internal virtio_scsi_init() and external vhost-scsi-pci code. Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Asias He <asias@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-19scsi: VMWare PVSCSI paravirtual device implementationDmitry Fleytman3-0/+1651
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com> Signed-off-by: Yan Vugenfirer <yan@daynix.com> [ Rename files to vmw_pvscsi, fix setting of hostStatus in pvscsi_request_cancelled - Paolo ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-19scsi: avoid assertion failure on VERIFY commandPaolo Bonzini1-5/+14
A verify command is not an actual read (we do not implement compare mode) and thus does not have an AIOCB attached. Do not crash in scsi_dma_complete. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-08hw: move private headers to hw/ subdirectories.Paolo Bonzini5-3/+1708
Many headers are used only in a single directory. These can be kept in hw/. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-08hw: move SCSI controllers to hw/scsi/, configure via default-configs/Paolo Bonzini2-0/+983
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-08hw: move virtio devices to hw/ subdirectoriesPaolo Bonzini2-0/+775
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-08hw: move target-independent files to subdirectoriesPaolo Bonzini8-0/+10531
This patch tackles all files that are compiled once, moving them to subdirectories of hw/. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-08hw: make subdirectories for devicesPaolo Bonzini1-0/+0
Prepare the new directory structure. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>