From: Tiwei Bie Date: Mon, 29 Oct 2018 05:28:03 +0000 (+0800) Subject: net/virtio-user: do not stop stopped device again X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f457e9007a117a2ca8fd00ed9ee29e734d04752d;p=dpdk.git net/virtio-user: do not stop stopped device again Without this change, virtio-user still works, but it will show annoying error messages like this on shutdown: vhost_kernel_set_backend(): VHOST_NET_SET_BACKEND fails, Operation not permitted vhost_kernel_ioctl(): VHOST_RESET_OWNER failed: Operation not permitted Fixes: e3b434818bbb ("net/virtio-user: support kernel vhost") Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug") Cc: stable@dpdk.org Reported-by: Stephen Hemminger Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index b4997ee3f7..0e35630513 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -184,6 +184,9 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) uint32_t i; pthread_mutex_lock(&dev->mutex); + if (!dev->started) + goto out; + for (i = 0; i < dev->max_queue_pairs; ++i) dev->ops->enable_qp(dev, i, 0); @@ -193,6 +196,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) return -1; } dev->started = false; +out: pthread_mutex_unlock(&dev->mutex); return 0;