Blame qemu-net-add-API-to-disable-enable-polling.patch

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