aboutsummaryrefslogtreecommitdiff
path: root/net/tap.c
diff options
context:
space:
mode:
authorWangkai (Kevin,C) <wangkai86@huawei.com>2014-07-18 09:33:42 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2014-12-19 11:19:22 +0000
commit756ae78b275a0625b4559a8fc448df4c6eb331a8 (patch)
tree848dab20a08d39d6bf80054c002e5f962a7ce3c3 /net/tap.c
parent86b182ac0e0b44726d85598cbefb468ed22517fc (diff)
downloadqemu-756ae78b275a0625b4559a8fc448df4c6eb331a8.zip
qemu-756ae78b275a0625b4559a8fc448df4c6eb331a8.tar.gz
qemu-756ae78b275a0625b4559a8fc448df4c6eb331a8.tar.bz2
tap: fix vcpu long time io blocking on tap
[Adjusted doc comment for grammar. --Stefan] Signed-off-by: Wangkai <wangkai86@huawei.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'net/tap.c')
-rw-r--r--net/tap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/tap.c b/net/tap.c
index bde6b58..1fe0edf 100644
--- 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;
+ }
}
}