From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9Hzm-0000q1-U5 for qemu-devel@nongnu.org; Fri, 31 Jan 2014 12:35:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9Hzg-0003Y9-WC for qemu-devel@nongnu.org; Fri, 31 Jan 2014 12:35:14 -0500 Received: from mail-wg0-f53.google.com ([74.125.82.53]:58463) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9Hzg-0003XS-RT for qemu-devel@nongnu.org; Fri, 31 Jan 2014 12:35:08 -0500 Received: by mail-wg0-f53.google.com with SMTP id y10so9290914wgg.8 for ; Fri, 31 Jan 2014 09:35:08 -0800 (PST) From: Antonios Motakis Date: Fri, 31 Jan 2014 18:34:34 +0100 Message-Id: <1391189683-1602-6-git-send-email-a.motakis@virtualopensystems.com> In-Reply-To: <1391189683-1602-1-git-send-email-a.motakis@virtualopensystems.com> References: <1391189683-1602-1-git-send-email-a.motakis@virtualopensystems.com> Subject: [Qemu-devel] [PATCH v7 05/13] vhost_net should call the poll callback only when it is set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, snabb-devel@googlegroups.com Cc: lukego@gmail.com, Antonios Motakis , tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com, mst@redhat.com 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 --- 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 006576d..6aa6e87 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -166,7 +166,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) { @@ -183,7 +186,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); @@ -204,7 +209,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); } -- 1.8.3.2