Statistics
| Branch: | Revision:

root / hw / scsi-disk.c @ 7ad7e3c3

History | View | Annotate | Download (31 kB)

# Date Author Comment
f8a83245 01/27/2010 12:41 am Herve Poussineau

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 (ie
VirtualAlloc) but frees it with qemu_free (ie free).
Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks....

383b4d9b 01/20/2010 12:31 am Gerd Hoffmann

scsi: device version property

This patch adds a new property named 'ver' to scsi-disk which allows to
specify the version which the virtual disk/cdrom should report to the
guest. By default this is the qemu version (i.e. 0.12). usage:

-drive if=none,id=disk,file=......
ad3cea42 12/13/2009 12:55 pm Artyom Tarasenko

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 too
small to transfer all of the parameters, the additional length shall...

407f879a 12/04/2009 08:08 pm Blue Swirl

scsi: fix incorrect ?: use

Fixes OpenBSD build.

Signed-off-by: Blue Swirl <>

550fe6c6 12/03/2009 11:25 pm Laszlo Ast

SCSI: Fix Standard INQUIRY data

Vendor identification, product identification and product revision level
should be padded with spaces without a terminating NULL character, see
SCSI-2 standard, 8.2.5.1 Standard INQUIRY data.

Signed-off-by: Laszlo Ast <>...

f7850099 12/03/2009 07:45 pm Kevin Wolf

Rename DriveInfo.onerror to on_write_error

Either rename variables and functions to refer to write errors (which is what
they actually do) or introduce a parameter to distinguish reads and writes.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

38215553 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: GET_CONFIGURATION

Move GET_CONFIGURATION emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add GET_CONFIGURATION to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <>...

5dd90e2a 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: SERVICE_ACTION_IN

Move SERVICE_ACTION_IN emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add SERVICE_ACTION_IN to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <>...

39ec9a50 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: REPORT_LUNS

Move REPORT_LUNS emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add REPORT_LUNS to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

88f8a5ed 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: VERIFY

Move VERIFY emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

bd536cf3 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add read/write 16 commands.

Add READ_16 + friends to scsi-defs.h, scsi_command_name() and the
request parsing helper functions.

Use them in scsi-disk.c too.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

0b06c059 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: INQUIRY

Move INQUIRY emulation from scsi_send_command() to
scsi_disk_emulate_command(). Also split the longish INQUITY emulation
code into the new scsi_disk_emulate_inquiry() function. Serial number
handling is slightly changed, we don't copy it any more but look it up...

3d53ba18 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: RESERVE+RELEASE

Move RESERVE+RELEASE emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

ebddfcbe 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: MODE_SENSE

Move MODE_SENSE emulation from scsi_send_command() to
scsi_disk_emulate_command(). Create two helper functions:
mode_sense_page() which writes the actual mode pages and
scsi_disk_emulate_mode_sense() which holds the longish MODE_SENSE...

8d3628ff 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: START_STOP

Move START_STOP emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

c68b9f34 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: ALLOW_MEDIUM_REMOVAL

Move ALLOW_MEDIUM_REMOVAL emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

e7e25e32 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: READ_CAPACITY

Move READ_CAPACITY emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

fc903943 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: SYNCHRONIZE_CACHE

Move SYNCHRONIZE_CACHE emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

02880f43 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: READ_TOC

Move READ_TOC emulation from scsi_send_command() to
scsi_disk_emulate_command(). Add scsi_disk_emulate_read_toc() function
which holds the longisch READ_TOC emulation code.

Signed-off-by: Gerd Hoffmann <>...

aa5dbdc1 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: core + TEST_UNIT_READY.

Add new scsi_disk_emulate_command() function, which will -- when
finished -- handle all scsi disk command emulation except actual I/O
(READ+WRITE commands) which goes to the block layer. The function...

51ad87c9 12/03/2009 05:41 pm Gerd Hoffmann

scsi-disk: restruct emulation: REQUEST_SENSE

Move REQUEST_SENSE emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

37659e51 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move sense to SCSIDevice, create SCSISense struct.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

251882b7 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move dinfo to SCSIDevice

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

ed3a34a3 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move status to SCSIRequest.

Also add and use the scsi_req_complete() helper function for calling the
completion callback.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

4c41d2ef 12/03/2009 05:41 pm Gerd Hoffmann

scsi: create common SCSIRequest structure.

Rename the SCSIRequest structs in scsi-disk.c and scsi-generic.c to
SCSIDiskReq and SCSIGenericReq. Create a SCSIRequest struct and move
the common elements over.

Signed-off-by: Gerd Hoffmann <>...

9af99d98 12/03/2009 05:41 pm Gerd Hoffmann

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....

89b08ae1 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move SCSIRequest management to common code.

Create generic functions to allocate, find and release SCSIRequest
structs. Make scsi-disk and scsi-generic use them.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

b07995e3 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move blocksize from SCSIGenericState to SCSIDevice

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

0d65e1f8 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add scsi-defs.h

Largely based on <scsi/scsi.h> from linux. Added into the tree so we
can use the defines everywhere, not just in scsi-generic.c (which is
linux-specific).

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

91376656 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move type from SCSIGenericState to SCSIDevice

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

ebf46023 12/03/2009 05:41 pm Gerd Hoffmann

scsi: use command defines in scsi-disk.c

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

43b443b6 11/09/2009 04:43 pm Gerd Hoffmann

scsi: move scsi-disk.h -> scsi.h

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

c79662f7 11/09/2009 04:43 pm Naphtali Sprei

Pass the drive's readonly attribute to the guest OS

Implemented for virtio-blk and for scsi

Signed-off-by: Naphtali Sprei <>
Signed-off-by: Anthony Liguori <>

6550f2e6 10/14/2009 09:31 pm Artyom Tarasenko

scsi disk block descriptor v2

The SCSI-2 documentation suggests, that although the block
descriptor 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...

56a14938 10/05/2009 05:32 pm Gerd Hoffmann

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...

01985dcf 10/05/2009 05:32 pm Gerd Hoffmann

Implement scsi device destruction

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

e900a7b7 09/11/2009 06:19 pm Christoph Hellwig

block: add enable_write_cache flag

Add a enable_write_cache flag in the block driver state, and use it to
decide if we claim to have a volatile write cache that needs controlled
flushing from the guest. The flag is off if cache=writethrough is
defined because O_DSYNC guarantees that every write goes to stable...

d52affa7 09/09/2009 10:57 pm Gerd Hoffmann

qdev/scsi: add scsi bus support to qdev, convert drivers.

  • Add SCSIBus. * Add SCSIDeviceInfo, move device callbacks here. * add qdev/scsi helper functions. * convert drivers.

Adding scsi disks via -device works now, i.e. you can do:

-drive id=sda,if=none,......
213189ab 07/30/2009 05:50 pm Markus Armbruster

Fix VM state change handlers running out of order

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...

0bf9e31a 07/20/2009 08:19 pm Blue Swirl

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' * /* *//*

Signed-off-by: Blue Swirl <>

001faf32 05/13/2009 08:53 pm Blue Swirl

Replace gcc variadic macro extension with C99 version

Signed-off-by: Blue Swirl <>

3f4cb3d3 04/13/2009 07:31 pm blueswir1

Fix OpenSolaris gcc4 warnings: iovec type mismatches, missing 'static'

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7103 c046a42c-6fe2-441c-8c8c-71466251a162

c87c0672 04/07/2009 09:43 pm aliguori

remove bdrv_aio_read/bdrv_aio_write (Christoph Hellwig)

Always use the vectored APIs to reduce code churn once we switch the BlockDriver
API to be vectored.

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Anthony Liguori <>...

58a2c436 03/29/2009 06:40 pm blueswir1

Misc scsi disk/cdrom fixes/improvements 4/4

Implement Test Unit Ready command (return NOT READY as above
if !bdrv_is_inserted(...))

Signed-off-by: Juergen Lock <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6954 c046a42c-6fe2-441c-8c8c-71466251a162

ed6a9b30 03/29/2009 06:40 pm blueswir1

misc scsi disk/cdrom fixes/improvements 3/4

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 <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6953 c046a42c-6fe2-441c-8c8c-71466251a162

b2056c16 03/29/2009 06:40 pm blueswir1

misc scsi disk/cdrom fixes/improvements 2/4

Implement cdrom load/eject functionality (Start Stop Unit command)

Signed-off-by: Juergen Lock <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6952 c046a42c-6fe2-441c-8c8c-71466251a162

ee16b24a 03/29/2009 06:39 pm blueswir1

misc scsi disk/cdrom fixes/improvements 1/4

Use correct sector size for cdrom Read TOC command

Signed-off-by: Juergen Lock <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6951 c046a42c-6fe2-441c-8c8c-71466251a162

274fb0e1 01/29/2009 09:59 pm aliguori

check SCSI read/write requests against max LBA (Rik van Riel)

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...

c1c0438c 01/28/2009 11:58 pm aliguori

SCSI divide capacity by s->cluster_size (Rik van Riel)

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...

86106e59 01/28/2009 11:58 pm aliguori

support >2TB SCSI disks (Rik van Riel)

Implement SCSI READ, WRITE and SAI READ CAPACITY 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...

e035b43d 01/28/2009 11:58 pm aliguori

fix signed/unsigned overflows in SCSI disk (Rik van Riel)

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...

ea8a5d7f 01/22/2009 09:52 pm aliguori

Stop VM on error in scsi-disk (Gleb Natapov)

Signed-off-by: Gleb Natapov <>
Signed-off-by: Anthony Liguori <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6409 c046a42c-6fe2-441c-8c8c-71466251a162

00766a4e 01/14/2009 08:08 pm blueswir1

Make OpenBSD sparc-softmmu compile warning free

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6299 c046a42c-6fe2-441c-8c8c-71466251a162

fa879c64 01/07/2009 07:32 pm aliguori

add "serial" parameter to -drive flag (Gleb Natapov)

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 <>...

57575058 12/07/2008 05:12 am balrog

SCSI: Handle inquiry commands of varying length (Justin Chevrier).

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...

22864256 10/11/2008 12:33 pm blueswir1

Correct SCSI error reporting (Laurent Vivier)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5455 c046a42c-6fe2-441c-8c8c-71466251a162

f0f72ffe 10/02/2008 12:46 am aurel32

qemu: improve scsi dma speed by increasing the dma buffer size

taken from Xen 17267:f4a92f0db20f, original patch by Samuel Thibault.

Signed-off-by: Avi Kivity <>
Signed-off-by: Anthony Liguori <>
Signed-off-by: Aurelien Jarno <>...

5e65a310 07/02/2008 06:16 pm blueswir1

Add rigid and flexible disk geometry page support

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4821 c046a42c-6fe2-441c-8c8c-71466251a162

1235fc06 06/03/2008 10:51 pm ths

Spelling fixes, by Stefan Weil.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4655 c046a42c-6fe2-441c-8c8c-71466251a162

b1fa7164 04/29/2008 07:08 pm blueswir1

Revert v4260, breaks Sparc32

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4280 c046a42c-6fe2-441c-8c8c-71466251a162

47e4ca5a 04/26/2008 06:56 pm balrog

Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4260 c046a42c-6fe2-441c-8c8c-71466251a162

1d4db89c 02/03/2008 06:05 am balrog

Implement more INQUIRY command replies for scsi disk (Igor Kovalenko).

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3955 c046a42c-6fe2-441c-8c8c-71466251a162

33f00271 12/24/2007 04:33 pm balrog

Add "cache" parameter to "-drive" (Laurent Vivier).

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3848 c046a42c-6fe2-441c-8c8c-71466251a162

96b8f136 12/17/2007 03:35 am ths

Fix bdrv_get_geometry to return uint64_t, by Andre Przywara.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3825 c046a42c-6fe2-441c-8c8c-71466251a162

8ccc2ace 12/10/2007 04:58 am ths

SCSI cleanup, by Laurent Vivier.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3797 c046a42c-6fe2-441c-8c8c-71466251a162

87ecb68b 11/17/2007 07:14 pm pbrook

Break up vl.h.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3674 c046a42c-6fe2-441c-8c8c-71466251a162

e91c8a77 06/03/2007 04:35 pm ths

Spelling fixes, by Stefan Weil.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2927 c046a42c-6fe2-441c-8c8c-71466251a162

67cd24a8 04/28/2007 11:47 pm ths

Buffer length fixes, by Wang Cheng Yeh.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2736 c046a42c-6fe2-441c-8c8c-71466251a162

a917d384 08/29/2006 07:52 am pbrook

SCSI TCQ support.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2139 c046a42c-6fe2-441c-8c8c-71466251a162

a9f277ba 08/19/2006 02:58 pm bellard

no need for bdrv_close()

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2125 c046a42c-6fe2-441c-8c8c-71466251a162

35f1df84 08/14/2006 06:08 pm pbrook

scsi empty drive fix (Blue Swirl).

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2109 c046a42c-6fe2-441c-8c8c-71466251a162

4d611c9a 08/12/2006 04:04 am pbrook

SCSI and USB async IO support.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2107 c046a42c-6fe2-441c-8c8c-71466251a162

1aacf348 08/06/2006 04:27 pm pbrook

Add missing #define.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2092 c046a42c-6fe2-441c-8c8c-71466251a162

51c1ebb1 08/06/2006 02:31 pm pbrook

Fix SCSI off-by-one device size.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2091 c046a42c-6fe2-441c-8c8c-71466251a162

7a6cba61 06/04/2006 02:39 pm pbrook

Disk cache flush support.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1949 c046a42c-6fe2-441c-8c8c-71466251a162

17acfe32 06/03/2006 05:23 pm pbrook

More SCSI commands (Blue Swirl).

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1948 c046a42c-6fe2-441c-8c8c-71466251a162

7d8406be 05/30/2006 04:48 am pbrook

PCI SCSI HBA emulation.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1946 c046a42c-6fe2-441c-8c8c-71466251a162

0fc5c15a 05/27/2006 12:53 am pbrook

SCSI lun probing fix.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1945 c046a42c-6fe2-441c-8c8c-71466251a162

cac782d4 05/26/2006 09:08 pm pbrook

Small read fix.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1944 c046a42c-6fe2-441c-8c8c-71466251a162

7c22dd52 05/26/2006 07:46 pm pbrook

Fix scsi sector size confusion (Blue Swirl).
Fix short TOC read.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1942 c046a42c-6fe2-441c-8c8c-71466251a162

2e5d83bb 05/26/2006 02:58 am pbrook

Rearrange SCSI disk emulation code.
Add USB mass storage device emulation.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1940 c046a42c-6fe2-441c-8c8c-71466251a162