[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 6/4] nodeinfo: port nodecpumap to RHEL5



On 11/15/2012 04:38 PM, Eric Blake wrote:
-    cpumap = linuxParseCPUmap(present, SYSFS_SYSTEM_PATH "/cpu/online");
+
+    if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/online")) {
+        cpumap = linuxParseCPUmap(present, SYSFS_SYSTEM_PATH "/cpu/online");
+    } else {
+        int i;
+
+        cpumap = virBitmapNew(present);
+        if (!cpumap) {
+            virReportOOMError();
+            return NULL;
+        }
+        for (i = 0; i < present; i++) {
+            int online = virNodeGetCpuValue(SYSFS_SYSTEM_PATH, i, "online", 1);
+            if (online < 0) {
+                virBitmapFree(cpumap);
+                return NULL;
+            }
+            if (online)
+                ignore_value(virBitmapSetBit(cpumap, i));
+        }
+    }
      if (max_id && cpumap)
          *max_id = present;
      return cpumap;


Fallback should provide correct result on back-level kernels. The code
doesn't use the goto error/cleanup pattern, but there's a mixture in
nodeinfo.c anyway and it wouldn't make it anymore compact. As far as
I am concerned: +1.

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]