summaryrefslogtreecommitdiffstats
path: root/hw/scsi-disk.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix VM state change handlers running out of orderMarkus Armbruster2009-07-301-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a VM state change handler changes VM state, other VM state change handlers can see the state transitions out of order. bmdma_map(), scsi_disk_init() and virtio_blk_init() install VM state change handlers to restart DMA. These handlers can vm_stop() by running into a write error on a drive with werror=stop. This throws the VM state change handler callback into disarray. Here's an example case I observed: 0. The virtual IDE drive goes south. All future writes return errors. 1. Something encounters a write error, and duly stops the VM with vm_stop(). 2. vm_stop() calls vm_state_notify(0). 3. vm_state_notify() runs the callbacks in list vm_change_state_head. It contains ide_dma_restart_cb() installed by bmdma_map(). It also contains audio_vm_change_state_handler() installed by audio_init(). 4. audio_vm_change_state_handler() stops audio stuff. 5. User continues VM with monitor command "c". This runs vm_start(). 6. vm_start() calls vm_state_notify(1). 7. vm_state_notify() runs the callbacks in vm_change_state_head. 8. ide_dma_restart_cb() happens to come first. It does its work, runs into a write error, and duly stops the VM with vm_stop(). 9. vm_stop() runs vm_state_notify(0). 10. vm_state_notify() runs the callbacks in vm_change_state_head. 11. audio_vm_change_state_handler() stops audio stuff. Which isn't running. 12. vm_stop() finishes, ide_dma_restart_cb() finishes, step 7's vm_state_notify() resumes running handlers. 13. audio_vm_change_state_handler() starts audio stuff. Oopsie. Fix this by moving the actual write from each VM state change handler into a new bottom half (suggested by Gleb Natapov). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix most warnings (errors with -Werror) when debugging is enabledBlue Swirl2009-07-201-6/+6
| | | | | | | I used the following command to enable debugging: perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * */* */*/* Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Replace gcc variadic macro extension with C99 versionBlue Swirl2009-05-131-5/+5
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix OpenSolaris gcc4 warnings: iovec type mismatches, missing 'static'blueswir12009-04-131-2/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7103 c046a42c-6fe2-441c-8c8c-71466251a162
* remove bdrv_aio_read/bdrv_aio_write (Christoph Hellwig)aliguori2009-04-071-62/+63
| | | | | | | | | | | | Always use the vectored APIs to reduce code churn once we switch the BlockDriver API to be vectored. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7019 c046a42c-6fe2-441c-8c8c-71466251a162
* Misc scsi disk/cdrom fixes/improvements 4/4blueswir12009-03-291-0/+3
| | | | | | | | | | Implement Test Unit Ready command (return NOT READY as above if !bdrv_is_inserted(...)) Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6954 c046a42c-6fe2-441c-8c8c-71466251a162
* misc scsi disk/cdrom fixes/improvements 3/4blueswir12009-03-291-1/+9
| | | | | | | | | | | Add asc 0x3a, ascq 0: Medium not present to NOT READY sense (needed to keep some guests from retrying causing long sleeps in the kernel) Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6953 c046a42c-6fe2-441c-8c8c-71466251a162
* misc scsi disk/cdrom fixes/improvements 2/4blueswir12009-03-291-0/+4
| | | | | | | | | Implement cdrom load/eject functionality (Start Stop Unit command) Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6952 c046a42c-6fe2-441c-8c8c-71466251a162
* misc scsi disk/cdrom fixes/improvements 1/4blueswir12009-03-291-0/+1
| | | | | | | | | Use correct sector size for cdrom Read TOC command Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6951 c046a42c-6fe2-441c-8c8c-71466251a162
* check SCSI read/write requests against max LBA (Rik van Riel)aliguori2009-01-291-0/+18
| | | | | | | | | | | | | | | | | | | | | The bdrv layer uses a signed offset. Furthermore, block-raw-posix only seeks when that offset is positive. Passing a negative offset to block-raw-posix can result in data being written at the current seek cursor's position. It may be possible to exploit this to seek to the end of the disk and extend the virtual disk by writing data to a negative sector offset. After a reboot, this could lead to the guest having a larger disk than it had before. Close the hole by sanity checking the lba against the size of the disk. Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6475 c046a42c-6fe2-441c-8c8c-71466251a162
* SCSI divide capacity by s->cluster_size (Rik van Riel)aliguori2009-01-281-0/+2
| | | | | | | | | | | | | | | | | | | Paul Brook pointed out that the number of sectors reported by the SCSI read capacity commands needs to be divided by s->cluster_size, because bdrv_get_geometry reports the number of 512 byte sectors, while emulated CDROMs report 2048 byte sectors back to the guest. This has no consequences for emulated hard disks, which use a cluster size of 1. aliguori: fixed typo Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6469 c046a42c-6fe2-441c-8c8c-71466251a162
* support >2TB SCSI disks (Rik van Riel)aliguori2009-01-281-7/+46
| | | | | | | | | | | | | | | | | Implement SCSI READ(16), WRITE(16) and SAI READ CAPACITY(16) commands, so SCSI disks larger than 2TB can work with guests that support these newer SCSI commands. The cast to (uint64_t) is needed because otherwise gcc will use a signed int, which gets sign extended into uint64_t lba, resulting in bad block numbers for READ 10 and READ 16 with block numbers larger than 2^31. Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6468 c046a42c-6fe2-441c-8c8c-71466251a162
* fix signed/unsigned overflows in SCSI disk (Rik van Riel)aliguori2009-01-281-3/+6
| | | | | | | | | | | | | | | | | | | Sector numbers can overflow on a virtual scsi disk of over 1TB in size. Qemu's bdrv_read expects an int64_t, so fix the overflow by going to that data type. On large disks, we clip the capacity to 2TB instead of returning "capacity modulo 2TB". Turn sector_count into an unsigned to prevent a signed/unsigned overflow with SCSI transfers larger than 2TB. We're unlikely to ever hit this bug, but fixing it is just one line. Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6467 c046a42c-6fe2-441c-8c8c-71466251a162
* Stop VM on error in scsi-disk (Gleb Natapov)aliguori2009-01-221-17/+69
| | | | | | | | Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6409 c046a42c-6fe2-441c-8c8c-71466251a162
* Make OpenBSD sparc-softmmu compile warning freeblueswir12009-01-141-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6299 c046a42c-6fe2-441c-8c8c-71466251a162
* add "serial" parameter to -drive flag (Gleb Natapov)aliguori2009-01-071-4/+13
| | | | | | | | | | | | | Windows calculates HW "uniqueness" based on a hard drive serial number among other things. The patch allows to specify drive serial number from a command line. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6214 c046a42c-6fe2-441c-8c8c-71466251a162
* SCSI: Handle inquiry commands of varying length (Justin Chevrier).balrog2008-12-071-3/+8
| | | | | | | | | | | | | | | | Openserver 5.0.5 sends an Inquiry command to the emulated SCSI disk expecting a response length of 40 bytes. Currently the response to an Inquiry command is hardcoded to 36 bytes. When receiving a response of length 36 instead of 40 Openserver panics. Modifications to original patch based on feedback from Ryan Harper and Paul Brook. Thanks guys. Signed-off-by: Justin Chevrier <address@hidden> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5903 c046a42c-6fe2-441c-8c8c-71466251a162
* Correct SCSI error reporting (Laurent Vivier)blueswir12008-10-111-15/+27
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5455 c046a42c-6fe2-441c-8c8c-71466251a162
* qemu: improve scsi dma speed by increasing the dma buffer sizeaurel322008-10-011-1/+1
| | | | | | | | | | taken from Xen 17267:f4a92f0db20f, original patch by Samuel Thibault. Signed-off-by: Avi Kivity <avi@qumranet.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5385 c046a42c-6fe2-441c-8c8c-71466251a162
* Add rigid and flexible disk geometry page supportblueswir12008-07-021-1/+70
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4821 c046a42c-6fe2-441c-8c8c-71466251a162
* Spelling fixes, by Stefan Weil.ths2008-06-031-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4655 c046a42c-6fe2-441c-8c8c-71466251a162
* Revert v4260, breaks Sparc32blueswir12008-04-291-24/+13
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4280 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).balrog2008-04-261-13/+24
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4260 c046a42c-6fe2-441c-8c8c-71466251a162
* Implement more INQUIRY command replies for scsi disk (Igor Kovalenko).balrog2008-02-031-4/+125
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3955 c046a42c-6fe2-441c-8c8c-71466251a162
* Add "cache" parameter to "-drive" (Laurent Vivier).balrog2007-12-241-1/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3848 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix bdrv_get_geometry to return uint64_t, by Andre Przywara.ths2007-12-171-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3825 c046a42c-6fe2-441c-8c8c-71466251a162
* SCSI cleanup, by Laurent Vivier.ths2007-12-101-24/+38
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3797 c046a42c-6fe2-441c-8c8c-71466251a162
* Break up vl.h.pbrook2007-11-171-1/+3
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3674 c046a42c-6fe2-441c-8c8c-71466251a162
* Spelling fixes, by Stefan Weil.ths2007-06-031-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2927 c046a42c-6fe2-441c-8c8c-71466251a162
* Buffer length fixes, by Wang Cheng Yeh.ths2007-04-281-4/+5
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2736 c046a42c-6fe2-441c-8c8c-71466251a162
* SCSI TCQ support.pbrook2006-08-291-231/+263
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2139 c046a42c-6fe2-441c-8c8c-71466251a162
* no need for bdrv_close()bellard2006-08-191-1/+0
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2125 c046a42c-6fe2-441c-8c8c-71466251a162
* scsi empty drive fix (Blue Swirl).pbrook2006-08-141-0/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2109 c046a42c-6fe2-441c-8c8c-71466251a162
* SCSI and USB async IO support.pbrook2006-08-121-34/+118
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2107 c046a42c-6fe2-441c-8c8c-71466251a162
* Add missing #define.pbrook2006-08-061-0/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2092 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix SCSI off-by-one device size.pbrook2006-08-061-9/+15
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2091 c046a42c-6fe2-441c-8c8c-71466251a162
* Disk cache flush support.pbrook2006-06-041-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1949 c046a42c-6fe2-441c-8c8c-71466251a162
* More SCSI commands (Blue Swirl).pbrook2006-06-031-20/+72
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1948 c046a42c-6fe2-441c-8c8c-71466251a162
* PCI SCSI HBA emulation.pbrook2006-05-301-14/+28
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1946 c046a42c-6fe2-441c-8c8c-71466251a162
* SCSI lun probing fix.pbrook2006-05-261-3/+4
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1945 c046a42c-6fe2-441c-8c8c-71466251a162
* Small read fix.pbrook2006-05-261-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1944 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix scsi sector size confusion (Blue Swirl).pbrook2006-05-261-38/+41
| | | | | | | Fix short TOC read. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1942 c046a42c-6fe2-441c-8c8c-71466251a162
* Rearrange SCSI disk emulation code.pbrook2006-05-251-0/+408
Add USB mass storage device emulation. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1940 c046a42c-6fe2-441c-8c8c-71466251a162
OpenPOWER on IntegriCloud