[libvirt] [PATCH 12/15] util: pci: Introduce virPCIGetMdevTypes helper
Erik Skultety
eskultet at redhat.com
Mon Jan 29 12:24:49 UTC 2018
On Fri, Jan 26, 2018 at 12:39:00PM +0100, Michal Privoznik wrote:
> On 01/25/2018 10:23 AM, Erik Skultety wrote:
> > This is a replacement for the existing udevPCIGetMdevTypesCap which is
> > static to the udev backend. This simple helper constructs the sysfs path
> > from the device's base path for each mdev type and queries the
> > corresponding attributes of that type.
> >
> > Signed-off-by: Erik Skultety <eskultet at redhat.com>
> > ---
> > src/libvirt_private.syms | 1 +
> > src/util/virpci.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
> > src/util/virpci.h | 4 ++++
> > 3 files changed, 63 insertions(+)
> >
> > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> > index 75eaf1d4c..8d4c8dd3f 100644
> > --- a/src/libvirt_private.syms
> > +++ b/src/libvirt_private.syms
> > @@ -2456,6 +2456,7 @@ virPCIDeviceWaitForCleanup;
> > virPCIEDeviceInfoFree;
> > virPCIGetDeviceAddressFromSysfsLink;
> > virPCIGetHeaderType;
> > +virPCIGetMdevTypes;
> > virPCIGetNetName;
> > virPCIGetPhysicalFunction;
> > virPCIGetVirtualFunctionIndex;
> > diff --git a/src/util/virpci.c b/src/util/virpci.c
> > index fe57bef32..12d7ef0e4 100644
> > --- a/src/util/virpci.c
> > +++ b/src/util/virpci.c
> > @@ -3027,6 +3027,64 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
> > return ret;
> > }
> >
> > +
> > +int
> > +virPCIGetMdevTypes(const char *sysfspath,
> > + virMediatedDeviceTypePtr **types)
>
> Since this function returns size_t on success, I guess the retval should
> be type of ssize_t at least. We are not guaranteed that size_t will fit
ssize_t wouldn't really help, since assigning size_t might overflow, so the
only safe bet is long long, but I mean, do you really expect there to be more
than INT_MAX mdev types for a device? That would be a lot of types to support.
Erik
> into int (although in this case it will - currently you will have only
> limited number of MDEVs if any).
>
> ACK
>
> Michal
More information about the libvir-list
mailing list