Skip to contentSkip to conversation

vhost: fix missing flag reset on stop

PATCH In review Yuanhan Liu 2 participants 3 messages Jun 27, 2016 – Jun 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: fix missing flag reset on stop

Commit 550c9d27d143 ("vhost: set/reset device flags internally") moves the VIRTIO_DEV_RUNNING set/reset to vhost lib. But I missed one reset on stop; here fixes it.

Fixes 550c9d27d143 ("vhost: set/reset device flags internally")
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_vhost/vhost_user/virtio-net-user.c +3 -1
index a6a48dc..e7c4347 100644
@@ -317,8 +317,10 @@ user_get_vring_base(int vid, struct vhost_vring_state *state)
 	if (dev == NULL)
 		return -1;
 	/* We have to stop the queue (virtio) if it is running. */
-	if (dev->flags & VIRTIO_DEV_RUNNING)
+	if (dev->flags & VIRTIO_DEV_RUNNING) {
+		dev->flags &= ~VIRTIO_DEV_RUNNING;
 		notify_ops->destroy_device(vid);
+	}
 
 	/* Here we are safe to get the last used index */
 	vhost_get_vring_base(vid, state->index, state);
Signature · 1 line
1.9.0
Tested-by on v1 1/1
#1 lore raw
Quoted 30 lines

Commit 550c9d27d143 ("vhost: set/reset device flags internally") moves the VIRTIO_DEV_RUNNING set/reset to vhost lib. But I missed one reset on stop; here fixes it.

Fixes 550c9d27d143 ("vhost: set/reset device flags internally")
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_vhost/vhost_user/virtio-net-user.c +3 -1
index a6a48dc..e7c4347 100644
@@ -317,8 +317,10 @@ user_get_vring_base(int vid, struct
 vhost_vring_state *state)
 	if (dev == NULL)
 		return -1;
 	/* We have to stop the queue (virtio) if it is running. */
-	if (dev->flags & VIRTIO_DEV_RUNNING)
+	if (dev->flags & VIRTIO_DEV_RUNNING) {
+		dev->flags &= ~VIRTIO_DEV_RUNNING;
 		notify_ops->destroy_device(vid);
+	}
 
 	/* Here we are safe to get the last used index */
Quoted 3 lines

vhost_get_vring_base(vid, state->index, state);
--
1.9.0

Thanks for the patch. I've tested it and it solves the issue I was seeing where destroy_device was being called too many times.

author Applied
#2 lore raw
Quoted 29 lines · Ciara
Quoted 29 lines

Commit 550c9d27d143 ("vhost: set/reset device flags internally") moves the VIRTIO_DEV_RUNNING set/reset to vhost lib. But I missed one reset on stop; here fixes it.

Fixes 550c9d27d143 ("vhost: set/reset device flags internally")
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_vhost/vhost_user/virtio-net-user.c +3 -1
index a6a48dc..e7c4347 100644
@@ -317,8 +317,10 @@ user_get_vring_base(int vid, struct
 vhost_vring_state *state)
 	if (dev == NULL)
 		return -1;
 	/* We have to stop the queue (virtio) if it is running. */
-	if (dev->flags & VIRTIO_DEV_RUNNING)
+	if (dev->flags & VIRTIO_DEV_RUNNING) {
+		dev->flags &= ~VIRTIO_DEV_RUNNING;
 		notify_ops->destroy_device(vid);
+	}
 
Quoted 8 lines
Quoted 4 lines
lib/librte_vhost/vhost_user/virtio-net-user.c +0 -0
 	/* Here we are safe to get the last used index */

vhost_get_vring_base(vid, state->index, state);
--
1.9.0

Thanks for the patch. I've tested it and it solves the issue I was seeing where destroy_device was being called too many times.

Thanks for testing!

Applied to dpdk-next-virtio.

	--yliu