vhost: remove a hack on queue allocation
[dpdk.git] / lib / librte_vhost / socket.c
index bf03f84..6a30a31 100644 (file)
@@ -62,6 +62,7 @@ struct vhost_user_socket {
        int connfd;
        bool is_server;
        bool reconnect;
+       bool dequeue_zero_copy;
 };
 
 struct vhost_user_connection {
@@ -203,6 +204,9 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
        size = strnlen(vsocket->path, PATH_MAX);
        vhost_set_ifname(vid, vsocket->path, size);
 
+       if (vsocket->dequeue_zero_copy)
+               vhost_enable_dequeue_zero_copy(vid);
+
        RTE_LOG(INFO, VHOST_CONFIG, "new device, handle is %d\n", vid);
 
        vsocket->connfd = fd;
@@ -246,8 +250,8 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)
                vsocket->connfd = -1;
                close(connfd);
                *remove = 1;
-               free(conn);
                vhost_destroy_device(conn->vid);
+               free(conn);
 
                if (vsocket->reconnect)
                        vhost_user_create_client(vsocket);
@@ -444,7 +448,7 @@ vhost_user_create_client(struct vhost_user_socket *vsocket)
                return 0;
        }
 
-       RTE_LOG(ERR, VHOST_CONFIG,
+       RTE_LOG(WARNING, VHOST_CONFIG,
                "failed to connect to %s: %s\n",
                path, strerror(errno));
 
@@ -453,7 +457,7 @@ vhost_user_create_client(struct vhost_user_socket *vsocket)
                return -1;
        }
 
-       RTE_LOG(ERR, VHOST_CONFIG, "%s: reconnecting...\n", path);
+       RTE_LOG(INFO, VHOST_CONFIG, "%s: reconnecting...\n", path);
        reconn = malloc(sizeof(*reconn));
        if (reconn == NULL) {
                RTE_LOG(ERR, VHOST_CONFIG,
@@ -499,6 +503,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
        memset(vsocket, 0, sizeof(struct vhost_user_socket));
        vsocket->path = strdup(path);
        vsocket->connfd = -1;
+       vsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
 
        if ((flags & RTE_VHOST_USER_CLIENT) != 0) {
                vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT);