{
memset(vq, 0, sizeof(struct vhost_virtqueue));
- vq->kickfd = -1;
- vq->callfd = -1;
+ vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
+ vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
/* Backends are set to -1 indicating an inactive device. */
vq->backend = -1;
{
struct virtio_net *dev = get_device(ctx);
+ if (dev == NULL)
+ return;
+
if (dev->flags & VIRTIO_DEV_RUNNING)
notify_ops->destroy_device(dev);
sizeof(dev->ifname) : if_len;
strncpy(dev->ifname, if_name, len);
+ dev->ifname[sizeof(dev->ifname) - 1] = '\0';
}
struct vhost_virtqueue *old_vq, *vq;
int ret;
+ /*
+ * vq is allocated on pairs, we should try to do realloc
+ * on first queue of one queue pair only.
+ */
+ if (index % VIRTIO_QNUM != 0)
+ return dev;
+
old_dev = dev;
vq = old_vq = dev->virtqueue[index];
if (oldnode != newnode) {
RTE_LOG(INFO, VHOST_CONFIG,
"reallocate vq from %d to %d node\n", oldnode, newnode);
- vq = rte_malloc_socket(NULL, sizeof(*vq), 0, newnode);
+ vq = rte_malloc_socket(NULL, sizeof(*vq) * VIRTIO_QNUM, 0,
+ newnode);
if (!vq)
return dev;
- memcpy(vq, old_vq, sizeof(*vq));
+ memcpy(vq, old_vq, sizeof(*vq) * VIRTIO_QNUM);
rte_free(old_vq);
}
out:
dev->virtqueue[index] = vq;
+ dev->virtqueue[index + 1] = vq + 1;
vhost_devices[dev->device_fh] = dev;
return dev;