[PATCH v3 1/1] vhost: tolerate file descriptor in REM_MEM_REG msg
Maxime Coquelin
maxime.coquelin at redhat.com
Thu Oct 15 19:20:15 CEST 2026
On 7/31/26 10:10 AM, pravin.bathija at dell.com wrote:
> From: Pravin M Bathija<pravin.bathija at dell.com>
>
> The vhost-user specification (vhost-user.rst) states that no file
> descriptors SHOULD be passed with VHOST_USER_REM_MEM_REG. However,
> it also says: "For compatibility with existing incorrect
> implementations, the back-end MAY accept messages with one file
> descriptor. If a file descriptor is passed, the back-end MUST close
> it without using it otherwise."
>
> Some front-ends, notably libblkio, reuse the same message-building
> helper for both ADD_MEM_REG and REM_MEM_REG and unconditionally attach
> the mapping fd. The previous implementation rejected any
> REM_MEM_REG carrying a file descriptor with the error:
>
> expect 0 FDs for request VHOST_USER_REM_MEM_REG, received 1
>
> This broke teardown and memory region hot-swap with these front-ends.
>
> To reproduce, run any libblkio (v1.5.0) application using the
> virtio-blk-vhost-user driver against a DPDK vhost back-end. The
> connection is dropped during cleanup or whenever a memory region is
> unmapped and remapped.
>
> QEMU's libvhost-user reference back-end (vu_rem_mem_reg) already
> tolerates zero or one fd in this message. Align DPDK's behavior
> with both the specification's compatibility clause and the reference
> implementation by accepting the message and closing any unexpected fd.
>
> Tested with:
> - QEMU VM bring-up with runtime add/remove memory regions via
> QEMU monitor
> - QEMU post-copy live migration between source and destination
> - SPDK vhost-blk with libblkio (fio libblkio engine, write + md5
> verify)
> - libblkio alloc-mem-region and map-mem-region tests exercising
> ADD_MEM_REG / REM_MEM_REG / ADD_MEM_REG cycles against SPDK
> vhost-blk
>
> Fixes: 1d730eea6a42 ("vhost: add memory region handlers")
> Cc:stable at dpdk.org
>
> Signed-off-by: Pravin M Bathija<pravin.bathija at dell.com>
> ---
> lib/vhost/vhost_user.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
Applied to next-virtio/for-next-net.
Thanks,
Maxime
More information about the dev
mailing list