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

Re: [libvirt] [PATCH 2/2] FreeBSD: stub out CPU affinity functions.



On 12/16/12 15:47, Roman Bogorodskiy wrote:
---
  src/util/processinfo.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)

diff --git a/src/util/processinfo.c b/src/util/processinfo.c
index b1db049..4822bcc 100644
--- a/src/util/processinfo.c
+++ b/src/util/processinfo.c
@@ -168,6 +168,28 @@ realloc:
      return 0;
  }

+#elif defined(__FreeBSD__)
+
+int virProcessInfoSetAffinity(pid_t pid ATTRIBUTE_UNUSED,
+                              virBitmapPtr map ATTRIBUTE_UNUSED)
+{
+    return 0;

Hmm, if the platform doesn't support setting of cpu affinity you should report an error here and return failure. Otherwise the user will think that the affinity was set successfully and when he tries to read it (code below) he/she gets incorrect value.

+}
+
+int virProcessInfoGetAffinity(pid_t pid ATTRIBUTE_UNUSED,
+                              virBitmapPtr *map,
+                              int maxcpu)
+{
+    *map = virBitmapNew(maxcpu);
+    if (!map) {
+        virReportOOMError();
+        return -1;
+    }
+    virBitmapSetAll(*map);

Okay, this is fair enough, but you have to fail in the setting call so that this function doesn't lie to the user.

+
+    return 0;
+}
+
  #else /* HAVE_SCHED_GETAFFINITY */

  int virProcessInfoSetAffinity(pid_t pid ATTRIBUTE_UNUSED,


Peter


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