]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
nodeinfo: Add sysfs_prefix to nodeGetPresentCPUBitmap
authorJohn Ferlan <jferlan@redhat.com>
Mon, 6 Jul 2015 20:31:36 +0000 (16:31 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 13 Jul 2015 19:59:32 +0000 (15:59 -0400)
Add the sysfs_prefix argument to the call to allow for setting the
path for tests to something other than SYSFS_SYSTEM_PATH.

src/nodeinfo.c
src/nodeinfo.h
src/util/vircgroup.c

index 409f922ba8a51bdc4a6df4ed926212dbf96629dd..34de7203dc83763bbe214b9e65598c4c41cba1fd 100644 (file)
@@ -1249,19 +1249,20 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
 }
 
 virBitmapPtr
-nodeGetPresentCPUBitmap(void)
+nodeGetPresentCPUBitmap(const char *sysfs_prefix)
 {
     int max_present;
 #ifdef __linux__
     char *present_path = NULL;
     virBitmapPtr bitmap = NULL;
 #endif
+    const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
 
-    if ((max_present = nodeGetCPUCount(NULL)) < 0)
+    if ((max_present = nodeGetCPUCount(prefix)) < 0)
         return NULL;
 
 #ifdef __linux__
-    if (!(present_path = linuxGetCPUPresentPath(NULL)))
+    if (!(present_path = linuxGetCPUPresentPath(prefix)))
         return NULL;
     if (virFileExists(present_path))
         bitmap = linuxParseCPUmap(max_present, present_path);
index 4f9699ea7a49de429e581996d8b34b23ad66cd8d..3ef206b173efd180e036b5e1ce5cf0c71b2f8846 100644 (file)
@@ -43,7 +43,7 @@ int nodeGetCellsFreeMemory(unsigned long long *freeMems,
 int nodeGetMemory(unsigned long long *mem,
                   unsigned long long *freeMem);
 
-virBitmapPtr nodeGetPresentCPUBitmap(void);
+virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix);
 virBitmapPtr nodeGetCPUBitmap(int *max_id);
 int nodeGetCPUCount(const char *sysfs_prefix);
 
index cbe0234b4e4e5149de8f5110e077720bc1e6fb63..0ef2d29626fa40d0862ad6f3f73bef8490ff259e 100644 (file)
@@ -3043,7 +3043,7 @@ virCgroupGetPercpuStats(virCgroupPtr group,
     }
 
     /* To parse account file, we need to know how many cpus are present.  */
-    if (!(cpumap = nodeGetPresentCPUBitmap()))
+    if (!(cpumap = nodeGetPresentCPUBitmap(NULL)))
         return rv;
 
     total_cpus = virBitmapSize(cpumap);