render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
7a3408
From 397e67c0f6ee09387ac871c7f3ac1fa9ba697287 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <397e67c0f6ee09387ac871c7f3ac1fa9ba697287@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:11 +0200
7a3408
Subject: [PATCH] nodeinfo: Add sysfs_prefix to nodeGetCPUMap
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 f1c6179f0d44a04abb2f7c2e58f2ef3dad2892b8)
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             | 8 +++++---
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
 src/vz/vz_driver.c         | 2 +-
7a3408
 8 files changed, 13 insertions(+), 10 deletions(-)
7a3408
7a3408
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
7a3408
index dc76cf7..68dff6c 100644
7a3408
--- a/src/bhyve/bhyve_driver.c
7a3408
+++ b/src/bhyve/bhyve_driver.c
7a3408
@@ -1299,7 +1299,7 @@ bhyveNodeGetCPUMap(virConnectPtr conn,
7a3408
     if (virNodeGetCPUMapEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetCPUMap(cpumap, online, flags);
7a3408
+    return nodeGetCPUMap(NULL, cpumap, online, flags);
7a3408
 }
7a3408
 
7a3408
 static int
7a3408
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
7a3408
index 5ecfc7a..44a138b 100644
7a3408
--- a/src/lxc/lxc_driver.c
7a3408
+++ b/src/lxc/lxc_driver.c
7a3408
@@ -5551,7 +5551,7 @@ lxcNodeGetCPUMap(virConnectPtr conn,
7a3408
     if (virNodeGetCPUMapEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetCPUMap(cpumap, online, flags);
7a3408
+    return nodeGetCPUMap(NULL, cpumap, online, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
7a3408
index 75e0a02..bf4f751 100644
7a3408
--- a/src/nodeinfo.c
7a3408
+++ b/src/nodeinfo.c
7a3408
@@ -1624,10 +1624,12 @@ nodeGetMemoryParameters(virTypedParameterPtr params ATTRIBUTE_UNUSED,
7a3408
 }
7a3408
 
7a3408
 int
7a3408
-nodeGetCPUMap(unsigned char **cpumap,
7a3408
+nodeGetCPUMap(const char *sysfs_prefix,
7a3408
+              unsigned char **cpumap,
7a3408
               unsigned int *online,
7a3408
               unsigned int flags)
7a3408
 {
7a3408
+    const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
7a3408
     virBitmapPtr cpus = NULL;
7a3408
     int maxpresent;
7a3408
     int ret = -1;
7a3408
@@ -1636,9 +1638,9 @@ nodeGetCPUMap(unsigned char **cpumap,
7a3408
     virCheckFlags(0, -1);
7a3408
 
7a3408
     if (!cpumap && !online)
7a3408
-        return nodeGetCPUCount(NULL);
7a3408
+        return nodeGetCPUCount(prefix);
7a3408
 
7a3408
-    if (!(cpus = nodeGetCPUBitmap(NULL, &maxpresent)))
7a3408
+    if (!(cpus = nodeGetCPUBitmap(prefix, &maxpresent)))
7a3408
         goto cleanup;
7a3408
 
7a3408
     if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0)
7a3408
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
7a3408
index 439ef35..9e6904f 100644
7a3408
--- a/src/nodeinfo.h
7a3408
+++ b/src/nodeinfo.h
7a3408
@@ -55,7 +55,8 @@ int nodeSetMemoryParameters(virTypedParameterPtr params,
7a3408
                             int nparams,
7a3408
                             unsigned int flags);
7a3408
 
7a3408
-int nodeGetCPUMap(unsigned char **cpumap,
7a3408
+int nodeGetCPUMap(const char *sysfs_prefix,
7a3408
+                  unsigned char **cpumap,
7a3408
                   unsigned int *online,
7a3408
                   unsigned int flags);
7a3408
 
7a3408
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
7a3408
index d1a327c..fc6f101 100644
7a3408
--- a/src/openvz/openvz_driver.c
7a3408
+++ b/src/openvz/openvz_driver.c
7a3408
@@ -2207,7 +2207,7 @@ openvzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
                     unsigned int *online,
7a3408
                     unsigned int flags)
7a3408
 {
7a3408
-    return nodeGetCPUMap(cpumap, online, flags);
7a3408
+    return nodeGetCPUMap(NULL, cpumap, online, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7a3408
index e30a02d..6036363 100644
7a3408
--- a/src/qemu/qemu_driver.c
7a3408
+++ b/src/qemu/qemu_driver.c
7a3408
@@ -18586,7 +18586,7 @@ qemuNodeGetCPUMap(virConnectPtr conn,
7a3408
     if (virNodeGetCPUMapEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetCPUMap(cpumap, online, flags);
7a3408
+    return nodeGetCPUMap(NULL, cpumap, online, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
7a3408
index 7a95458..99162f7 100644
7a3408
--- a/src/uml/uml_driver.c
7a3408
+++ b/src/uml/uml_driver.c
7a3408
@@ -2877,7 +2877,7 @@ umlNodeGetCPUMap(virConnectPtr conn,
7a3408
     if (virNodeGetCPUMapEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetCPUMap(cpumap, online, flags);
7a3408
+    return nodeGetCPUMap(NULL, cpumap, online, flags);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
7a3408
index 47c5023..a98d65b 100644
7a3408
--- a/src/vz/vz_driver.c
7a3408
+++ b/src/vz/vz_driver.c
7a3408
@@ -884,7 +884,7 @@ vzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
                 unsigned int *online,
7a3408
                 unsigned int flags)
7a3408
 {
7a3408
-    return nodeGetCPUMap(cpumap, online, flags);
7a3408
+    return nodeGetCPUMap(NULL, cpumap, online, flags);
7a3408
 }
7a3408
 
7a3408
 static int
7a3408
-- 
7a3408
2.5.0
7a3408