提交 ceb69615 编写于 作者: M Michael S. Tsirkin 提交者: Anthony Liguori

net: add API to disable/enable polling

When vhost is bound to a backend device, we need to stop polling it when
vhost is started, and restart polling when vhost is stopped.
Add an API for that for use by vhost, and implement in tap backend.
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 c9f398e5
#ifndef QEMU_NET_H
#define QEMU_NET_H
#include <stdbool.h>
#include "qemu-queue.h"
#include "qemu-common.h"
#include "qdict.h"
......@@ -36,6 +37,7 @@ typedef enum {
NET_CLIENT_TYPE_DUMP
} net_client_type;
typedef void (NetPoll)(VLANClientState *, bool enable);
typedef int (NetCanReceive)(VLANClientState *);
typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
......@@ -51,6 +53,7 @@ typedef struct NetClientInfo {
NetCanReceive *can_receive;
NetCleanup *cleanup;
LinkStatusChanged *link_status_changed;
NetPoll *poll;
} NetClientInfo;
struct VLANClientState {
......
......@@ -262,6 +262,13 @@ static void tap_cleanup(VLANClientState *nc)
close(s->fd);
}
static void tap_poll(VLANClientState *nc, bool enable)
{
TAPState *s = DO_UPCAST(TAPState, nc, nc);
tap_read_poll(s, enable);
tap_write_poll(s, enable);
}
/* fd support */
static NetClientInfo net_tap_info = {
......@@ -270,6 +277,7 @@ static NetClientInfo net_tap_info = {
.receive = tap_receive,
.receive_raw = tap_receive_raw,
.receive_iov = tap_receive_iov,
.poll = tap_poll,
.cleanup = tap_cleanup,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册