From patchwork Fri Nov 16 13:40:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 199637 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9CE082C0094 for ; Sat, 17 Nov 2012 01:27:39 +1100 (EST) Received: from localhost ([::1]:54173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZMtN-0005HB-Hx for incoming@patchwork.ozlabs.org; Fri, 16 Nov 2012 09:27:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZMtE-0005Fg-AG for qemu-devel@nongnu.org; Fri, 16 Nov 2012 09:27:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZMtB-0005Rs-8K for qemu-devel@nongnu.org; Fri, 16 Nov 2012 09:27:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZMtA-0005Rg-VM for qemu-devel@nongnu.org; Fri, 16 Nov 2012 09:27:25 -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.14.4/8.14.4) with ESMTP id qAGERN6C032255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 Nov 2012 09:27:24 -0500 Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qAGDeJPN006944; Fri, 16 Nov 2012 08:40:20 -0500 From: Stefan Hajnoczi To: Date: Fri, 16 Nov 2012 14:40:03 +0100 Message-Id: <1353073206-31501-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1353073206-31501-1-git-send-email-stefanha@redhat.com> References: <1353073206-31501-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/4] net: add public qemu_net_poll() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The NetClientInfo .poll() callback is being called directly by hw/vhost_net.c. Create a public net.c function so callers do not depend on internals. This change is useful because later patches change net internals. Those changes shouldn't affect .poll() callers. Signed-off-by: Stefan Hajnoczi --- hw/vhost_net.c | 6 +++--- net.c | 7 +++++++ net.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 8241601..32ce40f 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -156,7 +156,7 @@ int vhost_net_start(struct vhost_net *net, goto fail_start; } - net->nc->info->poll(net->nc, false); + qemu_net_poll(net->nc, false); qemu_set_fd_handler(net->backend, NULL, NULL, NULL); file.fd = net->backend; for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { @@ -173,7 +173,7 @@ fail: int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file); assert(r >= 0); } - net->nc->info->poll(net->nc, true); + qemu_net_poll(net->nc, true); vhost_dev_stop(&net->dev, dev); fail_start: vhost_dev_disable_notifiers(&net->dev, dev); @@ -190,7 +190,7 @@ void vhost_net_stop(struct vhost_net *net, int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file); assert(r >= 0); } - net->nc->info->poll(net->nc, true); + qemu_net_poll(net->nc, true); vhost_dev_stop(&net->dev, dev); vhost_dev_disable_notifiers(&net->dev, dev); } diff --git a/net.c b/net.c index e8ae13e..025d999 100644 --- a/net.c +++ b/net.c @@ -466,6 +466,13 @@ qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, int iovcnt) return qemu_sendv_packet_async(nc, iov, iovcnt, NULL); } +void qemu_net_poll(NetClientState *nc, bool enable) +{ + if (nc->info->poll) { + nc->info->poll(nc, enable); + } +} + NetClientState *qemu_find_netdev(const char *id) { NetClientState *nc; diff --git a/net.h b/net.h index 04fda1d..763f926 100644 --- a/net.h +++ b/net.h @@ -111,6 +111,8 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, int iovcnt, void *opaque); +void qemu_net_poll(NetClientState *nc, bool enable); + void print_net_client(Monitor *mon, NetClientState *nc); void do_info_network(Monitor *mon);