From patchwork Thu Dec 24 12:46:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 41774 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2FFFBB7C00 for ; Thu, 24 Dec 2009 23:54:02 +1100 (EST) Received: from localhost ([127.0.0.1]:52632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNnCZ-0002CR-1H for incoming@patchwork.ozlabs.org; Thu, 24 Dec 2009 07:53:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNn88-0000vp-32 for qemu-devel@nongnu.org; Thu, 24 Dec 2009 07:49:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNn83-0000vL-KQ for qemu-devel@nongnu.org; Thu, 24 Dec 2009 07:49:23 -0500 Received: from [199.232.76.173] (port=55783 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNn83-0000vC-EC for qemu-devel@nongnu.org; Thu, 24 Dec 2009 07:49:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4865) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NNn82-0005hY-Tq for qemu-devel@nongnu.org; Thu, 24 Dec 2009 07:49:19 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBOCnHda017202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Dec 2009 07:49:17 -0500 Received: from redhat.com (vpn2-10-194.ams2.redhat.com [10.36.10.194]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nBOCnFjg013419; Thu, 24 Dec 2009 07:49:16 -0500 Date: Thu, 24 Dec 2009 14:46:29 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori Message-ID: <20091224124629.GA31567@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH] net: add API to disable/enable polling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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: Michael S. Tsirkin --- net.h | 3 +++ net/tap.c | 8 ++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/net.h b/net.h index 4971fcb..116bb80 100644 --- a/net.h +++ b/net.h @@ -1,6 +1,7 @@ #ifndef QEMU_NET_H #define QEMU_NET_H +#include #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 { diff --git a/net/tap.c b/net/tap.c index 0d8b424..d3492de 100644 --- a/net/tap.c +++ b/net/tap.c @@ -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, };