Statistics
| Branch: | Revision:

root / hw / scsi-generic.c @ 43997225

History | View | Annotate | Download (14.1 kB)

# Date Author Comment
56b1fc48 02/22/2012 02:29 pm Paolo Bonzini

scsi-generic: add migration support

Signed-off-by: Paolo Bonzini <>

83f7d43a 02/15/2012 05:39 pm Andreas Färber

qom: Unify type registration

Replace device_init() with generalized type_init().

While at it, unify naming convention: type_init([$prefix_]register_types)
Also, type_init() is a function, so add preceding blank line where
necessary and don't put a semicolon after the closing brace....

39bffca2 02/03/2012 06:41 pm Anthony Liguori

qdev: register all types natively through QEMU Object Model

This was done in a mostly automated fashion. I did it in three steps and then
rebased it into a single step which avoids repeatedly touching every file in
the tree.

The first step was a sed-based addition of the parent type to the subclass...

b9eea3e6 01/27/2012 06:50 pm Anthony Liguori

scsi: convert to QEMU Object Model

Signed-off-by: Anthony Liguori <>

6a84cb1f 01/06/2012 05:07 pm Markus Armbruster

scsi virtio-blk usb-msd: Clean up device init error messages

Replace

error_report("DEVICE-NAME: MESSAGE");

by just

error_report("MESSAGE");

in block device init functions.

DEVICE-NAME is bogus in some cases: it's "scsi-disk" for device
scsi-hd and scsi-cd, "virtio-blk-pci" for virtio-blk-s390, and...

ad54ae80 12/15/2011 01:40 pm Paolo Bonzini

block: bdrv_aio_* do not return NULL

Initially done with the following semantic patch:

rule1
expression E;
statement S;
@@
E =
(
bdrv_aio_readv | bdrv_aio_writev | bdrv_aio_flush | bdrv_aio_discard | bdrv_aio_ioctl
)
(...);
(
- if (E == NULL) { ... }...

28b77657 11/22/2011 11:33 am Paolo Bonzini

scsi-generic: add as boot device

There is no reason why a scsi-generic device cannot boot if it has
the right type, and indeed it provides already a bootindex property.
So register those devices too.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

7877903a 10/28/2011 08:25 pm Paolo Bonzini

scsi: move max_lba to SCSIDevice

The field is only in scsi-disk for now. Moving it up to SCSIDevice makes
it easier to reuse the scsi-generic reqops elsewhere.

At the same time, make scsi-generic get max_lba from snooped READ CAPACITY
commands as well....

adcf2754 10/28/2011 08:25 pm Paolo Bonzini

scsi: make reqops const

Also delete a stale occurrence of SCSIReqOps inside SCSIDeviceInfo.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

765d1525 10/28/2011 08:25 pm Paolo Bonzini

scsi: export scsi_generic_reqops

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

63db0f0e 10/28/2011 08:25 pm Paolo Bonzini

scsi: pass cdb to alloc_req

This will let scsi-block choose between passthrough and emulation.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

c9501c95 10/28/2011 08:25 pm Paolo Bonzini

scsi-generic: bump SCSIRequest reference count until aio completion runs

Same as before, but for scsi-generic.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

8869e103 10/28/2011 08:25 pm Paolo Bonzini

scsi-generic: drop SCSIGenericState

It is not needed, because s->bs is already stored in SCSIDevice, and
can be reached from the conf.bs member.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

6a58a3a6 10/28/2011 08:25 pm Paolo Bonzini

scsi-generic: remove scsi_req_fixup

This is not needed anymore, since asynchronous ioctls were introduced
by commit 221f715 (new scsi-generic abstraction, use SG_IO, 2009-03-28).

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

fe0ed712 10/28/2011 08:25 pm Paolo Bonzini

scsi-generic: check ioctl statuses when SG_IO succeeds

A succeeding ioctl does not imply that the SCSI command succeeded.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

a3b16e71 10/28/2011 08:25 pm Paolo Bonzini

scsi-generic: look at host status

Pass down the host status so that failing transport can be detected
by the guest. Similar treatment of host status could be done in
virtio-blk, too.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

9b6eef8a 10/28/2011 08:25 pm Paolo Bonzini

scsi-generic: snoop READ CAPACITY commands to get block size

Instead of "guessing" the block size when there is no medium in the
drive, wait for the guest to send a READ CAPACITY command and snoop
it from there.

Signed-off-by: Paolo Bonzini <>...

1b8f8a6f 09/19/2011 12:34 pm Paolo Bonzini

scsi-generic: do not disable FUA

I found no rationale for this in the logs, and it is quite bad because
it will make scsi-generic unsafe WRT power failures.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>
Signed-off-by: Kevin Wolf <>

9e6a4c91 09/12/2011 04:17 pm Markus Armbruster

block: Drop BlockDriverState member removable

It's a confused mess (see previous commit). No users remain.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

c7b48872 08/12/2011 04:31 pm Paolo Bonzini

scsi: report unit attention on reset

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

739df215 08/12/2011 04:31 pm Paolo Bonzini

scsi: move handling of REQUEST SENSE to common code

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

fdaef069 08/12/2011 04:30 pm Paolo Bonzini

scsi: move handling of REPORT LUNS and invalid LUNs to common code

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

87dcd1b2 08/12/2011 04:29 pm Paolo Bonzini

scsi: push lun field to SCSIDevice

This will let SCSIBus detect requests sent to an invalid LUN, and
handle them itself. However, there will be still support for only one
LUN per target

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

afa46c46 08/12/2011 04:29 pm Paolo Bonzini

scsi: move request parsing to common code

Also introduce the first occurrence of "independent" SCSIReqOps,
to handle invalid commands in common code.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

12010e7b 08/12/2011 04:27 pm Paolo Bonzini

scsi: move request-related callbacks from SCSIDeviceInfo to SCSIReqOps

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

8dbd4574 08/12/2011 04:27 pm Paolo Bonzini

scsi: introduce SCSIReqOps

This will let allow requests to be dispatched through different callbacks,
either common or per-device.

This patch adjusts the API, the next one will move members to SCSIReqOps.

Signed-off-by: Paolo Bonzini <>...

b45ef674 08/12/2011 04:27 pm Paolo Bonzini

scsi: move sense handling to generic code

With this patch, sense data is stored in the generic data structures
for SCSI devices and requests. The SCSI layer takes care of storing
sense data in the SCSIDevice for the subsequent REQUEST SENSE command.

At the same time, get_sense is removed and scsi_req_get_sense can use...

682a9b21 08/12/2011 04:27 pm Paolo Bonzini

scsi: pass status when completing

A small improvement in the SCSI request API. Pass the status
at the time the request is completed, so that we can assert that
no request is completed twice. This would have detected the
problem fixed in the previous patch....

5e30a07d 08/01/2011 01:10 pm Hannes Reinecke

scsi: Sanitize command definitions

Sanitize SCSI command definitions.
Add _10 suffix to READ_CAPACITY, WRITE_VERIFY, VERIFY, READ_LONG,
WRITE_LONG, and WRITE_SAME.
Add new command definitions for LOCATE_10, UNMAP, VARLENGTH_CDB,
WRITE_FILEMARKS_16, EXTENDED_COPY, ATA_PASSTHROUGH, ACCESS_CONTROL_IN,...

8e31bf38 07/23/2011 07:26 pm Matthew Fernandez

Correct spelling of licensed

Correct typos of "licenced" to "licensed".

Reviewed-by: Stefan Weil <>
Reviewed-by: Andreas F=E4rber <>
Signed-off-by: Matthew Fernandez <>
Signed-off-by: Anthony Liguori <>

c5bf71a9 07/19/2011 04:38 pm Hannes Reinecke

scsi: Add 'hba_private' to SCSIRequest

'tag' is just an abstraction to identify the command
from the driver. So we should make that explicit by
replacing 'tag' with a driver-defined pointer 'hba_private'.
This saves the lookup for driver handling several commands...

42741212 05/26/2011 01:14 pm Paolo Bonzini

scsi: make write_data return void

The return value is unused anyway.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

2e7cc4d6 05/26/2011 01:14 pm Paolo Bonzini

scsi-generic: Handle queue full

The sg driver currently has a hardcoded limit of commands it
can handle simultaneously. When this limit is reached the
driver will return -EDOM. So we need to capture this to
enable proper return values here.

Signed-off-by: Hannes Reinecke <>...

1455084e 05/26/2011 01:14 pm Paolo Bonzini

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.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

a1f0cce2 05/26/2011 01:14 pm Hannes Reinecke

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 error
which is actually a violation of the spec in certain cases....

fc4f0754 05/26/2011 01:14 pm Paolo Bonzini

scsi: do not call send_command directly

Move the common part of scsi-disk.c and scsi-generic.c to the SCSI layer.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

74382217 05/26/2011 01:14 pm Hannes Reinecke

scsi: Implement 'get_sense' callback

The get_sense callback copies existing sense information into
the provided buffer. This is required if sense information
should be transferred together with the command response.

Signed-off-by: Hannes Reinecke <>...

ad2d30f7 05/26/2011 01:14 pm Paolo Bonzini

scsi: reference-count requests

With the next patch, a device may hold SCSIRequest for an indefinite
time. 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...

5c6c0e51 05/26/2011 01:14 pm Hannes Reinecke

scsi: Use 'SCSIRequest' directly

Currently the SCSIRequest structure is abstracted away and cannot accessed
directly from the driver. This requires the handler to do a lookup on
an abstract 'tag' which identifies the SCSIRequest structure.

With this patch the SCSIRequest structure is exposed to the driver. This...

c557e889 05/26/2011 01:14 pm Paolo Bonzini

scsi: commonize purging requests

The code for canceling requests upon reset is already the same. Clean
it up and move it to scsi-bus.c.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

94d3f98a 05/26/2011 01:14 pm Paolo Bonzini

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 devices
register a second callback in SCSIBusOps.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

2b8b3bb9 05/26/2011 01:14 pm Paolo Bonzini

scsi: use scsi_req_complete

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

40f16dd1 05/26/2011 01:14 pm Paolo Bonzini

scsi-generic: Remove bogus double complete

scsi-generic scsi_read_complete() should not both call the client
complete callback with SCSI_REASON_DATA and call
scsi_command_complete(). The former will cause the client to queue a
new read or write request, while the later will free the request data...

ab9adc88 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce scsi_req_data

This abstracts calling the command_complete callback, reducing churn
in the following patches.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Christoph Hellwig <>

cfdc1bb0 05/26/2011 01:14 pm Paolo Bonzini

scsi: introduce SCSIBusOps

There are more operations than a SCSI bus can handle, besides completing
commands. One example, which this series will introduce, is cleaning up
after a request is cancelled.

More long term, a "SCSI bus" can represent the LUNs attached to a...

d33e0ce2 05/26/2011 01:14 pm Paolo Bonzini

scsi-generic: do not use a stale aiocb

If a request is canceled after it has been completed, scsi_cancel_io
would pass a stale aiocb to bdrv_aio_cancel. Avoid this.

Signed-off-by: Paolo Bonzini <>
Cc: Christoph Hellwig <>

f0171327 11/25/2010 01:00 pm Hannes Reinecke

scsi: Return SAM status codes

Traditionally, the linux stack is using SCSI status codes
which are shifted by one as compared to those defined in SAM.
A SCSI emulation should naturally return the SAM defined codes,
not the linux ones.
So to avoid any confusion this patch modifies the existing...

f8b6d672 09/21/2010 04:39 pm Bernhard Kohl

scsi-generic: add missing reset handler

Ensure that pending requests of a SCSI generic device are purged on
system reset. This also avoids calling a NULL function in lsi53c895a.
The lsi code was recently changed to call the .qdev.reset function.

Signed-off-by: Bernhard Kohl <>...

aa2b1e89 09/08/2010 01:39 pm Bernhard Kohl

scsi: fix and improve debug prints

Some of them are not compile clean.

Signed-off-by: Bernhard Kohl <>
Signed-off-by: Kevin Wolf <>

2446333c 08/24/2010 06:22 pm Blue Swirl

Rearrange block headers

Changing block.h or blockdev.h resulted in recompiling most objects.

Move DriveInfo typedef and BlockInterfaceType enum definitions
to qemu-common.h and rearrange blockdev.h use to decrease churn.

Signed-off-by: Blue Swirl <>

620f862e 07/06/2010 06:05 pm Markus Armbruster

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

f8b6cc00 07/02/2010 02:18 pm Markus Armbruster

qdev: Decouple qdev_prop_drive from DriveInfo

Make the property point to BlockDriverState, cutting out the DriveInfo
middleman. This prepares the ground for block devices that don't have
a DriveInfo.

Currently all user-defined ones have a DriveInfo, because the only way...

7d0d6950 07/02/2010 02:18 pm Markus Armbruster

block: Fix virtual media change for if=none

BlockDriverState member removable controls whether virtual media
change (monitor commands change, eject) is allowed. It is set when
the "type hint" is BDRV_TYPE_CDROM or BDRV_TYPE_FLOPPY.

The type hint is only set by drive_init(). It sets BDRV_TYPE_FLOPPY...

14bafc54 07/02/2010 02:18 pm Markus Armbruster

blockdev: Clean up automatic drive deletion

We automatically delete blockdev host parts on unplug of the guest
device. Too much magic, but we can't change that now.

The delete happens early in the guest device teardown, before the
connection to the host part is severed. Thus, the guest part's...

666daa68 06/04/2010 04:20 pm Markus Armbruster

blockdev: Collect block device code in new blockdev.c

Anything that moves hundreds of lines out of vl.c can't be all bad.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

1ecda02b 03/16/2010 05:58 pm Markus Armbruster

error: Replace qemu_error() by error_report()

error_report() terminates the message with a newline. Strip it it
from its arguments.

This fixes a few error messages lacking a newline:
net_handle_fd_param()'s "No file descriptor named %s found", and
tap_open()'s "vnet_hdr=1 requested, but no kernel support for...

2f792016 03/16/2010 05:55 pm Markus Armbruster

error: Move qemu_error & friends into their own header

428c149b 02/11/2010 12:53 am Christoph Hellwig

block: add topology qdev properties

Add three new qdev properties to export block topology information to
the guest. This is needed to get optimal I/O alignment for RAID arrays
or SSDs.

The options are:

- physical_block_size to specify the physical block size of the device,...
97a06435 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add xfer mode

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

29362ebe 12/03/2009 05:41 pm Gerd Hoffmann

scsi: move scsi command buffer from SCSIGenericReq to SCSIRequest.

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

2ec749cb 12/03/2009 05:41 pm Gerd Hoffmann

scsi: add request parsing helpers to common code.

Add helper functions for scsi request parsing to common code. Getting
command length, transfer size, and linear block address is handled.

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

e3c916e6 12/02/2009 04:57 pm Jean-Christophe DUBOIS

Fix qemu_free use in scsi-generic.c

scsi-generic.c is using free() instead of qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <>
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 <>

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

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,......
001faf32 05/13/2009 08:53 pm Blue Swirl

Replace gcc variadic macro extension with C99 version

Signed-off-by: Blue Swirl <>

221f715d 03/28/2009 07:28 pm aliguori

new scsi-generic abstraction, use SG_IO (Christoph Hellwig)

Okay, I started looking into how to handle scsi-generic I/O in the
new world order.

I think the best is to use the SG_IO ioctl instead of the read/write
interface as that allows us to support scsi passthrough on disk/cdrom...

7d780669 03/12/2009 09:57 pm aliguori

Add specialized block driver scsi generic API (Avi Kivity)

When a scsi device is backed by a scsi generic device instead of an
ordinary host block device, the block API is abused in a couple of annoying
ways:

- nb_sectors is negative, and specifies a byte count instead of a sector count...
89c0f643 10/17/2008 11:08 am aurel32

scsi-generic: correct error management

this patch allows to fully use a tape device connected to qemu through
the scsi-generic interface.

Previous patch introduced tape SCSI commands management, this one
improve error case management:

- the SCSI controller command completion must be called with the status...

a9dd6843 09/23/2008 04:38 pm aliguori

scsi-generic: decode correctly SCSI tape commands (Laurent Vivier)

This patch allows to use a "real" SCSI tape with qemu using
"-drive /dev/sgX,if=scsi".

It allows to decode correctly transfer length when the type of the
device is a tape.

Some issues remain when the application reading the tape tries to go...

72ecb8d9 09/22/2008 06:30 pm aliguori

scsi-generic: correct 6-bytes commands transfer length (Laurent Vivier)

According to SCSI documentation, for 6 bytes commands (READ,
WRITE), if transfer length is 0 it specifies 256 blocks.

Signed-off-by: Laurent Vivier <>
Signed-off-by: Anthony Liguori <>...

4f26a486 09/22/2008 06:27 pm aliguori

scsi-generic: correct usage of memset() (Laurent Vivier)

void *memset(void *s, int c, size_t n);

DESCRIPTION
The memset() function fills the first n bytes of the
memory area
pointed to by s with the constant byte c."

Reported by Dietmar Maurer....

37e828b4 09/02/2008 03:08 am aurel32

suppress a couple of spurious warnings in scsi-generic.c

This patch fixes two spurious `may be used uninitialised' warnings
when compiling with some compilers.

Signed-off-by: Andre Przywara <>
Signed-off-by: Ian Jackson <>...

2cc977e2 12/24/2007 06:11 pm ths

scsi-generic implemnentation, missing in last commit.

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