]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Added function pciSysfsFile to enable access to the PCI SYSFS files.
authorShradha Shah <sshah@solarflare.com>
Wed, 14 Dec 2011 10:50:01 +0000 (10:50 +0000)
committerEric Blake <eblake@redhat.com>
Wed, 11 Jan 2012 20:01:16 +0000 (13:01 -0700)
src/util/pci.c
src/util/pci.h

index cd82b431ce3e6c6cffa294ccee7da93aabc71f8d..5e09c2fb91d5a693d6e28974dcd5abca6310073b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2011 Red Hat, Inc.
+ * Copyright (C) 2009-2012 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -2026,6 +2026,22 @@ out:
     return ret;
 }
 
+/*
+ * 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
  */
index 76e37e37b0007760fbf965fb8b45097f40bb2abc..fe62a257e217af44a8ed5b880a19db038eb35aa5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009, 2011 Red Hat, Inc.
+ * Copyright (C) 2009, 2011-2012 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -109,4 +109,7 @@ 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)
+    ATTRIBUTE_RETURN_CHECK;
+
 #endif /* __VIR_PCI_H__ */