7a3408
From 44e605079ad64ead62dc949c9cd81326f10d3711 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <44e605079ad64ead62dc949c9cd81326f10d3711@dist-git>
7a3408
From: Andrea Bolognani <abologna@redhat.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:21 +0200
7a3408
Subject: [PATCH] nodeinfo: Fix nodeGetCPUBitmap()'s fallback code path
7a3408
7a3408
During the recent refactoring/cleanups, a bug has been introduced
7a3408
that caused all CPUs to be reported as online unless the sysfs
7a3408
cpu/present file was available.
7a3408
7a3408
This commit fixes the fallback code path by building the directory
7a3408
path passed to virNodeGetCpuValue() correctly.
7a3408
7a3408
(cherry picked from commit 2a6801892ac962d8176f764edde219ae00cb7f3a)
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 | 8 +++++++-
7a3408
 1 file changed, 7 insertions(+), 1 deletion(-)
7a3408
7a3408
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
7a3408
index c874fa6..105d7ab 100644
7a3408
--- a/src/nodeinfo.c
7a3408
+++ b/src/nodeinfo.c
7a3408
@@ -1300,6 +1300,7 @@ nodeGetCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED,
7a3408
 #ifdef __linux__
7a3408
     const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
7a3408
     char *online_path = NULL;
7a3408
+    char *cpudir = NULL;
7a3408
     virBitmapPtr cpumap;
7a3408
     int present;
7a3408
 
7a3408
@@ -1317,8 +1318,12 @@ nodeGetCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED,
7a3408
         cpumap = virBitmapNew(present);
7a3408
         if (!cpumap)
7a3408
             goto cleanup;
7a3408
+
7a3408
+        if (virAsprintf(&cpudir, "%s/cpu", prefix) < 0)
7a3408
+            goto cleanup;
7a3408
+
7a3408
         for (i = 0; i < present; i++) {
7a3408
-            int online = virNodeGetCpuValue(prefix, i, "online", 1);
7a3408
+            int online = virNodeGetCpuValue(cpudir, i, "online", 1);
7a3408
             if (online < 0) {
7a3408
                 virBitmapFree(cpumap);
7a3408
                 cpumap = NULL;
7a3408
@@ -1332,6 +1337,7 @@ nodeGetCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED,
7a3408
         *max_id = present;
7a3408
  cleanup:
7a3408
     VIR_FREE(online_path);
7a3408
+    VIR_FREE(cpudir);
7a3408
     return cpumap;
7a3408
 #else
7a3408
     virReportError(VIR_ERR_NO_SUPPORT, "%s",
7a3408
-- 
7a3408
2.5.0
7a3408