[dpdk-dev] lib/librte_vhost: remove vhost device from data plane when receive VHOST_SET_MEM_TABLE message

Message ID EDCDDC5F3D468742B7A0048DF68542612FE3F306@IRSMSX104.ger.corp.intel.com (mailing list archive)
State Not Applicable, archived
Headers

Commit Message

Long, Thomas March 4, 2015, 11:57 a.m. UTC
  Acked-by: Tommy Long  <thomas.long@intel.com>


-----Original Message-----
From: Xie, Huawei 
Sent: Tuesday, March 3, 2015 2:26 AM
To: dev@dpdk.org
Cc: haifeng.lin@huawei.com; mukawa@igel.co.jp; Long, Thomas; Xie, Huawei
Subject: [PATCH] lib/librte_vhost: remove vhost device from data plane when receive VHOST_SET_MEM_TABLE message

This patch fixes the segfault issue in the case vhost receives new VHOST_SET_MEM_TABLE message without VHOST_VRING_GET_VRING_BASE(which we uses as the stop message).

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Thomas Monjalon March 5, 2015, 9:08 p.m. UTC | #1
> > This patch fixes the segfault issue in the case vhost receives new
> > VHOST_SET_MEM_TABLE message without VHOST_VRING_GET_VRING_BASE(which
> > we uses as the stop message).
> > 
> > Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> 
> Acked-by: Tommy Long  <thomas.long@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
index 97c5177..aa08706 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -109,6 +109,10 @@  user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg)
 	if (dev == NULL)
 		return -1;
 
+	/* Remove from the data plane. */
+	if (dev->flags & VIRTIO_DEV_RUNNING)
+		notify_ops->destroy_device(dev);
+
 	if (dev->mem) {
 		free_mem_region(dev);
 		free(dev->mem);