[libvirt] [PATCH 01/10] nodeinfo: Introduce linuxGetCPUGlobalPath()

Andrea Bolognani abologna at redhat.com
Fri Jul 17 16:13:20 UTC 2015


This is just a more generic version of linuxGetCPUPresentPath(),
which is now implemented by calling the new function appropriately.
---
 src/nodeinfo.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 105d7ab..64b12e6 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -958,16 +958,21 @@ linuxNodeGetMemoryStats(FILE *meminfo,
 }
 
 static char *
-linuxGetCPUPresentPath(const char *sysfs_prefix)
+linuxGetCPUGlobalPath(const char *sysfs_prefix,
+                      const char *file)
 {
     const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
     char *path = NULL;
 
-    if (virAsprintf(&path, "%s/cpu/present", prefix) < 0)
+    if (virAsprintf(&path, "%s/cpu/%s", prefix, file) < 0)
         return NULL;
+
     return path;
 }
 
+# define linuxGetCPUPresentPath(sysfs_prefix)            \
+    linuxGetCPUGlobalPath(sysfs_prefix, "present")
+
 /* Determine the maximum cpu id from a Linux sysfs cpu/present file. */
 static int
 linuxParseCPUmax(const char *path)
-- 
2.4.3




More information about the libvir-list mailing list