render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
7a3408
From 69397bf8901e911a4e288bba84896a18b2604dd1 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <69397bf8901e911a4e288bba84896a18b2604dd1@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:14 +0200
7a3408
Subject: [PATCH] nodeinfo: Add sysfs_prefix to nodeGetMemoryStats
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 c71f0654fc8ed9e69b75b24eac83a3369e4e64b3)
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/bhyve/bhyve_driver.c   | 2 +-
7a3408
 src/lxc/lxc_driver.c       | 2 +-
7a3408
 src/nodeinfo.c             | 6 ++++--
7a3408
 src/nodeinfo.h             | 3 ++-
7a3408
 src/openvz/openvz_driver.c | 2 +-
7a3408
 src/qemu/qemu_driver.c     | 2 +-
7a3408
 src/uml/uml_driver.c       | 2 +-
7a3408
 7 files changed, 11 insertions(+), 8 deletions(-)
7a3408
7a3408
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
7a3408
index ba411a0..85b7c8f 100644
7a3408
--- a/src/bhyve/bhyve_driver.c
7a3408
+++ b/src/bhyve/bhyve_driver.c
7a3408
@@ -1121,7 +1121,7 @@ bhyveNodeGetMemoryStats(virConnectPtr conn,
7a3408
     if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetMemoryStats(cellNum, params, nparams, flags);
7a3408
+    return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
7a3408
 }
7a3408
 
7a3408
 static int
7a3408
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
7a3408
index 1206074..d8d5119 100644
7a3408
--- a/src/lxc/lxc_driver.c
7a3408
+++ b/src/lxc/lxc_driver.c
7a3408
@@ -5484,7 +5484,7 @@ lxcNodeGetMemoryStats(virConnectPtr conn,
7a3408
     if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetMemoryStats(cellNum, params, nparams, flags);
7a3408
+    return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
7a3408
index a71d05e..ca9cb3a 100644
7a3408
--- a/src/nodeinfo.c
7a3408
+++ b/src/nodeinfo.c
7a3408
@@ -1141,7 +1141,8 @@ int nodeGetCPUStats(int cpuNum ATTRIBUTE_UNUSED,
7a3408
 #endif
7a3408
 }
7a3408
 
7a3408
-int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
7a3408
+int nodeGetMemoryStats(const char *sysfs_prefix ATTRIBUTE_UNUSED,
7a3408
+                       int cellNum ATTRIBUTE_UNUSED,
7a3408
                        virNodeMemoryStatsPtr params ATTRIBUTE_UNUSED,
7a3408
                        int *nparams ATTRIBUTE_UNUSED,
7a3408
                        unsigned int flags)
7a3408
@@ -1151,6 +1152,7 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
7a3408
 #ifdef __linux__
7a3408
     {
7a3408
         int ret;
7a3408
+        const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
7a3408
         char *meminfo_path = NULL;
7a3408
         FILE *meminfo;
7a3408
         int max_node;
7a3408
@@ -1170,7 +1172,7 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
7a3408
             }
7a3408
 
7a3408
             if (virAsprintf(&meminfo_path, "%s/node/node%d/meminfo",
7a3408
-                            SYSFS_SYSTEM_PATH, cellNum) < 0)
7a3408
+                            prefix, cellNum) < 0)
7a3408
                 return -1;
7a3408
         }
7a3408
         meminfo = fopen(meminfo_path, "r");
7a3408
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
7a3408
index b28aaab..4f983c2 100644
7a3408
--- a/src/nodeinfo.h
7a3408
+++ b/src/nodeinfo.h
7a3408
@@ -33,7 +33,8 @@ int nodeGetCPUStats(int cpuNum,
7a3408
                     virNodeCPUStatsPtr params,
7a3408
                     int *nparams,
7a3408
                     unsigned int flags);
7a3408
-int nodeGetMemoryStats(int cellNum,
7a3408
+int nodeGetMemoryStats(const char *sysfs_prefix,
7a3408
+                       int cellNum,
7a3408
                        virNodeMemoryStatsPtr params,
7a3408
                        int *nparams,
7a3408
                        unsigned int flags);
7a3408
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
7a3408
index 280b998..fc8db7e 100644
7a3408
--- a/src/openvz/openvz_driver.c
7a3408
+++ b/src/openvz/openvz_driver.c
7a3408
@@ -2177,7 +2177,7 @@ openvzNodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
                          int *nparams,
7a3408
                          unsigned int flags)
7a3408
 {
7a3408
-    return nodeGetMemoryStats(cellNum, params, nparams, flags);
7a3408
+    return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7a3408
index 17593b9..6b715bf 100644
7a3408
--- a/src/qemu/qemu_driver.c
7a3408
+++ b/src/qemu/qemu_driver.c
7a3408
@@ -18519,7 +18519,7 @@ qemuNodeGetMemoryStats(virConnectPtr conn,
7a3408
     if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetMemoryStats(cellNum, params, nparams, flags);
7a3408
+    return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
7a3408
index 8606616..c3c5fa7 100644
7a3408
--- a/src/uml/uml_driver.c
7a3408
+++ b/src/uml/uml_driver.c
7a3408
@@ -2810,7 +2810,7 @@ umlNodeGetMemoryStats(virConnectPtr conn,
7a3408
     if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetMemoryStats(cellNum, params, nparams, flags);
7a3408
+    return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
-- 
7a3408
2.5.0
7a3408