]> git.proxmox.com Git - qemu.git/commitdiff
usb-storage: cancel I/O on reset
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 4 Jan 2012 17:13:54 +0000 (18:13 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 6 Jan 2012 11:36:14 +0000 (12:36 +0100)
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>
hw/usb-msd.c

index 4c069501253ddcb9c35f0b50a9903843da51ac6c..3147131db46ae6db10883408ff8c42656dc6c4cb 100644 (file)
@@ -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;
 }