summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTiwei Bie <tiwei.bie@intel.com>2018-10-29 13:28:05 +0800
committerFerruh Yigit <ferruh.yigit@intel.com>2018-11-05 15:01:25 +0100
commit74dc6746a0f195907ec487df7de18a856108482f (patch)
tree6603b7d3dad1501dae5661449b9b0937aa82f3c2 /drivers
parent86d4b0618495faf58ef5e698b3c8ea76e82b54d6 (diff)
downloaddpdk-74dc6746a0f195907ec487df7de18a856108482f.zip
dpdk-74dc6746a0f195907ec487df7de18a856108482f.tar.gz
dpdk-74dc6746a0f195907ec487df7de18a856108482f.tar.xz
net/virtio-user: do not reset owner when driver resets
When driver resets the device, virtio-user just needs to send GET_VRING_BASE messages to stop the vhost backend, and that's what QEMU does. With this change, we won't need to set owner when starting virtio-user device anymore. This will help us to get rid of below error message on startup: vhost_kernel_ioctl(): VHOST_SET_OWNER failed: Device or resource busy Fixes: bce7e9050f9b ("net/virtio-user: fix start with kernel vhost") Fixes: 0d6a8752ac9d ("net/virtio-user: fix crash as features change") Cc: stable@dpdk.org Signed-off-by: Tiwei Bie <tiwei.bie@intel.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/virtio/virtio_user/virtio_user_dev.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 0e35630..0eb0f24 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -134,9 +134,6 @@ virtio_user_start_device(struct virtio_user_dev *dev)
if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)
goto error;
- /* Do not check return as already done in init, or reset in stop */
- dev->ops->send_request(dev, VHOST_USER_SET_OWNER, NULL);
-
/* Step 0: tell vhost to create queues */
if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
goto error;
@@ -181,7 +178,9 @@ error:
int virtio_user_stop_device(struct virtio_user_dev *dev)
{
+ struct vhost_vring_state state;
uint32_t i;
+ int error = 0;
pthread_mutex_lock(&dev->mutex);
if (!dev->started)
@@ -190,16 +189,23 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
for (i = 0; i < dev->max_queue_pairs; ++i)
dev->ops->enable_qp(dev, i, 0);
- if (dev->ops->send_request(dev, VHOST_USER_RESET_OWNER, NULL) < 0) {
- PMD_DRV_LOG(INFO, "Failed to reset the device\n");
- pthread_mutex_unlock(&dev->mutex);
- return -1;
+ /* Stop the backend. */
+ for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
+ state.index = i;
+ if (dev->ops->send_request(dev, VHOST_USER_GET_VRING_BASE,
+ &state) < 0) {
+ PMD_DRV_LOG(ERR, "get_vring_base failed, index=%u\n",
+ i);
+ error = -1;
+ goto out;
+ }
}
+
dev->started = false;
out:
pthread_mutex_unlock(&dev->mutex);
- return 0;
+ return error;
}
static inline void