[libvirt] [PATCH 1/5 v3] Added function pciSysfsFile to enable access to the PCI SYSFS files.

Daniel P. Berrange berrange at redhat.com
Tue Jan 10 10:50:48 UTC 2012


On Wed, Dec 14, 2011 at 10:50:01AM +0000, Shradha Shah wrote:
> ---
>  src/util/pci.c |   16 ++++++++++++++++
>  src/util/pci.h |    2 ++
>  2 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/src/util/pci.c b/src/util/pci.c
> index cd82b43..d0ba4c5 100644
> --- a/src/util/pci.c
> +++ b/src/util/pci.c
> @@ -2027,6 +2027,22 @@ out:
>  }
>  
>  /*
> + * Returns a path to the PCI sysfs file given the BDF of the PCI function
> + */
> +
> +int
> +pciSysfsFile(char *pciDeviceName, char **pci_sysfs_device_link)
> +{
> +    if (virAsprintf(pci_sysfs_device_link, PCI_SYSFS "devices/%s",
> +                    pciDeviceName) < 0) {
> +        virReportOOMError();
> +        return -1;
> +    }
> +    
> +    return 0;
> +}
> +
> +/*
>   * Returns the network device name of a pci device
>   */
>  int
> diff --git a/src/util/pci.h b/src/util/pci.h
> index 76e37e3..f98e745 100644
> --- a/src/util/pci.h
> +++ b/src/util/pci.h
> @@ -109,4 +109,6 @@ int pciGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
>  
>  int pciDeviceNetName(char *device_link_sysfs_path, char **netname);
>  
> +int pciSysfsFile(char *pciDeviceName, char **pci_sysfs_device_link);

We could add the 'ATTRIBUTE_RETURN_CHECK' annotation to this method

>  #endif /* __VIR_PCI_H__ */

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list