From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39292 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTYT8-00088t-K6 for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTYT5-0007WY-PM for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTYT5-0007WA-Fy for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:23 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBHBRMMd025866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 17 Dec 2010 06:27:22 -0500 From: Gerd Hoffmann Date: Fri, 17 Dec 2010 12:26:44 +0100 Message-Id: <1292585206-24862-29-git-send-email-kraxel@redhat.com> In-Reply-To: <1292585206-24862-1-git-send-email-kraxel@redhat.com> References: <1292585206-24862-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 28/30] usb storage: handle long responses List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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 --- hw/usb-msd.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 28c12dd..729d96c 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -187,7 +187,7 @@ static void usb_msd_copy_data(MSDState *s) s->usb_buf += len; s->scsi_buf += len; s->data_len -= len; - if (s->scsi_len == 0) { + if (s->scsi_len == 0 || s->data_len == 0) { if (s->mode == USB_MSDM_DATAIN) { s->scsi_dev->info->read_data(s->scsi_dev, s->tag); } else if (s->mode == USB_MSDM_DATAOUT) { @@ -434,7 +434,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) break; case USB_MSDM_DATAIN: - DPRINTF("Data in %d/%d\n", len, s->data_len); + DPRINTF("Data in %d/%d, scsi_len %d\n", len, s->data_len, s->scsi_len); if (len > s->data_len) len = s->data_len; s->usb_buf = data; -- 1.7.1