From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4C0938043 for ; Wed, 10 Dec 2014 22:40:03 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 10 Dec 2014 13:39:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="427504484" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 10 Dec 2014 13:29:10 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id sBALdpIl003892; Thu, 11 Dec 2014 05:39:51 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sBALdn2c014031; Thu, 11 Dec 2014 05:39:51 +0800 Received: (from hxie5@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id sBALdnW1014027; Thu, 11 Dec 2014 05:39:49 +0800 From: Huawei Xie To: dev@dpdk.org Date: Thu, 11 Dec 2014 05:37:56 +0800 Message-Id: <1418247477-13920-12-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1418247477-13920-1-git-send-email-huawei.xie@intel.com> References: <1418247477-13920-1-git-send-email-huawei.xie@intel.com> Cc: haifeng.lin@intel.com Subject: [dpdk-dev] [PATCH RFC v2 11/12] lib/librte_vhost: kick/callfd fix X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Dec 2014 21:40:04 -0000 Signed-off-by: Huawei Xie --- lib/librte_vhost/vhost_user/virtio-net-user.c | 4 ++-- lib/librte_vhost/virtio-net.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c index 3aecb17..4e49e9b 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -274,11 +274,11 @@ user_get_vring_base(struct vhost_device_ctx ctx, * sent and only sent in vhost_vring_stop. * TODO: cleanup the vring, it isn't usable since here. */ - if (dev->virtqueue[VIRTIO_RXQ]->callfd) { + if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >=0) { close(dev->virtqueue[VIRTIO_RXQ]->callfd); dev->virtqueue[VIRTIO_RXQ]->callfd = (eventfd_t)-1; } - if (dev->virtqueue[VIRTIO_TXQ]->callfd) { + if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >=0) { close(dev->virtqueue[VIRTIO_TXQ]->callfd); dev->virtqueue[VIRTIO_TXQ]->callfd = (eventfd_t)-1; } diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 0b49f1b..f37fed0 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -253,6 +253,11 @@ init_device(struct virtio_net *dev) memset(dev->virtqueue[VIRTIO_RXQ], 0, sizeof(struct vhost_virtqueue)); memset(dev->virtqueue[VIRTIO_TXQ], 0, sizeof(struct vhost_virtqueue)); + dev->virtqueue[VIRTIO_RXQ]->kickfd = (eventfd_t)-1; + dev->virtqueue[VIRTIO_RXQ]->callfd = (eventfd_t)-1; + dev->virtqueue[VIRTIO_TXQ]->kickfd = (eventfd_t)-1; + dev->virtqueue[VIRTIO_TXQ]->callfd = (eventfd_t)-1; + /* Backends are set to -1 indicating an inactive device. */ dev->virtqueue[VIRTIO_RXQ]->backend = VIRTIO_DEV_STOPPED; dev->virtqueue[VIRTIO_TXQ]->backend = VIRTIO_DEV_STOPPED; @@ -615,8 +620,10 @@ set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file) /* file->index refers to the queue index. The txq is 1, rxq is 0. */ vq = dev->virtqueue[file->index]; - if (vq->kickfd) + if ((int)vq->kickfd >=0) { + printf("close %d\n", (int)vq->kickfd); close((int)vq->kickfd); + } vq->kickfd = file->fd; @@ -641,8 +648,10 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file) /* file->index refers to the queue index. The txq is 1, rxq is 0. */ vq = dev->virtqueue[file->index]; - if (vq->callfd) + if ((int)vq->callfd >= 0) { + printf("close callfd %u\n", (int)vq->callfd); close((int)vq->callfd); + } vq->callfd = file->fd; return 0; -- 1.8.1.4