summaryrefslogtreecommitdiffstats
path: root/hw/usb-msd.c
Commit message (Collapse)AuthorAgeFilesLines
* scsi: pass cdb already to scsi_req_newPaolo Bonzini2011-08-121-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>
* usb-storage: iovec supportGerd Hoffmann2011-08-041-58/+49
| | | | | | Add full iovec support to usb-storage. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: use iovecs in USBPacketGerd Hoffmann2011-08-041-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>
* Merge remote-tracking branch 'kraxel/migration.2' into stagingAnthony Liguori2011-07-291-0/+12
|\
| * usb storage: first migration support bits.Gerd Hoffmann2011-07-201-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>
* | Correct spelling of licensedMatthew Fernandez2011-07-231-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>
* | scsi: Add 'hba_private' to SCSIRequestHannes Reinecke2011-07-191-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>
* usb-storage: Turn drive serial into a qdev property usb-storage.serialMarkus Armbruster2011-06-231-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>
* usb: Proper error propagation for usb_device_attach errorsHans de Goede2011-06-231-2/+3
| | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* Merge remote-tracking branch 'bonzini/scsi.2' into stagingAnthony Liguori2011-05-311-50/+72
|\ | | | | | | | | Conflicts: hw/usb-msd.c
| * scsi: rename arguments to the new callbacksPaolo Bonzini2011-05-261-5/+5
| | | | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
| * scsi: split command_complete callback in twoPaolo Bonzini2011-05-261-30/+41
| | | | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
| * scsi: introduce scsi_req_get_bufPaolo Bonzini2011-05-261-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>
| * scsi: introduce scsi_req_continuePaolo Bonzini2011-05-261-11/+4
| | | | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
| * scsi: introduce scsi_req_newPaolo Bonzini2011-05-261-1/+1
| | | | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
| * scsi: do not call send_command directlyPaolo Bonzini2011-05-261-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>
| * scsi: introduce scsi_req_cancelPaolo Bonzini2011-05-261-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>
| * scsi: Use 'SCSIRequest' directlyHannes Reinecke2011-05-261-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>
| * scsi: introduce SCSIBusOpsPaolo Bonzini2011-05-261-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>
* | usb: move cancel callback to USBDeviceInfoGerd Hoffmann2011-05-261-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>
* | usb-storage: don't call usb_packet_complete twiceGerd Hoffmann2011-05-261-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>
* | usb: Pass the packet to the device's handle_control callbackHans de Goede2011-05-261-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>
* | usb: update config descriptors to identify number of interfacesBrad Hards2011-05-261-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>
* usb: mass storage fixGerd Hoffmann2011-05-041-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>
* usb: move complete callback to port opsGerd Hoffmann2011-05-041-2/+2
|
* usb: trivial spelling fixesBrad Hards2011-04-161-2/+2
| | | | | Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* Add bootindex handling into usb storage device.Gleb Natapov2011-02-011-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>
* blockdev: Fix drive_add for drives without mediaMarkus Armbruster2011-01-311-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>
* usb-msd: Propagate removable bit to SCSI deviceStefan Hajnoczi2011-01-241-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>
* scsi: Allow scsi_bus_legacy_add_drive() to set removable bitStefan Hajnoczi2011-01-241-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>
* usb storage: handle long responsesGerd Hoffmann2011-01-111-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>
* usb storage: fix status reportingGerd Hoffmann2011-01-111-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>
* usb storage: high speed supportGerd Hoffmann2011-01-111-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>
* usb: move remote wakeup handling to common codeGerd Hoffmann2011-01-111-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>
* usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common codeGerd Hoffmann2011-01-111-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>
* usb: move USB_REQ_SET_ADDRESS handling to common codeGerd Hoffmann2011-01-111-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>
* usb storage: serial number supportGerd Hoffmann2011-01-111-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>
* usb storage: use new descriptor infrastructure.Gerd Hoffmann2011-01-111-104/+63
| | | | | | | Switch the usb storage driver over to the new descriptor infrastructure. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* Rearrange block headersBlue Swirl2010-08-241-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>
* QemuOpts: make most qemu_*_opts staticGerd Hoffmann2010-08-221-1/+1
| | | | | | | | Switch tree to lookup-by-name using qemu_find_opts(). Also hook up virtfs options so qemu_find_opts works for them too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* block: Catch attempt to attach multiple devices to a blockdevMarkus Armbruster2010-07-021-4/+8
| | | | | | | | | | | | | | | For instance, -device scsi-disk,drive=foo -device scsi-disk,drive=foo happily creates two SCSI disks connected to the same block device. It's all downhill from there. Device usb-storage deliberately attaches twice to the same blockdev, which fails with the fix in place. Detach before the second attach there. Also catch attempt to delete while a guest device model is attached. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qdev: Decouple qdev_prop_drive from DriveInfoMarkus Armbruster2010-07-021-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 to define one is -drive & friends (they go through drive_init()). DriveInfo is closely tied to -drive, and like -drive, it mixes information about host and guest part of the block device. I'm working towards a new way to define block devices, with clean host/guest separation, and I need to get DriveInfo out of the way for that. Fortunately, the device models are perfectly happy with BlockDriverState, except for two places: ide_drive_initfn() and scsi_disk_initfn() need to check the DriveInfo for a serial number set with legacy -drive serial=... Use drive_get_by_blockdev() there. Device model code should now use DriveInfo only when explicitly dealing with drives defined the old way, i.e. without -device. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blockdev: Clean up automatic drive deletionMarkus Armbruster2010-07-021-4/+16
| | | | | | | | | | | | | | | | | | | | | 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 pointer to the host part dangles for a brief time. No actual harm comes from this, but we'll catch such dangling pointers a few commits down the road. Clean up the dangling pointers by delaying the automatic deletion until the guest part's pointer is gone. Device usb-storage deliberately makes two qdev properties refer to the same drive, because it automatically creates a second device. Again, too much magic we can't change now. Multiple references worked okay before, but now free_drive() dies for the second one. Zap the extra reference. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: scsi_bus_legacy_handle_cmdline() can fail, fix callersMarkus Armbruster2010-07-021-0/+3
| | | | | | | | | | | | | | None of its callers checks for failure. scsi_hot_add() can crash because of that: (qemu) drive_add 4 if=scsi,format=host_device,file=/dev/sg1 scsi-generic: scsi generic interface too old Segmentation fault (core dumped) Fix all callers, not just scsi_hot_add(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blockdev: Collect block device code in new blockdev.cMarkus Armbruster2010-06-041-1/+1
| | | | | | | Anything that moves hundreds of lines out of vl.c can't be all bad. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blockdev: Hide QEMUMachine from drive_init()Markus Armbruster2010-06-041-1/+1
| | | | | | | To pave the way for moving it out of vl.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* usb: class specific interface requestsMax Reitz2010-03-311-4/+2
| | | | | | | | | | | | | Mass Storage Reset and Get Max LUN are class specific requests, but they were not marked as such in hw/usb-msd.c, moved therefore ClassInterfaceRequest and ClassInterfaceOutRequest from hw/usb-net.c to hw/usb.h. Furthermore there was a problem in hw/usb-ohci.c when using DEBUG concerning systems where size_t is a 32 bit integer (printf resulted in a segmentation fault). Signed-off-by: Max Reitz <max@tyndur.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* hw/usb-msd: fix some usb requestsArnaud Patard (Rtp)2010-03-171-3/+5
| | | | | | | | | | The usb-msd device emulation needs some small tweaks in the requests emulations. For instance, the reset/maxlun requests are class/interface specific so requests for them with the type class and recipient interface bits sets have to be handled. Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* error: Replace qemu_error() by error_report()Markus Armbruster2010-03-161-1/+1
| | | | | | | | | | | | | 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 IFF_VNET_HDR available" (all three versions). There's one place that passes arguments without newlines intentionally: load_vmstate(). Fix it up.
* block: Simplify usb_msd_initfn() test for "can read bdrv key"Markus Armbruster2010-03-161-1/+1
| | | | | | | | | | | | The old test assumes that "hotplugged" implies "we have a current monitor for reading the key". This is in fact true, but it's not obviously true. Aside: if it were false, we could pass a null pointer to monitor_read_bdrv_key_start(), which would then crash. The previous commit permits us to check for "we have a current monitor" directly, so do that.
OpenPOWER on IntegriCloud