Skip to contentSkip to conversation

Support more than 32 vcpus for xl vcpu-set

PATCH Applied Juergen Gross 2 participants 2 messages Feb 14, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support more than 32 vcpus for xl vcpu-set

xl vcpu-set currently uses a 32 bit mask for specifying which cpus are to be set online. This restricts the number of cpus supported by this command.

The patch switches to libxl_cpumap, the interface of libxl_set_vcpuonline() is changed accordingly.

Signed-off-by [email protected]
3 files changed, 14 insertions(+), 8 deletions(-)
tools/libxl/libxl.c      |    4 ++--
tools/libxl/libxl.h      |    2 +-
tools/libxl/xl_cmdimpl.c |   16 +++++++++++-----

# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1297677770 -3600
# Node ID f3579aa973c24a4ecee809a184b08c1855cd07ba # Parent 67f2fed570346155d615327f4c1bd1099f155fbd Support more than 32 vcpus for xl vcpu-set

xl vcpu-set currently uses a 32 bit mask for specifying which cpus are to be set online. This restricts the number of cpus supported by this command.

The patch switches to libxl_cpumap, the interface of libxl_set_vcpuonline() is changed accordingly.

Signed-off-by [email protected]
tools/libxl/libxl.c +2 -2
diff -r 67f2fed57034 -r f3579aa973c2 tools/libxl/libxl.c
@@ -2463,7 +2463,7 @@ int libxl_set_vcpuaffinity(libxl_ctx *ct
     return 0;
 }
 
-int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, uint32_t bitmask)
+int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_cpumap *cpumap)
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
     libxl_dominfo info;
@@ -2483,7 +2483,7 @@ retry_transaction:
     for (i = 0; i <= info.vcpu_max_id; i++)
         libxl__xs_write(&gc, t,
                        libxl__sprintf(&gc, "%s/cpu/%u/availability", dompath, i),
-                       "%s", ((1 << i) & bitmask) ? "online" : "offline");
+                       "%s", libxl_cpumap_test(cpumap, i) ? "online" : "offline");
     if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
tools/libxl/libxl.h +1 -1
diff -r 67f2fed57034 -r f3579aa973c2 tools/libxl/libxl.h
@@ -499,7 +499,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
                                        int *nb_vcpu, int *nrcpus);
 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
                            libxl_cpumap *cpumap);
-int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, uint32_t bitmask);
+int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_cpumap *cpumap);
 
 int libxl_get_sched_id(libxl_ctx *ctx);
 
tools/libxl/xl_cmdimpl.c +11 -5
diff -r 67f2fed57034 -r f3579aa973c2 tools/libxl/xl_cmdimpl.c
@@ -3607,7 +3607,7 @@ static void vcpuset(const char *d, const
 {
     char *endptr;
     unsigned int max_vcpus, i;
-    uint32_t bitmask = 0;
+    libxl_cpumap cpumap;
 
     max_vcpus = strtoul(nr_vcpus, &endptr, 10);
     if (nr_vcpus == endptr) {
@@ -3617,11 +3617,17 @@ static void vcpuset(const char *d, const
 
     find_domain(d);
 
+    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+        fprintf(stderr, "libxl_cpumap_alloc failed\n");
+        return;
+    }
     for (i = 0; i < max_vcpus; i++)
-        bitmask |= 1 << i;
-
-    if (libxl_set_vcpuonline(&ctx, domid, bitmask) < 0)
-        fprintf(stderr, "libxl_set_vcpuonline failed domid=%d bitmask=%x\n", domid, bitmask);
+        libxl_cpumap_set(&cpumap, i);
+
+    if (libxl_set_vcpuonline(&ctx, domid, &cpumap) < 0)
+        fprintf(stderr, "libxl_set_vcpuonline failed domid=%d max_vcpus=%d\n", domid, max_vcpus);
+
+    libxl_cpumap_destroy(&cpumap);
 }
 
 int main_vcpuset(int argc, char **argv)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Applied
#1 lore raw

Juergen Gross writes ("[Xen-devel] [PATCH] Support more than 32 vcpus for xl vcpu-set"):

Quoted 5 lines

xl vcpu-set currently uses a 32 bit mask for specifying which cpus are to be set online. This restricts the number of cpus supported by this command.

The patch switches to libxl_cpumap, the interface of libxl_set_vcpuonline() is changed accordingly.

Applied, thanks.

Ian.