File 0001-net-move-the-tap-buffer-into-TAPState.patch of Package xen

From: Mark McLoughlin <markmc@redhat.com>
Date: Mon, 18 May 2009 12:05:44 +0100
Subject: net: move the tap buffer into TAPState
Patch-mainline: v0.11.0-rc0
Git-commit: 5b01e886d9eb4d5e94384a79634dcb43848e7bbf
References: bnc#840196

KVM uses a 64k buffer for reading from tapfd (for GSO support)
and allocates the buffer with TAPState rather than on the stack.

Not allocating it on the stack probably makes sense for qemu
anyway, so merge it in advance of GSO support.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 tools/qemu-xen-traditional-dir-remote/net.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/qemu-xen-traditional-dir-remote/net.c b/tools/qemu-xen-traditional-dir-remote/net.c
index 0e7c77c..2ca85a3 100644
--- a/tools/qemu-xen-traditional-dir-remote/net.c
+++ b/tools/qemu-xen-traditional-dir-remote/net.c
@@ -700,6 +700,7 @@ typedef struct TAPState {
     char down_script[1024];
     char down_script_arg[128];
     char script_arg[1024];
+    uint8_t buf[4096];
 } TAPState;
 
 #ifndef CONFIG_STUBDOM
@@ -735,20 +736,19 @@ static void tap_receive(void *opaque, const uint8_t *buf, int size)
 static void tap_send(void *opaque)
 {
     TAPState *s = opaque;
-    uint8_t buf[4096];
     int size;
 
 #ifdef __sun__
     struct strbuf sbuf;
     int f = 0;
-    sbuf.maxlen = sizeof(buf);
-    sbuf.buf = buf;
+    sbuf.maxlen = sizeof(s->buf);
+    sbuf.buf = s->buf;
     size = getmsg(s->fd, NULL, &sbuf, &f) >=0 ? sbuf.len : -1;
 #else
-    size = read(s->fd, buf, sizeof(buf));
+    size = read(s->fd, s->buf, sizeof(s->buf));
 #endif
     if (size > 0) {
-        qemu_send_packet(s->vc, buf, size);
+        qemu_send_packet(s->vc, s->buf, size);
     }
 }
 
-- 
1.8.1.4