[dpdk-dev] vhost: fix close callfd on get vring base

Message ID 20180209171049.7132-1-tomaszx.kulasek@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tomasz Kulasek Feb. 9, 2018, 5:10 p.m. UTC
  This prevents from destroying & recreating user device in "incomplete"
vring state. virtio_is_ready() was returning true for devices with
vrings which did not have valid callfd (their VHOST_USER_SET_VRING_CALL
hasn't arrived yet)

Fixes: 8f972312b8f4 ("vhost: support vhost-user")
Cc: huawei.xie@intel.com
Cc: stable@dpdk.org

Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 lib/librte_vhost/vhost_user.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Jianfeng Tan Feb. 11, 2018, 1:47 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
> Sent: Saturday, February 10, 2018 1:11 AM
> To: yliu@fridaylinux.org
> Cc: dev@dpdk.org; Xie, Huawei; stable@dpdk.org; Stojaczyk, DariuszX
> Subject: [dpdk-dev] [PATCH] vhost: fix close callfd on get vring base
> 
> This prevents from destroying & recreating user device in "incomplete"
> vring state. virtio_is_ready() was returning true for devices with
> vrings which did not have valid callfd (their VHOST_USER_SET_VRING_CALL
> hasn't arrived yet)
> 
> Fixes: 8f972312b8f4 ("vhost: support vhost-user")
> Cc: huawei.xie@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>

Reviewed-by: Jianfeng Tan <jianfeng.tan@intel.com>

Thanks for fixing this.
  
Maxime Coquelin Feb. 20, 2018, 9:09 a.m. UTC | #2
On 02/09/2018 06:10 PM, Tomasz Kulasek wrote:
> This prevents from destroying & recreating user device in "incomplete"
> vring state. virtio_is_ready() was returning true for devices with
> vrings which did not have valid callfd (their VHOST_USER_SET_VRING_CALL
> hasn't arrived yet)
> 
> Fixes: 8f972312b8f4 ("vhost: support vhost-user")
> Cc:huawei.xie@intel.com
> Cc:stable@dpdk.org
> 
> Signed-off-by: Dariusz Stojaczyk<dariuszx.stojaczyk@intel.com>
> Signed-off-by: Tomasz Kulasek<tomaszx.kulasek@intel.com>
> ---
>   lib/librte_vhost/vhost_user.c | 5 +++++
>   1 file changed, 5 insertions(+)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

and applied to dpdk-next-virtio/master.

Thanks,
Maxime
  
Maxime Coquelin March 2, 2018, 11:05 a.m. UTC | #3
Hi Tomasz,

On 02/20/2018 10:09 AM, Maxime Coquelin wrote:
> 
> 
> On 02/09/2018 06:10 PM, Tomasz Kulasek wrote:
>> This prevents from destroying & recreating user device in "incomplete"
>> vring state. virtio_is_ready() was returning true for devices with
>> vrings which did not have valid callfd (their VHOST_USER_SET_VRING_CALL
>> hasn't arrived yet)
>>
>> Fixes: 8f972312b8f4 ("vhost: support vhost-user")
>> Cc:huawei.xie@intel.com
>> Cc:stable@dpdk.org
>>
>> Signed-off-by: Dariusz Stojaczyk<dariuszx.stojaczyk@intel.com>
>> Signed-off-by: Tomasz Kulasek<tomaszx.kulasek@intel.com>
>> ---
>>   lib/librte_vhost/vhost_user.c | 5 +++++
>>   1 file changed, 5 insertions(+)
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> and applied to dpdk-next-virtio/master.

I reworded the title:
vhost: cleanup device properly at stop time

Let me know if this is fine to you

Thanks,
Maxime

> Thanks,
> Maxime
  

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 65ee33919..dd8682c09 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -897,6 +897,11 @@  vhost_user_get_vring_base(struct virtio_net *dev,
 
 	vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
 
+	if (vq->callfd >= 0)
+		close(vq->callfd);
+
+	vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
+
 	if (dev->dequeue_zero_copy)
 		free_zmbufs(vq);
 	rte_free(vq->shadow_used_ring);