]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tap: fix vcpu long time io blocking on tap
authorWangkai (Kevin,C) <wangkai86@huawei.com>
Fri, 18 Jul 2014 09:33:42 +0000 (09:33 +0000)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 19 Dec 2014 11:19:22 +0000 (11:19 +0000)
[Adjusted doc comment for grammar.
--Stefan]

Signed-off-by: Wangkai <wangkai86@huawei.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
net/tap.c

index bde6b58b17454d88cb2b61a0d6be60baecdb99fc..1fe0edfdf78e17bb0537825f65f122e4c4432793 100644 (file)
--- a/net/tap.c
+++ b/net/tap.c
@@ -189,6 +189,7 @@ static void tap_send(void *opaque)
 {
     TAPState *s = opaque;
     int size;
+    int packets = 0;
 
     while (qemu_can_send_packet(&s->nc)) {
         uint8_t *buf = s->buf;
@@ -210,6 +211,17 @@ static void tap_send(void *opaque)
         } else if (size < 0) {
             break;
         }
+
+        /*
+         * When the host keeps receiving more packets while tap_send() is
+         * running we can hog the QEMU global mutex.  Limit the number of
+         * packets that are processed per tap_send() callback to prevent
+         * stalling the guest.
+         */
+        packets++;
+        if (packets >= 50) {
+            break;
+        }
     }
 }