From c1522bd8267d85b560825dd0e765ebe80bca8b1b Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 12 Sep 2012 13:10:27 -0300
Subject: [RHEL6 qemu-kvm PATCH 08/14] usb-redir: Get rid of local shadow copy
 of packet headers

RH-Author: Hans de Goede <hdegoede@redhat.com>
Message-id: <1347455431-11260-9-git-send-email-hdegoede@redhat.com>
Patchwork-id: 41856
O-Subject: [RHEL-6.4 qemu-kvm PATCH 08/12] usb-redir: Get rid of local shadow copy of packet headers
Bugzilla:
RH-Acked-by: Alon Levy <alevy@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
RH-Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Bugzilla-related: 805172

The shadow copy only serves as an extra check (besides the packet-id) to
ensure the packet we get back is a reply to the packet we think it is.

This check has never triggered in all the time usb-redir is in use now,
and since the verified data in the returned packet-header is not used
otherwise, removing the check does not open any possibilities for the
usbredirhost to confuse us.

This is a preparation patch for completely getting rid of the async-packet
struct in usb-redir, instead relying on the (new) per ep queues in the
qemu usb core.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Upstream-commit: 104981d52b63dc3d68f39d4442881c667f44bbb9
Conflicts: usb-redir.c
---
 usb-redir.c | 27 ---------------------------
 1 file changed, 27 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 usb-redir.c | 27 ---------------------------
 1 file changed, 27 deletions(-)

diff --git a/usb-redir.c b/usb-redir.c
index 5e3d132..d2e1bf9 100644
--- a/usb-redir.c
+++ b/usb-redir.c
@@ -98,11 +98,6 @@ struct AsyncURB {
     USBRedirDevice *dev;
     USBPacket *packet;
     uint32_t packet_id;
-    union {
-        struct usb_redir_control_packet_header control_packet;
-        struct usb_redir_bulk_packet_header bulk_packet;
-        struct usb_redir_interrupt_packet_header interrupt_packet;
-    };
     QTAILQ_ENTRY(AsyncURB)next;
 };
 
@@ -508,7 +503,6 @@ static int usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p,
     bulk_packet.endpoint  = ep;
     bulk_packet.length    = p->len;
     bulk_packet.stream_id = 0;
-    aurb->bulk_packet = bulk_packet;
 
     if (ep & USB_DIR_IN) {
         usbredirparser_send_bulk_packet(dev->parser, aurb->packet_id,
@@ -586,7 +580,6 @@ static int usbredir_handle_interrupt_data(USBRedirDevice *dev,
 
         interrupt_packet.endpoint  = ep;
         interrupt_packet.length    = p->len;
-        aurb->interrupt_packet     = interrupt_packet;
 
         usbredir_log_data(dev, "interrupt data out:", p->data, p->len);
         usbredirparser_send_interrupt_packet(dev->parser, aurb->packet_id,
@@ -766,7 +759,6 @@ static int usbredir_handle_control(USBDevice *udev, USBPacket *p,
     control_packet.value       = value;
     control_packet.index       = index;
     control_packet.length      = length;
-    aurb->control_packet       = control_packet;
 
     if (control_packet.requesttype & USB_DIR_IN) {
         usbredirparser_send_control_packet(dev->parser, aurb->packet_id,
@@ -1337,14 +1329,6 @@ static void usbredir_control_packet(void *priv, uint32_t id,
         return;
     }
 
-    aurb->control_packet.status = control_packet->status;
-    aurb->control_packet.length = control_packet->length;
-    if (memcmp(&aurb->control_packet, control_packet,
-               sizeof(*control_packet))) {
-        ERROR("return control packet mismatch, please report this!\n");
-        len = USB_RET_NAK;
-    }
-
     if (aurb->packet) {
         len = usbredir_handle_status(dev, control_packet->status, len);
         if (len > 0) {
@@ -1382,12 +1366,6 @@ static void usbredir_bulk_packet(void *priv, uint32_t id,
         return;
     }
 
-    if (aurb->bulk_packet.endpoint != bulk_packet->endpoint ||
-            aurb->bulk_packet.stream_id != bulk_packet->stream_id) {
-        ERROR("return bulk packet mismatch, please report this!\n");
-        len = USB_RET_NAK;
-    }
-
     if (aurb->packet) {
         len = usbredir_handle_status(dev, bulk_packet->status, len);
         if (len > 0) {
@@ -1466,11 +1444,6 @@ static void usbredir_interrupt_packet(void *priv, uint32_t id,
             return;
         }
 
-        if (aurb->interrupt_packet.endpoint != interrupt_packet->endpoint) {
-            ERROR("return int packet mismatch, please report this!\n");
-            len = USB_RET_NAK;
-        }
-
         if (aurb->packet) {
             aurb->packet->len = usbredir_handle_status(dev,
                                                interrupt_packet->status, len);
-- 
1.7.11.4

