render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
7a3408
From 242c0464ea05a4c8e3ca02e79251e40de28b14eb Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <242c0464ea05a4c8e3ca02e79251e40de28b14eb@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:12 +0200
7a3408
Subject: [PATCH] nodeinfo: Add sysfs_prefix to nodeGetInfo
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 29e4f2243fb59a3b1fcbd69ee329e38f09960266)
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_capabilities.c | 2 +-
7a3408
 src/bhyve/bhyve_driver.c       | 2 +-
7a3408
 src/lxc/lxc_driver.c           | 2 +-
7a3408
 src/nodeinfo.c                 | 9 ++++++---
7a3408
 src/nodeinfo.h                 | 2 +-
7a3408
 src/openvz/openvz_conf.c       | 2 +-
7a3408
 src/openvz/openvz_driver.c     | 2 +-
7a3408
 src/qemu/qemu_capabilities.c   | 2 +-
7a3408
 src/qemu/qemu_driver.c         | 2 +-
7a3408
 src/uml/uml_driver.c           | 2 +-
7a3408
 src/vbox/vbox_common.c         | 2 +-
7a3408
 src/vz/vz_driver.c             | 4 ++--
7a3408
 12 files changed, 18 insertions(+), 15 deletions(-)
7a3408
7a3408
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
7a3408
index e6d5518..3a55879 100644
7a3408
--- a/src/bhyve/bhyve_capabilities.c
7a3408
+++ b/src/bhyve/bhyve_capabilities.c
7a3408
@@ -51,7 +51,7 @@ virBhyveCapsInitCPU(virCapsPtr caps,
7a3408
 
7a3408
     cpu->arch = arch;
7a3408
 
7a3408
-    if (nodeGetInfo(&nodeinfo))
7a3408
+    if (nodeGetInfo(NULL, &nodeinfo))
7a3408
         goto error;
7a3408
 
7a3408
     cpu->type = VIR_CPU_TYPE_HOST;
7a3408
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
7a3408
index 68dff6c..ba411a0 100644
7a3408
--- a/src/bhyve/bhyve_driver.c
7a3408
+++ b/src/bhyve/bhyve_driver.c
7a3408
@@ -1131,7 +1131,7 @@ bhyveNodeGetInfo(virConnectPtr conn,
7a3408
     if (virNodeGetInfoEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetInfo(nodeinfo);
7a3408
+    return nodeGetInfo(NULL, nodeinfo);
7a3408
 }
7a3408
 
7a3408
 static int
7a3408
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
7a3408
index 44a138b..1206074 100644
7a3408
--- a/src/lxc/lxc_driver.c
7a3408
+++ b/src/lxc/lxc_driver.c
7a3408
@@ -5398,7 +5398,7 @@ lxcNodeGetInfo(virConnectPtr conn,
7a3408
     if (virNodeGetInfoEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetInfo(nodeinfo);
7a3408
+    return nodeGetInfo(NULL, nodeinfo);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
7a3408
index bf4f751..2d715fd 100644
7a3408
--- a/src/nodeinfo.c
7a3408
+++ b/src/nodeinfo.c
7a3408
@@ -1034,7 +1034,8 @@ virNodeGetSiblingsList(const char *dir, int cpu_id)
7a3408
 }
7a3408
 #endif
7a3408
 
7a3408
-int nodeGetInfo(virNodeInfoPtr nodeinfo)
7a3408
+int nodeGetInfo(const char *sysfs_prefix ATTRIBUTE_UNUSED,
7a3408
+                virNodeInfoPtr nodeinfo)
7a3408
 {
7a3408
     virArch hostarch = virArchFromHost();
7a3408
 
7a3408
@@ -1046,14 +1047,16 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo)
7a3408
 #ifdef __linux__
7a3408
     {
7a3408
     int ret = -1;
7a3408
+    const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
7a3408
     FILE *cpuinfo = fopen(CPUINFO_PATH, "r");
7a3408
+
7a3408
     if (!cpuinfo) {
7a3408
         virReportSystemError(errno,
7a3408
                              _("cannot open %s"), CPUINFO_PATH);
7a3408
         return -1;
7a3408
     }
7a3408
 
7a3408
-    ret = linuxNodeInfoCPUPopulate(cpuinfo, SYSFS_SYSTEM_PATH,
7a3408
+    ret = linuxNodeInfoCPUPopulate(cpuinfo, prefix,
7a3408
                                    hostarch, nodeinfo);
7a3408
     if (ret < 0)
7a3408
         goto cleanup;
7a3408
@@ -1666,7 +1669,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
7a3408
     int id, cid;
7a3408
     int onlinecpus ATTRIBUTE_UNUSED;
7a3408
 
7a3408
-    if (nodeGetInfo(&nodeinfo) < 0)
7a3408
+    if (nodeGetInfo(NULL, &nodeinfo) < 0)
7a3408
         return -1;
7a3408
 
7a3408
     ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
7a3408
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
7a3408
index 9e6904f..ec53769 100644
7a3408
--- a/src/nodeinfo.h
7a3408
+++ b/src/nodeinfo.h
7a3408
@@ -26,7 +26,7 @@
7a3408
 
7a3408
 # include "capabilities.h"
7a3408
 
7a3408
-int nodeGetInfo(virNodeInfoPtr nodeinfo);
7a3408
+int nodeGetInfo(const char *sysfs_prefix, virNodeInfoPtr nodeinfo);
7a3408
 int nodeCapsInitNUMA(virCapsPtr caps);
7a3408
 
7a3408
 int nodeGetCPUStats(int cpuNum,
7a3408
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
7a3408
index 49d78c6..a4c5c31 100644
7a3408
--- a/src/openvz/openvz_conf.c
7a3408
+++ b/src/openvz/openvz_conf.c
7a3408
@@ -637,7 +637,7 @@ openvzGetNodeCPUs(void)
7a3408
 {
7a3408
     virNodeInfo nodeinfo;
7a3408
 
7a3408
-    if (nodeGetInfo(&nodeinfo) < 0)
7a3408
+    if (nodeGetInfo(NULL, &nodeinfo) < 0)
7a3408
         return 0;
7a3408
 
7a3408
     return nodeinfo.cpus;
7a3408
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
7a3408
index fc6f101..280b998 100644
7a3408
--- a/src/openvz/openvz_driver.c
7a3408
+++ b/src/openvz/openvz_driver.c
7a3408
@@ -2155,7 +2155,7 @@ static int
7a3408
 openvzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
                   virNodeInfoPtr nodeinfo)
7a3408
 {
7a3408
-    return nodeGetInfo(nodeinfo);
7a3408
+    return nodeGetInfo(NULL, nodeinfo);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
7a3408
index b4a6961..39954bc 100644
7a3408
--- a/src/qemu/qemu_capabilities.c
7a3408
+++ b/src/qemu/qemu_capabilities.c
7a3408
@@ -961,7 +961,7 @@ virQEMUCapsInitCPU(virCapsPtr caps,
7a3408
 
7a3408
     cpu->arch = arch;
7a3408
 
7a3408
-    if (nodeGetInfo(&nodeinfo))
7a3408
+    if (nodeGetInfo(NULL, &nodeinfo))
7a3408
         goto error;
7a3408
 
7a3408
     cpu->type = VIR_CPU_TYPE_HOST;
7a3408
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7a3408
index 6036363..17593b9 100644
7a3408
--- a/src/qemu/qemu_driver.c
7a3408
+++ b/src/qemu/qemu_driver.c
7a3408
@@ -18491,7 +18491,7 @@ qemuNodeGetInfo(virConnectPtr conn,
7a3408
     if (virNodeGetInfoEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetInfo(nodeinfo);
7a3408
+    return nodeGetInfo(NULL, nodeinfo);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
7a3408
index 99162f7..8606616 100644
7a3408
--- a/src/uml/uml_driver.c
7a3408
+++ b/src/uml/uml_driver.c
7a3408
@@ -2782,7 +2782,7 @@ umlNodeGetInfo(virConnectPtr conn,
7a3408
     if (virNodeGetInfoEnsureACL(conn) < 0)
7a3408
         return -1;
7a3408
 
7a3408
-    return nodeGetInfo(nodeinfo);
7a3408
+    return nodeGetInfo(NULL, nodeinfo);
7a3408
 }
7a3408
 
7a3408
 
7a3408
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
7a3408
index 813a171..5615df5 100644
7a3408
--- a/src/vbox/vbox_common.c
7a3408
+++ b/src/vbox/vbox_common.c
7a3408
@@ -7537,7 +7537,7 @@ static int
7a3408
 vboxNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
                 virNodeInfoPtr nodeinfo)
7a3408
 {
7a3408
-    return nodeGetInfo(nodeinfo);
7a3408
+    return nodeGetInfo(NULL, nodeinfo);
7a3408
 }
7a3408
 
7a3408
 static int
7a3408
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
7a3408
index a98d65b..61d0d62 100644
7a3408
--- a/src/vz/vz_driver.c
7a3408
+++ b/src/vz/vz_driver.c
7a3408
@@ -148,7 +148,7 @@ vzBuildCapabilities(void)
7a3408
                                       NULL, NULL, 0, NULL) == NULL)
7a3408
         goto error;
7a3408
 
7a3408
-    if (nodeGetInfo(&nodeinfo))
7a3408
+    if (nodeGetInfo(NULL, &nodeinfo))
7a3408
         goto error;
7a3408
 
7a3408
     if (VIR_ALLOC(cpu) < 0)
7a3408
@@ -781,7 +781,7 @@ static int
7a3408
 vzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
               virNodeInfoPtr nodeinfo)
7a3408
 {
7a3408
-    return nodeGetInfo(nodeinfo);
7a3408
+    return nodeGetInfo(NULL, nodeinfo);
7a3408
 }
7a3408
 
7a3408
 static int vzConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
7a3408
-- 
7a3408
2.5.0
7a3408