272dfe3
When vhost is bound to a backend device, we need to stop polling it when
272dfe3
vhost is started, and restart polling when vhost is stopped.
272dfe3
Add an API for that for use by vhost, and implement in tap backend.
272dfe3
272dfe3
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
272dfe3
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
272dfe3
(cherry picked from commit ceb696159d569db5b2a7659ce38752398c236742)
272dfe3
---
272dfe3
 net.h     |    3 +++
272dfe3
 net/tap.c |    8 ++++++++
272dfe3
 2 files changed, 11 insertions(+), 0 deletions(-)
272dfe3
272dfe3
diff --git a/net.h b/net.h
272dfe3
index 4971fcb..116bb80 100644
272dfe3
--- a/net.h
272dfe3
+++ b/net.h
272dfe3
@@ -1,6 +1,7 @@
272dfe3
 #ifndef QEMU_NET_H
272dfe3
 #define QEMU_NET_H
272dfe3
 
272dfe3
+#include <stdbool.h>
272dfe3
 #include "qemu-queue.h"
272dfe3
 #include "qemu-common.h"
272dfe3
 #include "qdict.h"
272dfe3
@@ -36,6 +37,7 @@ typedef enum {
272dfe3
     NET_CLIENT_TYPE_DUMP
272dfe3
 } net_client_type;
272dfe3
 
272dfe3
+typedef void (NetPoll)(VLANClientState *, bool enable);
272dfe3
 typedef int (NetCanReceive)(VLANClientState *);
272dfe3
 typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
272dfe3
 typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
272dfe3
@@ -51,6 +53,7 @@ typedef struct NetClientInfo {
272dfe3
     NetCanReceive *can_receive;
272dfe3
     NetCleanup *cleanup;
272dfe3
     LinkStatusChanged *link_status_changed;
272dfe3
+    NetPoll *poll;
272dfe3
 } NetClientInfo;
272dfe3
 
272dfe3
 struct VLANClientState {
272dfe3
diff --git a/net/tap.c b/net/tap.c
272dfe3
index 0d8b424..d3492de 100644
272dfe3
--- a/net/tap.c
272dfe3
+++ b/net/tap.c
272dfe3
@@ -262,6 +262,13 @@ static void tap_cleanup(VLANClientState *nc)
272dfe3
     close(s->fd);
272dfe3
 }
272dfe3
 
272dfe3
+static void tap_poll(VLANClientState *nc, bool enable)
272dfe3
+{
272dfe3
+    TAPState *s = DO_UPCAST(TAPState, nc, nc);
272dfe3
+    tap_read_poll(s, enable);
272dfe3
+    tap_write_poll(s, enable);
272dfe3
+}
272dfe3
+
272dfe3
 /* fd support */
272dfe3
 
272dfe3
 static NetClientInfo net_tap_info = {
272dfe3
@@ -270,6 +277,7 @@ static NetClientInfo net_tap_info = {
272dfe3
     .receive = tap_receive,
272dfe3
     .receive_raw = tap_receive_raw,
272dfe3
     .receive_iov = tap_receive_iov,
272dfe3
+    .poll = tap_poll,
272dfe3
     .cleanup = tap_cleanup,
272dfe3
 };
272dfe3
 
272dfe3
-- 
272dfe3
1.6.6.144.g5c3af