On Wed, Apr 09, 2025 at 11:51:09PM +0800, Tomita Moeko wrote: > On 4/9/25 21:48, John Levon wrote: > > Add these helpers that access config space and return an -errno style > > return. > > > > Signed-off-by: John Levon <john.le...@nutanix.com> > > --- > > hw/vfio/pci.c | 134 ++++++++++++++++++++++++++++++++++---------------- > > 1 file changed, 91 insertions(+), 43 deletions(-) > > > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > > index ddeee33aa9..c3842d2f8d 100644 > > --- a/hw/vfio/pci.c > > +++ b/hw/vfio/pci.c > > @@ -964,6 +964,28 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev) > > } > > } > > > > +/* "Raw" read of underlying config space. */ > > +static int vfio_pci_config_space_read(VFIOPCIDevice *vdev, off_t offset, > > + uint32_t size, void *data) > > Returning ssize_t here might be better here to avoid casting issues, > though we would never read/write something exceeds INT32_MAX.
I considered this (and the later helpers in the patch), but most of the existing code already uses int. Happy to look at fixing the callers too (e.g. vfio_msi_setup()) if that's everyone's preference. regards john