From 038d20526db6a23e6fb0f0368a0b729234043f7c Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 10 Jan 2012 11:18:17 +0100 Subject: [PATCH] usb-storage: cancel I/O on reset RH-Author: Gerd Hoffmann Message-id: <1326194297-21506-1-git-send-email-kraxel@redhat.com> Patchwork-id: 36298 O-Subject: [RHEL-6.3 qemu-kvm PATCH] usb-storage: cancel I/O on reset Bugzilla: 769760 RH-Acked-by: Paolo Bonzini RH-Acked-by: Hans de Goede RH-Acked-by: Markus Armbruster 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 (cherry picked from commit 24a5bbe1c8cd6f5e90100b42eac29f41c33939de) [ buildfix: s/result/len/ due to rhel6 vs upstream code base differences ] bugzilla: 769760 - Formatting of usb-storage disk attached on usb-hub fails to end --- hw/usb-msd.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) Signed-off-by: Michal Novotny --- hw/usb-msd.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 5b15821..eeea203 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -284,6 +284,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->len = USB_RET_STALL; + usb_packet_complete(dev, p); + } + s->mode = USB_MSDM_CBW; } -- 1.7.7.4