}
/*
- * Reallocate virtio_dev and vhost_virtqueue data structure to make them on the
- * same numa node as the memory of vring descriptor.
+ * Reallocate virtio_dev, vhost_virtqueue and related data structures to
+ * make them on the same numa node as the memory of vring descriptor.
*/
#ifdef RTE_LIBRTE_VHOST_NUMA
static struct virtio_net*
goto out;
}
if (oldnode != newnode) {
+ struct rte_vhost_memory *old_mem;
+ ssize_t mem_size;
+
VHOST_LOG_CONFIG(INFO,
"reallocate dev from %d to %d node\n",
oldnode, newnode);
memcpy(dev, old_dev, sizeof(*dev));
rte_free(old_dev);
+
+ mem_size = sizeof(struct rte_vhost_memory) +
+ sizeof(struct rte_vhost_mem_region) * dev->mem->nregions;
+ old_mem = dev->mem;
+ dev->mem = rte_malloc_socket(NULL, mem_size, 0, newnode);
+ if (!dev->mem) {
+ dev->mem = old_mem;
+ goto out;
+ }
+
+ memcpy(dev->mem, old_mem, mem_size);
+ rte_free(old_mem);
}
out: