From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id 8FE228E7A for ; Wed, 19 Aug 2015 11:53:03 +0200 (CEST) Received: by paccq16 with SMTP id cq16so110635049pac.1 for ; Wed, 19 Aug 2015 02:53: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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bsVxs/CQDP+RHClJ3ARr8SeUXImu/Rx5Imtm2sG4QC8=; b=JoS+Ook3KlSray77YhSRN3QcZtZ8fM69Ir3oc6vS7yM8z2GGDdAXCb1cLIAoMr/ReZ sCK32UL72mdbZULeF8HS9HyKEURkZqjGArBaSCuzXSvtNciiIEl+VVBlK/6pfN30n5xc dRG1BGQkIlsF+sVAXSKy3sw4FBj39OUaZDpGNqC3B6mij1MbdW4cY+eH13n6TG9pnnHP juhRGUvNdGjGu/q+24907sW3zCiHklTdTy1Q6+RV2tOJZn6z4jN375yjnnX8DgsTi/i8 zYPEWFI7LD5e4DuPsXMCCR8Tr9+sjVY7nesvCghj8O7OFMguey/I66bjyV0zzrfZ22E1 AOAA== X-Gm-Message-State: ALoCoQlIBCgUroCsap4yvD+KG0WnzaJm0VhIFYoqBdjXNWW1KBTY0ktMkUlCQ8u+QSEVPDQnPl/S X-Received: by 10.66.90.166 with SMTP id bx6mr22563507pab.133.1439977982924; Wed, 19 Aug 2015 02:53:02 -0700 (PDT) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id qe3sm212368pbc.73.2015.08.19.02.53.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 02:53:02 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Wed, 19 Aug 2015 18:51:08 +0900 Message-Id: <1439977869-28091-2-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1439977869-28091-1-git-send-email-mukawa@igel.co.jp> References: <1439977869-28091-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH 2/3] vhost: Fix RESET_OWNER handling not to close callfd 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, 19 Aug 2015 09:53:04 -0000 When RESET_OWNER message is issued, vhost backend shouldn't close 'callfd', because it will be valid while vhost-user connection is established. It should be closed when connection is closed. Signed-off-by: Tetsuya Mukawa --- lib/librte_vhost/virtio-net.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 144f301..7794e8b 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -189,13 +189,9 @@ cleanup_device(struct virtio_net *dev) free(dev->mem); } - /* Close any event notifiers opened by device. */ - if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0) - close((int)dev->virtqueue[VIRTIO_RXQ]->callfd); + /* Close kickfd event notifiers opened by device. */ if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0) close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd); - if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0) - close((int)dev->virtqueue[VIRTIO_TXQ]->callfd); if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0) close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd); } @@ -206,6 +202,12 @@ cleanup_device(struct virtio_net *dev) static void free_device(struct virtio_net_config_ll *ll_dev) { + /* close callfd when connection is closed */ + if ((int)ll_dev->dev.virtqueue[VIRTIO_RXQ]->callfd >= 0) + close((int)ll_dev->dev.virtqueue[VIRTIO_RXQ]->callfd); + if ((int)ll_dev->dev.virtqueue[VIRTIO_TXQ]->callfd >= 0) + close((int)ll_dev->dev.virtqueue[VIRTIO_TXQ]->callfd); + /* Free any malloc'd memory */ rte_free(ll_dev->dev.virtqueue[VIRTIO_RXQ]); rte_free(ll_dev->dev.virtqueue[VIRTIO_TXQ]); @@ -241,6 +243,21 @@ rm_config_ll_entry(struct virtio_net_config_ll *ll_dev, } } + +/* + * Rset variables in device structure. + */ +static void +reset_device(struct virtio_net *dev) +{ + dev->virtqueue[VIRTIO_RXQ]->kickfd = (eventfd_t)-1; + dev->virtqueue[VIRTIO_TXQ]->kickfd = (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; +} + /* * Initialise all variables in device structure. */ @@ -261,14 +278,10 @@ 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; + reset_device(dev); } /* @@ -403,7 +416,7 @@ reset_owner(struct vhost_device_ctx ctx) ll_dev = get_config_ll_entry(ctx); cleanup_device(&ll_dev->dev); - init_device(&ll_dev->dev); + reset_device(&ll_dev->dev); return 0; } -- 2.1.4