mlx4: avoid init errors when kernel modules are not loaded
[dpdk.git] / lib / librte_vhost / virtio-net.c
index 20567ff..4672e67 100644 (file)
@@ -185,13 +185,13 @@ cleanup_device(struct virtio_net *dev)
        }
 
        /* Close any event notifiers opened by device. */
-       if (dev->virtqueue[VIRTIO_RXQ]->callfd)
+       if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0)
                close((int)dev->virtqueue[VIRTIO_RXQ]->callfd);
-       if (dev->virtqueue[VIRTIO_RXQ]->kickfd)
+       if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0)
                close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd);
-       if (dev->virtqueue[VIRTIO_TXQ]->callfd)
+       if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0)
                close((int)dev->virtqueue[VIRTIO_TXQ]->callfd);
-       if (dev->virtqueue[VIRTIO_TXQ]->kickfd)
+       if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0)
                close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd);
 }
 
@@ -595,10 +595,10 @@ set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
        /* file->index refers to the queue index. The txq is 1, rxq is 0. */
        vq = dev->virtqueue[file->index];
 
-       if ((int)vq->kickfd >= 0)
-               close((int)vq->kickfd);
+       if ((int)vq->callfd >= 0)
+               close((int)vq->callfd);
 
-       vq->kickfd = file->fd;
+       vq->callfd = file->fd;
 
        return 0;
 }
@@ -621,10 +621,10 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
        /* file->index refers to the queue index. The txq is 1, rxq is 0. */
        vq = dev->virtqueue[file->index];
 
-       if ((int)vq->callfd >= 0)
-               close((int)vq->callfd);
+       if ((int)vq->kickfd >= 0)
+               close((int)vq->kickfd);
 
-       vq->callfd = file->fd;
+       vq->kickfd = file->fd;
 
        return 0;
 }