New upstream version 16.11.9
[deb_dpdk.git] / drivers / net / virtio / virtio_user / virtio_user_dev.c
index 91f6a59..3e6787a 100644 (file)
@@ -182,6 +182,7 @@ error:
 
 int virtio_user_stop_device(struct virtio_user_dev *dev)
 {
+       struct vhost_vring_state state;
        uint32_t i;
 
        for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
@@ -192,6 +193,17 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
        for (i = 0; i < dev->max_queue_pairs; ++i)
                vhost_user_enable_queue_pair(dev->vhostfd, i, 0);
 
+       /* Stop the backend. */
+       for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
+               state.index = i;
+               if (vhost_user_sock(dev->vhostfd, VHOST_USER_GET_VRING_BASE,
+                                          &state) < 0) {
+                       PMD_DRV_LOG(ERR, "get_vring_base failed, index=%u\n",
+                                   i);
+                       return -1;
+               }
+       }
+
        return 0;
 }
 
@@ -240,6 +252,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
                PMD_INIT_LOG(ERR, "backend set up fails");
                return -1;
        }
+
        if (vhost_user_sock(dev->vhostfd, VHOST_USER_SET_OWNER, NULL) < 0) {
                PMD_INIT_LOG(ERR, "set_owner fails: %s", strerror(errno));
                return -1;