7a3408
From a2dd895c863e4921fcc7e5b1939f8ca2526768c0 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <a2dd895c863e4921fcc7e5b1939f8ca2526768c0@dist-git>
7a3408
From: Andrea Bolognani <abologna@redhat.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:22 +0200
7a3408
Subject: [PATCH] nodeinfo: Introduce linuxGetCPUGlobalPath()
7a3408
7a3408
This is just a more generic version of linuxGetCPUPresentPath(),
7a3408
which is now implemented by calling the new function appropriately.
7a3408
7a3408
(cherry picked from commit bd87f07c25bcdeaa48219deb7dbd94b5fcd6ca3c)
7a3408
7a3408
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1213713
7a3408
7a3408
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/nodeinfo.c | 12 ++++++++++--
7a3408
 1 file changed, 10 insertions(+), 2 deletions(-)
7a3408
7a3408
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
7a3408
index 105d7ab..b09a4fd 100644
7a3408
--- a/src/nodeinfo.c
7a3408
+++ b/src/nodeinfo.c
7a3408
@@ -958,16 +958,24 @@ linuxNodeGetMemoryStats(FILE *meminfo,
7a3408
 }
7a3408
 
7a3408
 static char *
7a3408
-linuxGetCPUPresentPath(const char *sysfs_prefix)
7a3408
+linuxGetCPUGlobalPath(const char *sysfs_prefix,
7a3408
+                      const char *file)
7a3408
 {
7a3408
     const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
7a3408
     char *path = NULL;
7a3408
 
7a3408
-    if (virAsprintf(&path, "%s/cpu/present", prefix) < 0)
7a3408
+    if (virAsprintf(&path, "%s/cpu/%s", prefix, file) < 0)
7a3408
         return NULL;
7a3408
+
7a3408
     return path;
7a3408
 }
7a3408
 
7a3408
+static char *
7a3408
+linuxGetCPUPresentPath(const char *sysfs_prefix)
7a3408
+{
7a3408
+    return linuxGetCPUGlobalPath(sysfs_prefix, "present");
7a3408
+}
7a3408
+
7a3408
 /* Determine the maximum cpu id from a Linux sysfs cpu/present file. */
7a3408
 static int
7a3408
 linuxParseCPUmax(const char *path)
7a3408
-- 
7a3408
2.5.0
7a3408