src/dpdk/drivers/net/virtio/virtio_user/vhost_kernel.c
static int
vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
{
	struct vhost_kernel_data *data = dev->backend_data;
	struct vhost_memory_kernel *vm;
	int ret;

	vm = malloc(sizeof(struct vhost_memory_kernel) +
			max_regions *
			sizeof(struct vhost_memory_region));
	if (!vm)
		goto err;

	vm->nregions = 0;
	vm->padding = 0;

	/*
	 * The memory lock has already been taken by memory subsystem
	 * or virtio_user_start_device().
	 */
	ret = rte_memseg_list_walk_thread_unsafe(add_memseg_list, vm);
	if (ret < 0)
		goto err_free;

	ret = vhost_kernel_ioctl(data->vhostfds[0], VHOST_SET_MEM_TABLE, vm);
	if (ret < 0)
		goto err_free;

	free(vm);

	return 0;
err_free:
	free(vm);
err:
	PMD_DRV_LOG(ERR, "Failed to set memory table");
	return -1;
}
/* By default, vhost kernel module allows 64 regions, but DPDK may
 * have much more memory regions. Below function will treat each
 * contiguous memory space reserved by DPDK as one region.
 */
By default, vhost kernel module allows 64 regions, but DPDK may
have much more memory regions. Below function will treat each
contiguous memory space reserved by DPDK as one region.
By default vhost kernel module allows 64 regions but DPDK may have much more memory regions . Below function will treat each contiguous memory space reserved by DPDK as one region .
static int
vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
{
	struct vhost_kernel_data *data = dev->backend_data;
	struct vhost_memory_kernel *vm;
	int ret;
	vm = malloc(sizeof(struct vhost_memory_kernel) +
			max_regions *
			sizeof(struct vhost_memory_region));
	if (!vm)
		goto err;
	vm->nregions = 0;
	vm->padding = 0;
	ret = rte_memseg_list_walk_thread_unsafe(add_memseg_list, vm);
	if (ret < 0)
		goto err_free;
	ret = vhost_kernel_ioctl(data->vhostfds[0], VHOST_SET_MEM_TABLE, vm);
	if (ret < 0)
		goto err_free;
	free(vm);
	return 0;
err_free:
	free(vm);
err:
	PMD_DRV_LOG(ERR, "Failed to set memory table");
	return -1;
}
static int vhost_kernel_set_memory_table ( struct virtio_user_dev * dev ) { struct vhost_kernel_data * data = dev -> backend_data ; struct vhost_memory_kernel * vm ; int ret ; vm = malloc ( sizeof ( struct vhost_memory_kernel ) + max_regions * sizeof ( struct vhost_memory_region ) ) ; if ( ! vm ) goto err ; vm -> nregions = 0 ; vm -> padding = 0 ; ret = rte_memseg_list_walk_thread_unsafe ( add_memseg_list , vm ) ; if ( ret < 0 ) goto err_free ; ret = vhost_kernel_ioctl ( data -> vhostfds [ 0 ] , VHOST_SET_MEM_TABLE , vm ) ; if ( ret < 0 ) goto err_free ; free ( vm ) ; return 0 ; err_free : free ( vm ) ; err : PMD_DRV_LOG ( ERR , " " ) ; return -1 ; }
By default, vhost kernel module allows 64 regions, but DPDK may
 have much more memory regions.
By default vhost kernel module allows 64 regions but DPDK may have much more memory regions .
/*
	 * The memory lock has already been taken by memory subsystem
	 * or virtio_user_start_device().
	 */