Commit c1cfc10a authored by Pawel Wodkowski's avatar Pawel Wodkowski Committed by Jim Harris
Browse files

rte_vhost: stop device before messages that can change something



Some messages like SET_FEATURES, SET_VRING_ADDR etc will change internal
state of VQ or device. To prevent race vs thread polling those queues
stop the device.

Change-Id: I15caf9da0decbaa660e9773c93d45ff148e5e9a8
Signed-off-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/395739


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 29181903
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -183,8 +183,12 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features)
	}

	if ((dev->flags & VIRTIO_DEV_RUNNING) && dev->negotiated_features != features) {
		if (dev->notify_ops->features_changed)
		if (dev->notify_ops->features_changed) {
			dev->notify_ops->features_changed(dev->vid, features);
		} else {
			dev->flags &= ~VIRTIO_DEV_RUNNING;
			dev->notify_ops->destroy_device(dev->vid);
		}
	}

	dev->negotiated_features = features;
@@ -358,6 +362,12 @@ vhost_user_set_vring_addr(struct virtio_net *dev, VhostUserMsg *msg)
	if (dev->mem == NULL)
		return -1;

	/* Remove from the data plane. */
	if (dev->flags & VIRTIO_DEV_RUNNING) {
		dev->flags &= ~VIRTIO_DEV_RUNNING;
		dev->notify_ops->destroy_device(dev->vid);
	}

	/* addr->index refers to the queue index. The txq 1, rxq is 0. */
	vq = dev->virtqueue[msg->payload.addr.index];

@@ -831,6 +841,12 @@ vhost_user_set_protocol_features(struct virtio_net *dev,
	if (protocol_features & ~VHOST_USER_PROTOCOL_FEATURES)
		return;

	/* Remove from the data plane. */
	if (dev->flags & VIRTIO_DEV_RUNNING) {
		dev->flags &= ~VIRTIO_DEV_RUNNING;
		dev->notify_ops->destroy_device(dev->vid);
	}

	dev->protocol_features = protocol_features;
}

@@ -853,6 +869,12 @@ vhost_user_set_log_base(struct virtio_net *dev, struct VhostUserMsg *msg)
		return -1;
	}

	/* Remove from the data plane. */
	if (dev->flags & VIRTIO_DEV_RUNNING) {
		dev->flags &= ~VIRTIO_DEV_RUNNING;
		dev->notify_ops->destroy_device(dev->vid);
	}

	size = msg->payload.log.mmap_size;
	off  = msg->payload.log.mmap_offset;
	RTE_LOG(INFO, VHOST_CONFIG,