render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
7a3408
From ffadd3f17a8d1f970bcfe31cebd08a11da9fb5ef Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <ffadd3f17a8d1f970bcfe31cebd08a11da9fb5ef@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:09 +0200
7a3408
Subject: [PATCH] nodeinfo: Add sysfs_prefix to nodeGetPresentCPUBitmap
7a3408
7a3408
Add the sysfs_prefix argument to the call to allow for setting the
7a3408
path for tests to something other than SYSFS_SYSTEM_PATH.
7a3408
7a3408
(cherry picked from commit 51281dcb9032610983c19dd98295a0aa8e5c40d6)
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       | 7 ++++---
7a3408
 src/nodeinfo.h       | 2 +-
7a3408
 src/util/vircgroup.c | 2 +-
7a3408
 3 files changed, 6 insertions(+), 5 deletions(-)
7a3408
7a3408
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
7a3408
index 409f922..34de720 100644
7a3408
--- a/src/nodeinfo.c
7a3408
+++ b/src/nodeinfo.c
7a3408
@@ -1249,19 +1249,20 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
7a3408
 }
7a3408
 
7a3408
 virBitmapPtr
7a3408
-nodeGetPresentCPUBitmap(void)
7a3408
+nodeGetPresentCPUBitmap(const char *sysfs_prefix)
7a3408
 {
7a3408
     int max_present;
7a3408
 #ifdef __linux__
7a3408
     char *present_path = NULL;
7a3408
     virBitmapPtr bitmap = NULL;
7a3408
 #endif
7a3408
+    const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
7a3408
 
7a3408
-    if ((max_present = nodeGetCPUCount(NULL)) < 0)
7a3408
+    if ((max_present = nodeGetCPUCount(prefix)) < 0)
7a3408
         return NULL;
7a3408
 
7a3408
 #ifdef __linux__
7a3408
-    if (!(present_path = linuxGetCPUPresentPath(NULL)))
7a3408
+    if (!(present_path = linuxGetCPUPresentPath(prefix)))
7a3408
         return NULL;
7a3408
     if (virFileExists(present_path))
7a3408
         bitmap = linuxParseCPUmap(max_present, present_path);
7a3408
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
7a3408
index 4f9699e..3ef206b 100644
7a3408
--- a/src/nodeinfo.h
7a3408
+++ b/src/nodeinfo.h
7a3408
@@ -43,7 +43,7 @@ int nodeGetCellsFreeMemory(unsigned long long *freeMems,
7a3408
 int nodeGetMemory(unsigned long long *mem,
7a3408
                   unsigned long long *freeMem);
7a3408
 
7a3408
-virBitmapPtr nodeGetPresentCPUBitmap(void);
7a3408
+virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix);
7a3408
 virBitmapPtr nodeGetCPUBitmap(int *max_id);
7a3408
 int nodeGetCPUCount(const char *sysfs_prefix);
7a3408
 
7a3408
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
7a3408
index 29b2ab9..0599ba5 100644
7a3408
--- a/src/util/vircgroup.c
7a3408
+++ b/src/util/vircgroup.c
7a3408
@@ -3037,7 +3037,7 @@ virCgroupGetPercpuStats(virCgroupPtr group,
7a3408
     }
7a3408
 
7a3408
     /* To parse account file, we need to know how many cpus are present.  */
7a3408
-    if (!(cpumap = nodeGetPresentCPUBitmap()))
7a3408
+    if (!(cpumap = nodeGetPresentCPUBitmap(NULL)))
7a3408
         return rv;
7a3408
 
7a3408
     total_cpus = virBitmapSize(cpumap);
7a3408
-- 
7a3408
2.5.0
7a3408