[PATCH 7/8] process a cpu affinity mask

Glauber Costa
2008-03-04T16:22:00Z

This patch provides a function that process a cpu affinity list
in the form x,y,z... into a cpu_set_t variable.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
qemu/vl.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index 6a94724..4715594 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8646,6 +8646,23 @@ void *qemu_alloc_physram(unsigned long memory)

return area;
}
+#ifdef USE_KVM
+#include <sched.h>
+void process_cpu_set(const char *map, cpu_set_t *set)
+{
+ char *ptr = map;
+ int c;
+ CPU_ZERO(set);
+ do {
+ c = atoi(ptr);
+ CPU_SET(c, set);
+ ptr = strchr(ptr, ',');
+ if (!ptr)
+ break;
+ ptr++;
+ } while (*ptr);
+}
+#endif

int main(int argc, char **argv)
{
--
1.5.0.6