From patchwork Tue May 27 12:04:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 352892 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 703FB140098 for ; Tue, 27 May 2014 22:08:46 +1000 (EST) Received: from localhost ([::1]:33855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpGBQ-0001u0-1t for incoming@patchwork.ozlabs.org; Tue, 27 May 2014 08:08:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpG7y-0005Fk-HN for qemu-devel@nongnu.org; Tue, 27 May 2014 08:05:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpG7s-0007iG-5B for qemu-devel@nongnu.org; Tue, 27 May 2014 08:05:10 -0400 Received: from mail-we0-f170.google.com ([74.125.82.170]:42074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpG7r-0007gj-TG for qemu-devel@nongnu.org; Tue, 27 May 2014 08:05:04 -0400 Received: by mail-we0-f170.google.com with SMTP id u57so9653157wes.15 for ; Tue, 27 May 2014 05:05:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=RQ5t7AwVgdG6955R40rPRfWSbE1oOFStCOQosg8nH1w=; b=cniifmuwBnX7O1/nB8xZd9SlHCWm5eJHNafPHhX6mC3/MMLaSgzhxgPiK69rwsVU6x HFYtggSiI2Vf76Avapye5n2ACNchy1GmyOHXKY2u4bDuGYX3INnEyb9eiHDXYHDD/IxF H0CMBC8gl8Gb2/Rky4HwmTCHvvwp1Q+uoYVACvzOarl9ydGLEhTt7+TUpnAuc6HHbjp/ rz9dXXpiITSWannL1CwruCHUU0fYvg32ntuNRnBUL5RdnGKS/cxrWTdTHN9rM/7kVyR8 1J+QEX+R84upz6emcFEelOF/khj3tOIMQRgUiEcJO7n/fbRHFaXbpoM579h3Aiw/qn8h n0NQ== X-Gm-Message-State: ALoCoQnHgaiXblAWclyUXxDHHi3+6pKDagCQX/ann9KdK1IwCZOuIyS4+p4GVRdrStI0BZTVibme X-Received: by 10.194.62.140 with SMTP id y12mr24912245wjr.27.1401192302738; Tue, 27 May 2014 05:05:02 -0700 (PDT) Received: from [0.0.14.236] ([82.146.27.14]) by mx.google.com with ESMTPSA id dh1sm34550942wjc.25.2014.05.27.05.05.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 May 2014 05:05:02 -0700 (PDT) From: Nikolay Nikolaev To: snabb-devel@googlegroups.com, qemu-devel@nongnu.org Date: Tue, 27 May 2014 15:04:55 +0300 Message-ID: <20140527120450.15172.26370.stgit@3820> In-Reply-To: <20140527120050.15172.94908.stgit@3820> References: <20140527120050.15172.94908.stgit@3820> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.170 Cc: a.motakis@virtualopensystems.com, luke@snabb.co, tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v10 07/18] 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 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); }