Skip to contentSkip to conversation

vhost: initialize postcopy ufd properly

PATCH Applied Tiwei Bie 2 participants 3 messages Oct 24, 2018

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 vhost: initialize postcopy ufd properly

Currently, postcopy_ufd is initialized to 0 implicitly, so fd 0 could be closed unexpectedly by vhost_backend_cleanup(). Fix this issue by initializing postcopy_ufd to -1 explicitly.

Fixes 9eefef3b5970 ("vhost: introduce postcopy advise message")
---
 lib/librte_vhost/vhost.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost.c +1 -0
index 047ee535c..70ac6bc9c 100644
@@ -344,6 +344,7 @@ vhost_new_device(void)
 	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
 	dev->slave_req_fd = -1;
 	dev->vdpa_dev_id = -1;
+	dev->postcopy_ufd = -1;
 	rte_spinlock_init(&dev->slave_req_lock);
 
 	return i;
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Tiwei Bie

Currently, postcopy_ufd is initialized to 0 implicitly, so fd 0 could be closed unexpectedly by vhost_backend_cleanup(). Fix this issue by initializing postcopy_ufd to -1 explicitly.

Fixes 9eefef3b5970 ("vhost: introduce postcopy advise message")
---
  lib/librte_vhost/vhost.c | 1 +
  1 file changed, 1 insertion(+)
lib/librte_vhost/vhost.c +0 -0
index 047ee535c..70ac6bc9c 100644

lib/librte_vhost/vhost.c vhost_new_device(void) · line 350

Quoted 7 lines
lib/librte_vhost/vhost.c +1 -0
@@ -344,6 +344,7 @@ vhost_new_device(void)
  	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
  	dev->slave_req_fd = -1;
  	dev->vdpa_dev_id = -1;
+	dev->postcopy_ufd = -1;
  	rte_spinlock_init(&dev->slave_req_lock);
 
  	return i;

Thanks!
Maxime

#2 lore raw
In reply to Tiwei Bie
Quoted 17 lines · Tiwei Bie

Currently, postcopy_ufd is initialized to 0 implicitly, so fd 0 could be closed unexpectedly by vhost_backend_cleanup(). Fix this issue by initializing postcopy_ufd to -1 explicitly.

Fixes 9eefef3b5970 ("vhost: introduce postcopy advise message")
---
  lib/librte_vhost/vhost.c | 1 +
  1 file changed, 1 insertion(+)
lib/librte_vhost/vhost.c +0 -0
index 047ee535c..70ac6bc9c 100644

lib/librte_vhost/vhost.c vhost_new_device(void) · line 350

Quoted 7 lines
lib/librte_vhost/vhost.c +1 -0
@@ -344,6 +344,7 @@ vhost_new_device(void)
  	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
  	dev->slave_req_fd = -1;
  	dev->vdpa_dev_id = -1;
+	dev->postcopy_ufd = -1;
  	rte_spinlock_init(&dev->slave_req_lock);
 
  	return i;

Applied to dpdk-next-virtio/master.

Thanks,
Maxime