]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
nodeinfo: Introduce linuxGetCPUGlobalPath()
authorAndrea Bolognani <abologna@redhat.com>
Mon, 20 Jul 2015 16:37:21 +0000 (18:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Jul 2015 08:14:01 +0000 (10:14 +0200)
This is just a more generic version of linuxGetCPUPresentPath(),
which is now implemented by calling the new function appropriately.

src/nodeinfo.c

index 2bf611c642fc7287e97a1a6df1bbc07bd03e22f0..64442563f2be1d3882b94b459c92013ec62e6c31 100644 (file)
@@ -959,16 +959,24 @@ 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;
 }
 
+static char *
+linuxGetCPUPresentPath(const char *sysfs_prefix)
+{
+    return linuxGetCPUGlobalPath(sysfs_prefix, "present");
+}
+
 /* Determine the maximum cpu id from a Linux sysfs cpu/present file. */
 static int
 linuxParseCPUmax(const char *path)