summaryrefslogtreecommitdiff
path: root/hw/usb-msd.c
AgeCommit message (Collapse)AuthorFilesLines
2011-11-22usb-msd: do not register twice in the boot orderPaolo Bonzini1-2/+2
USB mass storage devices are registered twice in the boot order. To avoid having to keep the two paths in sync, pass the bootindex property down to the scsi-disk device and let it register itself. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-21usb-storage: don't try to send the status early.Gerd Hoffmann1-6/+10
Until recently all scsi commands sent to scsi-disk did either transfer data or finished instantly. The correct implementation of SYNCRONIZE_CACHE changed the picture though, and usb-storage needs a fix to handle that case correctly.
2011-11-21usb-storage: drop result from device state.Gerd Hoffmann1-3/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-21usb-storage: drop tag from device state.Gerd Hoffmann1-7/+6
scsi keeps track of the tag in SCSIRequest, no need to store a separate copy. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-21usb-storage: fill status in complete callback.Gerd Hoffmann1-17/+21
Put status word into device state, fill it in command_complete, have usb_msd_send_status just send it out. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-21usb-storage: move status debug message to usb_msd_send_status.Gerd Hoffmann1-2/+2
usb_msd_send_status can be called from different code paths, move the debug message into the function to make sure it is printed unconditionally. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-01usb: change VID/PID for usb-hub and usb-msd to prevent conflictRoy Tam1-2/+2
Some USB drivers, for example USBASPI.SYS, will skip different type of device which has same VID/PID. The following patch helps preventing usb-msd being skipped by the driver. Signed-off-by: Roy Tam <roytam@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-10-28scsi: allow arbitrary LUNsPaolo Bonzini1-1/+2
This only requires changes in two places: in SCSIBus, we need to look for a free LUN if somebody creates a device with a pre-existing scsi-id but the default LUN (-1, meaning "search for a free spot"); in vSCSI, we need to actually parse the LUN according to the SCSI spec. For vSCSI, max_target/max_lun are set according to the logical unit addressing format in SAM. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)Paolo Bonzini1-2/+5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-13usb-storage: fix NULL pointer dereference.Gerd Hoffmann1-1/+4
When a usb packet is canceled we need to check whenever we actually have a scsi request in flight before we try to cancel it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-06block: Attach non-qdev devices as wellMarkus Armbruster1-1/+1
For now, this just protects against programming errors like having the same drive back multiple non-qdev devices, or untimely bdrv_delete(). Later commits will add other interesting uses. While there, rename BlockDriverState member peer to dev, bdrv_attach() to bdrv_attach_dev(), bdrv_detach() to bdrv_detach_dev(), and bdrv_get_attached() to bdrv_get_attached_dev(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-12scsi: pass cdb already to scsi_req_newPaolo Bonzini1-2/+2
Right now the CDB is not passed to the SCSIBus until scsi_req_enqueue. Passing it to scsi_req_new will let scsi_req_new dispatch common requests through different reqops. Moving the memcpy to scsi_req_new is a hack that will go away as soon as scsi_req_new will also take care of the parsing. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-04usb-storage: iovec supportGerd Hoffmann1-58/+49
Add full iovec support to usb-storage. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-04usb: use iovecs in USBPacketGerd Hoffmann1-4/+8
Zap data pointer from USBPacket, add a QEMUIOVector instead. Add a bunch of helper functions to manage USBPacket data. Switch over users to the new interface. Note that USBPacket->len was used for two purposes: First to pass in the buffer size and second to return the number of transfered bytes or the status code on async transfers. There is a new result variable for the latter. A new status code was added to catch uninitialized result. Nobody creates iovecs with more than one element (yet). Some users are (temporarely) limited to iovecs with a single element to keep the patch size as small as possible. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-29Merge remote-tracking branch 'kraxel/migration.2' into stagingAnthony Liguori1-0/+12
2011-07-23Correct spelling of licensedMatthew Fernandez1-1/+1
Correct typos of "licenced" to "licensed". Reviewed-by: Stefan Weil <weil@mail.berlios.de> Reviewed-by: Andreas F=E4rber <andreas.faerber@web.de> Signed-off-by: Matthew Fernandez <matthew.fernandez@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-20usb storage: first migration support bits.Gerd Hoffmann1-0/+12
Tag vmstate as unmigratable for the time being, to be removed when mgration support is finished. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-19scsi: Add 'hba_private' to SCSIRequestHannes Reinecke1-8/+1
'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 in parallel. 'tag' is still being kept for tracing purposes. Signed-off-by: Hannes Reinecke <hare@suse.de> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-06-23usb-storage: Turn drive serial into a qdev property usb-storage.serialMarkus Armbruster1-3/+11
It needs to be a qdev property, because it belongs to the drive's guest part. Precedence: commit a0fef654 and 6ced55a5. Bonus: info qtree now shows the serial number. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23usb: Proper error propagation for usb_device_attach errorsHans de Goede1-2/+3
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-31Merge remote-tracking branch 'bonzini/scsi.2' into stagingAnthony Liguori1-50/+72
Conflicts: hw/usb-msd.c
2011-05-26scsi: rename arguments to the new callbacksPaolo Bonzini1-5/+5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: split command_complete callback in twoPaolo Bonzini1-30/+41
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_get_bufPaolo Bonzini1-1/+1
... and remove some SCSIDevice variables or fields that now become unused. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_continuePaolo Bonzini1-11/+4
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_newPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: do not call send_command directlyPaolo Bonzini1-1/+1
Move the common part of scsi-disk.c and scsi-generic.c to the SCSI layer. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce scsi_req_cancelPaolo Bonzini1-4/+15
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 <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: Use 'SCSIRequest' directlyHannes Reinecke1-12/+15
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 allows use to use it directly as an argument to the SCSIDeviceInfo callback functions and remove the lookup. A new callback function 'alloc_req' is introduced matching 'free req'; unref'ing to free up resources after use is moved into the scsi_command_complete callbacks. This temporarily introduces a leak of requests that are cancelled, when they are removed from the queue and not from the driver. This is fixed later by introducing scsi_req_cancel. That patch in turn depends on this one, because the argument to scsi_req_cancel is a SCSIRequest. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-05-26scsi: introduce SCSIBusOpsPaolo Bonzini1-1/+5
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 target; in this case, while all commands will ultimately reach a logical unit, it is the target who is in charge of answering REPORT LUNs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
2011-05-26usb: move cancel callback to USBDeviceInfoGerd Hoffmann1-5/+3
Remove the cancel callback from the USBPacket struct, move it over to USBDeviceInfo. Zap usb_defer_packet() which is obsolete now. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb-storage: don't call usb_packet_complete twiceGerd Hoffmann1-1/+1
usb_msd_copy_data() may cause a recursive call to usb_msd_command_complete() which in turn may complete the packet, setting s->packet to NULL in case it does. Recheck s->packet before calling usb_packet_complete() to fix the double call. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb: Pass the packet to the device's handle_control callbackHans de Goede1-3/+3
This allows using the generic usb_generic_handle_packet function from device code which does ASYNC control requests (such as the linux host pass through code). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-05-26usb: update config descriptors to identify number of interfacesBrad Hards1-0/+2
Previously we relied on the .bNumInterfaces, but that won't always be accurate after the introduction of grouped interfaces. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-04usb: mass storage fixGerd Hoffmann1-0/+1
Initialize scsi_len with zero when starting a new request, so any stuff leftover from the previous request is cleared out. This may happen in case the data returned by the scsi command doesn't fit into the buffer provided by the guest. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-04usb: move complete callback to port opsGerd Hoffmann1-2/+2
2011-04-16usb: trivial spelling fixesBrad Hards1-2/+2
Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-02-01Add bootindex handling into usb storage device.Gleb Natapov1-0/+2
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-01-31blockdev: Fix drive_add for drives without mediaMarkus Armbruster1-2/+1
Watch this: (qemu) drive_add 0 if=none (qemu) info block none0: type=hd removable=0 [not inserted] (qemu) drive_del none0 Segmentation fault (core dumped) add_init_drive() is confused about drive_init()'s failure modes, and cleans up when it shouldn't. This leaves the DriveInfo with member opts dangling. drive_del attempts to free it, and dies. drive_init() behaves as follows: * If it created a drive with media, it returns its DriveInfo. * If it created a drive without media, it clears *fatal_error and returns NULL. * If it couldn't create a drive, it sets *fatal_error and returns NULL. Of its three callers: * drive_init_func() is correct. * usb_msd_init() assumes drive_init() failed when it returns NULL. This is correct only because it always passes option "file", and "drive without media" can't happen then. * add_init_drive() assumes drive_init() failed when it returns NULL. This is incorrect. Clean up drive_init() to return NULL on failure and only on failure. Drop its parameter fatal_error. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-24usb-msd: Propagate removable bit to SCSI deviceStefan Hajnoczi1-1/+3
USB Mass Storage Devices sometimes have the RMB (removable) bit set in the SCSI INQUIRY response. Thumbdrives tend to have the bit set whereas hard disks do not. Operating systems differentiate between removable devices and fixed devices. Under Linux, the anaconda installer looks for removable devices. Under Windows, only fixed devices may have more than one partition and AutoRun is also affected by the removable bit. For these reasons, allow USB Mass Storage Devices to override the removable bit: qemu -usb -drive if=none,file=test.img,cache=none,id=disk0 -device usb-storage,drive=disk0,removable=on The default is off. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-24scsi: Allow scsi_bus_legacy_add_drive() to set removable bitStefan Hajnoczi1-1/+1
scsi-disk devices may wish to override the removable bit. Add support for a qdev property on SCSI devices. This is will be used by usb-msd. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-11usb storage: handle long responsesGerd Hoffmann1-2/+2
The scsi layer may return us more data than the guests wants to have. Handle this by just ignoring the extra bytes and calling the {read,write}_data callback to finish the request. Seen happening in real life with some extended inquiry command. With this patch applied the linux kernel stops reseting the device once at boot. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb storage: fix status reportingGerd Hoffmann1-6/+7
Change usb_msd_send_status() to take a pointer to the status packet instead of writing the status to s->usb_buf which might not point to the correct location. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb storage: high speed supportGerd Hoffmann1-5/+46
Add high speed support to the usb mass storage device. With this patch applied the linux kernel recognises the usb storage device as highspeed capable device and suggests to connect it to a highspeed port instead of the uhci. Tested with both uhci and (not-yet submitted) ehci. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: move remote wakeup handling to common codeGerd Hoffmann1-23/+0
This patch moves setting and clearing the remote_wakeup feature bit (via USB_REQ_{SET,CLEAR}_FEATURE) to common code. Also USB_REQ_GET_STATUS handling is moved to common code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common codeGerd Hoffmann1-8/+1
This patch adds fields to the USBDevice struct for the current speed (hard-wired to full speed for now) and current device configuration. Also a init function is added which inializes these fields. This allows USB_REQ_{GET,SET}_CONFIGURATION handling to be moved to common code. For most drivers the conversion is trivial ad they support a single configuration only anyway. One exception is bluetooth where some device-specific setup code runs after get/set configuration. The other is usb-net which actually has two configurations so the the code to check for the active configuration has been adapted. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: move USB_REQ_SET_ADDRESS handling to common codeGerd Hoffmann1-4/+0
USB_REQ_SET_ADDRESS handling is identical in *all* emulated devices. Move it to common code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb storage: serial number supportGerd Hoffmann1-0/+6
If a serial number is present for the drive fill it into the usb serialnumber string descriptor. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb storage: use new descriptor infrastructure.Gerd Hoffmann1-104/+63
Switch the usb storage driver over to the new descriptor infrastructure. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-08-24Rearrange block headersBlue Swirl1-0/+1
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 <blauwirbel@gmail.com>