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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/util/pci.c |   17 +++++++++++++++++
 src/util/pci.h |    2 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/util/pci.c b/src/util/pci.c
index 857078d..89a9d12 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -39,6 +39,7 @@
 #include "command.h"
 #include "virterror_internal.h"
 #include "virfile.h"
+#include "virnetdev.h"
 
 /* avoid compilation breakage on some systems */
 #ifndef MODPROBE
@@ -1991,6 +1992,22 @@ out:
     return ret;
 }
 
+ /*
+  * Returns a path to the PCI sysfs file given the BDF of the PCI function
+  */
+
+int
+pciSysfsFile(char **pci_sysfs_device_link, char *pciDeviceName)
+{
+    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
  */
diff --git a/src/util/pci.h b/src/util/pci.h
index 8e47fc2..3800d98 100644
--- a/src/util/pci.h
+++ b/src/util/pci.h
@@ -143,4 +143,6 @@ int pciGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
 
 int pciDeviceNetName(char *device_link_sysfs_path, char **netname);
 
+int pciSysfsFile(char **pci_sysfs_device_link, char *pciDeviceName);
+
 #endif /* __VIR_PCI_H__ */
-- 
1.7.4.4


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]