From patchwork Wed Jun 18 16:18:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 361722 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A445D140086 for ; Thu, 19 Jun 2014 04:37:54 +1000 (EST) Received: from localhost ([::1]:60004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxKk4-0004U4-MY for incoming@patchwork.ozlabs.org; Wed, 18 Jun 2014 14:37:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxIZ1-0001Ct-OX for qemu-devel@nongnu.org; Wed, 18 Jun 2014 12:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxIYv-0007AS-6e for qemu-devel@nongnu.org; Wed, 18 Jun 2014 12:18:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxIYu-0007AF-U7 for qemu-devel@nongnu.org; Wed, 18 Jun 2014 12:18:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5IGI9G7028382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jun 2014 12:18:09 -0400 Received: from redhat.com (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id s5IGI7eW028703; Wed, 18 Jun 2014 12:18:08 -0400 Date: Wed, 18 Jun 2014 19:18:36 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1403108034-32054-50-git-send-email-mst@redhat.com> References: <1403108034-32054-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1403108034-32054-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Nikolay Nikolaev , Anthony Liguori , Antonios Motakis Subject: [Qemu-devel] [PULL v2 049/106] vhost_net should call the poll callback only when it is set 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 From: Nikolay Nikolaev The poll callback needs to be called when bringing up or down the vhost_net instance. As it is not mandatory for an NetClient to implement it, invoke it only when it is set. Signed-off-by: Antonios Motakis Signed-off-by: Nikolay Nikolaev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/vhost_net.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6a9a32f..dcec0f7 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -168,7 +168,10 @@ static int vhost_net_start_one(struct vhost_net *net, goto fail_start; } - net->nc->info->poll(net->nc, false); + if (net->nc->info->poll) { + net->nc->info->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) { @@ -185,7 +188,9 @@ fail: int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file); assert(r >= 0); } - net->nc->info->poll(net->nc, true); + if (net->nc->info->poll) { + net->nc->info->poll(net->nc, true); + } vhost_dev_stop(&net->dev, dev); fail_start: vhost_dev_disable_notifiers(&net->dev, dev); @@ -206,7 +211,9 @@ static void vhost_net_stop_one(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); + if (net->nc->info->poll) { + net->nc->info->poll(net->nc, true); + } vhost_dev_stop(&net->dev, dev); vhost_dev_disable_notifiers(&net->dev, dev); }