From patchwork Thu Feb 13 12:03:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonios Motakis X-Patchwork-Id: 319989 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 F0D6C2C0040 for ; Thu, 13 Feb 2014 23:07:13 +1100 (EST) Received: from localhost ([::1]:45740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDv4R-0003Ke-NZ for incoming@patchwork.ozlabs.org; Thu, 13 Feb 2014 07:07:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDv1S-0007UM-9A for qemu-devel@nongnu.org; Thu, 13 Feb 2014 07:04:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDv1M-00014Y-9C for qemu-devel@nongnu.org; Thu, 13 Feb 2014 07:04:06 -0500 Received: from mail-we0-f173.google.com ([74.125.82.173]:33875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDv1M-00014L-4S for qemu-devel@nongnu.org; Thu, 13 Feb 2014 07:04:00 -0500 Received: by mail-we0-f173.google.com with SMTP id x48so1688469wes.32 for ; Thu, 13 Feb 2014 04:03:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jQlyyLNIjKaBL8+GMS0zVELCg1yv+ArsIQzanmHLt/Q=; b=lP1kYCCAgSw93z7dK3MreZXoJVQsFA9pSNOFZ/xr4Uscdqjm2oNWyXpQtuArCL+A99 q+gLtlobxXOYhQWM/ohWU9R+6asLXd8RG3k6X0KsVL3trpaTbgYzB2y/bOYbK5kVSrBa Gk9s6/vIweOxqOzdU4kkvmofIcb4Di1bByDFwaBEON8BqzaGl3hFMv2OyOH90y0huxtw e9gVg8JziUyuFQkbHUDXSLlpS00ab6WlJRMFq3gVBwwsiN8UapIrbpBdCk6nzrpwWQ4u Vh0jH9GM5eFqYP85kDkCdGRfcHGim3TdtkaDCDxPPS1OiIyTDhdx8xFHU0b83GDKUFlc vRNw== X-Gm-Message-State: ALoCoQky6igiBsKs79z0K5vYvvC6DEB7YyJq0wh2ZJsY+ODVGYvXvmgKqr/wRp8GUfZFL3qM6ue1 X-Received: by 10.180.12.233 with SMTP id b9mr6053471wic.8.1392293039406; Thu, 13 Feb 2014 04:03:59 -0800 (PST) Received: from localhost.localdomain (home.tvelocity.eu. [82.67.68.96]) by mx.google.com with ESMTPSA id bj3sm4039419wjb.14.2014.02.13.04.03.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Feb 2014 04:03:58 -0800 (PST) From: Antonios Motakis To: qemu-devel@nongnu.org, snabb-devel@googlegroups.com Date: Thu, 13 Feb 2014 13:03:17 +0100 Message-Id: <1392293009-13812-7-git-send-email-a.motakis@virtualopensystems.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392293009-13812-1-git-send-email-a.motakis@virtualopensystems.com> References: <1392293009-13812-1-git-send-email-a.motakis@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.173 Cc: lukego@gmail.com, Antonios Motakis , tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v8 06/17] 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 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 854997d..cbbf50a 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); }