Hi Naman,

Thanks for the series. However, the multiple FDs are a vfio-user
transport detail. The core VFIO only needs to know "which fd to
mmap for this subregion" and it doesn't need to manage arrays of
FDs per region. So, I'd prefer :

 1. No change.
2. Add 'fd' and 'fd_offset' to VFIOMmap : typedef struct VFIOMmap {
     ...
    +    int fd;             /* per-mmap fd, or -1 to use the region fd */
    +    uint64_t fd_offset; /* offset within fd for the mmap call */
     } VFIOMmap;

    This is the only core VFIO change.

 3. Add a 'setup_sparse_mmaps' hook to VFIODeviceIOOps
4. vfio-user: support multiple FDs for sparse mmap regions
    All multi-fd logic stays in hw/vfio-user/device.c

Thanks,

C.


On 9/3/26 19:46, Naman Gulati wrote:
Gentle ping on this series incase it got lost in the noise :)

On Tue, Aug 25, 2026 at 10:00 PM Naman Gulati <[email protected]> wrote:

This series extends the vfio-user protocol specification to allow
servers to pass multiple file descriptors for different sparse memory
areas to be mmap'ed within a single device region.

This extension is intended for exposing paravirtualized PCI devices via
a vfio-user server that may have multiple unique sub-regions in a BAR
backed by some mmap'able buffers sourced from distinct file descriptors.

This change introduces a new capability:
   VFIO_REGION_INFO_CAP_SPARSE_MMAP_FDS

Unlike VFIO_REGION_INFO_CAP_SPARSE_MMAP (which maps all sparse areas
from a single open file descriptor), this new capability defines an
array of sparse mmap areas where each area contains an index into the
array of file descriptors.

When all sparse areas share a single file descriptor, servers may
continue to emit VFIO_REGION_INFO_CAP_SPARSE_MMAP and send exactly one
file descriptor in SCM_RIGHTS for backwards compatibility with older
clients.

The extensions in this series also lays the groundwork to make use of
the in-development series [1] extending vfio-pci to return distinct
dmabuf FDs for discrete regions of a device's BAR. A vfio-user server
may choose to return dmabuf FDs for various regions of a device's BAR to
map a vfio passthrough device into the guest, in order to retain control
of the device and be able to revoke mappings passed to the VM.

libvfio-user server side changes WIP on github [2].


[1] https://lore.kernel.org/all/[email protected]
[2] https://github.com/NamanGulati/libvfio-user/tree/multi-region-fd

---
Changes from RFC:
   - Refactored the get_region_info callback to keep vbasedev constant
     and take in a VFIORegionFDs* out parameter to store the received fds.
   - Link to RFC: 
https://lore.kernel.org/qemu-devel/[email protected]
---

Naman Gulati (3):
   vfio-user: add multi-fd region mmap capability
   vfio: mmap sparse regions backed by multiple FDs
   vfio-user: implement client support for multi-fd region mmap

  docs/interop/vfio-user.rst    | 71 +++++++++++++++++++++++++++++++++--
  hw/vfio-user/device.c         | 66 ++++++++++++++++++++++++++++++--
  hw/vfio-user/protocol.h       | 20 ++++++++++
  hw/vfio/device.c              | 49 ++++++++++++++----------
  hw/vfio/region.c              | 41 ++++++++++++++++----
  hw/vfio/vfio-region.h         |  8 ++++
  include/hw/vfio/vfio-device.h | 32 ++++++++++++++--
  7 files changed, 249 insertions(+), 38 deletions(-)

--
2.55.0.860.g4b6b3295ed-goog




Reply via email to