summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-01-04 18:13:54 +0100
committerGerd Hoffmann <kraxel@redhat.com>2012-01-06 12:36:14 +0100
commit24a5bbe1c8cd6f5e90100b42eac29f41c33939de (patch)
tree705c6521a7cdcf76a60de41e2e00897d4e978f47 /hw
parent7279a85f37a9cf20b15c86159f0a1f01ce9cead4 (diff)
downloadqemu-24a5bbe1c8cd6f5e90100b42eac29f41c33939de.zip
usb-storage: cancel I/O on reset
When resetting the usb-storage device we'll have to carefully cancel and clear any requests which might be in flight, otherwise we'll confuse the state machine. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/usb-msd.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 4c06950125..3147131db4 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -278,6 +278,18 @@ static void usb_msd_handle_reset(USBDevice *dev)
MSDState *s = (MSDState *)dev;
DPRINTF("Reset\n");
+ if (s->req) {
+ scsi_req_cancel(s->req);
+ }
+ assert(s->req == NULL);
+
+ if (s->packet) {
+ USBPacket *p = s->packet;
+ s->packet = NULL;
+ p->result = USB_RET_STALL;
+ usb_packet_complete(dev, p);
+ }
+
s->mode = USB_MSDM_CBW;
}