Blob Blame History Raw
From a2dd895c863e4921fcc7e5b1939f8ca2526768c0 Mon Sep 17 00:00:00 2001
Message-Id: <a2dd895c863e4921fcc7e5b1939f8ca2526768c0@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Wed, 5 Aug 2015 18:18:22 +0200
Subject: [PATCH] nodeinfo: Introduce linuxGetCPUGlobalPath()

This is just a more generic version of linuxGetCPUPresentPath(),
which is now implemented by calling the new function appropriately.

(cherry picked from commit bd87f07c25bcdeaa48219deb7dbd94b5fcd6ca3c)

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1213713

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/nodeinfo.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 105d7ab..b09a4fd 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -958,16 +958,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)
-- 
2.5.0