Hi, This series adds a new memory backend, similar to hostmem-file, except that it doesn't need to create files. It also enforces memory sealing.
This backend is mainly useful for sharing the memory with other processes. Note that Linux supports transparent huge-pages of shmem/memfd memory since 4.8. It is relatively easier to set up THP than a dedicate hugepage mount point by using "madvise" in /sys/kernel/mm/transparent_hugepage/shmem_enabled. Since 4.14, memfd allows to set hugetlb requirement explicitly. Pending for merge in 4.16 is memfd sealing support for hugetlb backed memory. Usage: -object memory-backend-memfd,id=mem1,size=1G v7: - fix a small memory leak - update documentation and commit messages - rebased v6: - add hugetlbsize option - run vhost-user read-guest-mem test with memfile & memfd backend v5: - add memfd hugetlb support - add seal and hugeltb options to memfd memory backend - update qemu-option to explain sharing works with vhost-user for now - rebased, misc code changes v4: - rebased, now that preliminary patches are merged v3: - make vhost-user-test use memfd only if possible - rebased v2: - make it linux-specific - minor changes and commit message tweaks Marc-André Lureau (7): memfd: add error argument, instead of perror() memfd: add hugetlb support memfd: add hugetlbsize argument Add memfd based hostmem tests: keep compiling failing vhost-user tests vhost-user-test: make read-guest-mem setup its own qemu tests: use memfd in vhost-user-test include/qemu/memfd.h | 5 +- backends/hostmem-memfd.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio/vhost.c | 8 ++- tests/vhost-user-test.c | 128 +++++++++++++++++++++++------------ util/memfd.c | 78 ++++++++++++++-------- backends/Makefile.objs | 2 + qemu-options.hx | 22 ++++++ 7 files changed, 340 insertions(+), 73 deletions(-) create mode 100644 backends/hostmem-memfd.c -- 2.16.0.rc1.1.gef27df75a1