render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
7a3408
From 7d9e53dfd33baa9a934548aeba04abcf6775d7ca Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <7d9e53dfd33baa9a934548aeba04abcf6775d7ca@dist-git>
7a3408
From: Andrea Bolognani <abologna@redhat.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:29 +0200
7a3408
Subject: [PATCH] nodeinfo: Use nodeGetOnlineCPUBitmap() when parsing node
7a3408
7a3408
No need to look up the online status of each CPU separately when we
7a3408
can get all the information in one go.
7a3408
7a3408
(cherry picked from commit b909e9fb2c095b7c83eab99e1f812bd1ffe6e480)
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 | 16 +++++++---------
7a3408
 1 file changed, 7 insertions(+), 9 deletions(-)
7a3408
7a3408
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
7a3408
index 7d0e6b0..2d910c9 100644
7a3408
--- a/src/nodeinfo.c
7a3408
+++ b/src/nodeinfo.c
7a3408
@@ -409,6 +409,7 @@ virNodeParseNode(const char *sysfs_prefix,
7a3408
     DIR *cpudir = NULL;
7a3408
     struct dirent *cpudirent = NULL;
7a3408
     virBitmapPtr present_cpumap = NULL;
7a3408
+    virBitmapPtr online_cpus_map = NULL;
7a3408
     virBitmapPtr sockets_map = NULL;
7a3408
     virBitmapPtr *cores_maps = NULL;
7a3408
     int sock_max = 0;
7a3408
@@ -417,7 +418,6 @@ virNodeParseNode(const char *sysfs_prefix,
7a3408
     size_t i;
7a3408
     int siblings;
7a3408
     unsigned int cpu;
7a3408
-    int online;
7a3408
     int direrr;
7a3408
 
7a3408
     *threads = 0;
7a3408
@@ -432,6 +432,9 @@ virNodeParseNode(const char *sysfs_prefix,
7a3408
     present_cpumap = nodeGetPresentCPUBitmap(sysfs_prefix);
7a3408
     if (!present_cpumap)
7a3408
         goto cleanup;
7a3408
+    online_cpus_map = nodeGetOnlineCPUBitmap(sysfs_prefix);
7a3408
+    if (!online_cpus_map)
7a3408
+        goto cleanup;
7a3408
 
7a3408
     /* enumerate sockets in the node */
7a3408
     if (!(sockets_map = virBitmapNew(ID_MAX + 1)))
7a3408
@@ -444,10 +447,7 @@ virNodeParseNode(const char *sysfs_prefix,
7a3408
         if (!virBitmapIsBitSet(present_cpumap, cpu))
7a3408
             continue;
7a3408
 
7a3408
-        if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
7a3408
-            goto cleanup;
7a3408
-
7a3408
-        if (!online)
7a3408
+        if (!virBitmapIsBitSet(online_cpus_map, cpu))
7a3408
             continue;
7a3408
 
7a3408
         /* Parse socket */
7a3408
@@ -489,10 +489,7 @@ virNodeParseNode(const char *sysfs_prefix,
7a3408
         if (!virBitmapIsBitSet(present_cpumap, cpu))
7a3408
             continue;
7a3408
 
7a3408
-        if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
7a3408
-            goto cleanup;
7a3408
-
7a3408
-        if (!online) {
7a3408
+        if (!virBitmapIsBitSet(online_cpus_map, cpu)) {
7a3408
             (*offline)++;
7a3408
             continue;
7a3408
         }
7a3408
@@ -560,6 +557,7 @@ virNodeParseNode(const char *sysfs_prefix,
7a3408
             virBitmapFree(cores_maps[i]);
7a3408
     VIR_FREE(cores_maps);
7a3408
     virBitmapFree(sockets_map);
7a3408
+    virBitmapFree(online_cpus_map);
7a3408
     virBitmapFree(present_cpumap);
7a3408
 
7a3408
     return ret;
7a3408
-- 
7a3408
2.5.0
7a3408