tools/libxc: Introduce XC_CPUPOOL_POOLID_ANY
authorGeorge Dunlap <george.dunlap@citrix.com>
Wed, 15 Feb 2017 17:08:10 +0000 (17:08 +0000)
committerWei Liu <wei.liu2@citrix.com>
Thu, 16 Feb 2017 12:47:10 +0000 (12:47 +0000)
Callers to xc_cpupool_create() can either request a specific pool id,
or request that Xen do it for them.  But at the moment, the
"automatic" selection is indicated by using a magic value, 0.  This is
undesirable both because it doesn't obviously have meaning, but also
because '0' is a valid cpupool (albeit one which at the moment can't
be changed).

Introduce a constant, XC_CPUPOOL_POOLID_ANY, to indicate this instead.
Have it be the default for the python bindings.

Manually translate it, even though it's the same underlying value,
because we don't yet have a relaible way of enforcing that these
values are the same.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxc/include/xenctrl.h
tools/libxc/xc_cpupool.c
tools/libxl/libxl_cpupool.c
tools/python/xen/lowlevel/xc/xc.c

index 85d7fe5d198a48cd5f7a1be5c9fdaa565971122f..927e373d710c9ebcebdb35564bc70d081977cd2b 100644 (file)
@@ -1052,6 +1052,8 @@ typedef struct xc_cpupoolinfo {
     xc_cpumap_t cpumap;
 } xc_cpupoolinfo_t;
 
+#define XC_CPUPOOL_POOLID_ANY 0xFFFFFFFF
+
 /**
  * Create a new cpupool.
  *
index 70011d1f345f617679f56b5942e32db6402f179d..fbd8cc9d037c7761e78e5d7111e6eead027f8b3a 100644 (file)
@@ -43,7 +43,7 @@ int xc_cpupool_create(xc_interface *xch,
 
     sysctl.cmd = XEN_SYSCTL_cpupool_op;
     sysctl.u.cpupool_op.op = XEN_SYSCTL_CPUPOOL_OP_CREATE;
-    sysctl.u.cpupool_op.cpupool_id = (*ppoolid == 0) ?
+    sysctl.u.cpupool_op.cpupool_id = (*ppoolid == XC_CPUPOOL_POOLID_ANY) ?
         XEN_SYSCTL_CPUPOOL_PAR_ANY : *ppoolid;
     sysctl.u.cpupool_op.sched_id = sched_id;
     if ( (err = do_sysctl_save(xch, &sysctl)) != 0 )
index f3d22b10d09bc4130a15fb9c9640f309018cd1a6..0ff8724076bdbf5d789410165accb88ce4a60c7c 100644 (file)
@@ -137,6 +137,10 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
     int i;
     xs_transaction_t t;
     char *uuid_string;
+    uint32_t xcpoolid;
+
+    /* Zero means "choose a poolid for me" */
+    xcpoolid = (*poolid) ? (*poolid) : XC_CPUPOOL_POOLID_ANY;
 
     uuid_string = libxl__uuid2string(gc, *uuid);
     if (!uuid_string) {
@@ -144,12 +148,13 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
         return ERROR_NOMEM;
     }
 
-    rc = xc_cpupool_create(ctx->xch, poolid, sched);
+    rc = xc_cpupool_create(ctx->xch, &xcpoolid, sched);
     if (rc) {
         LOGEV(ERROR, rc, "Could not create cpupool");
         GC_FREE;
         return ERROR_FAIL;
     }
+    *poolid = xcpoolid;
 
     libxl_for_each_bit(i, cpumap)
         if (libxl_bitmap_test(&cpumap, i)) {
index 39be1d5c0b2b3cd5587780af0fab757d8fffd30c..9e93d496f447394a706e98a3b28aec351ec053ad 100644 (file)
@@ -1715,7 +1715,7 @@ static PyObject *pyxc_cpupool_create(XcObject *self,
                                      PyObject *args,
                                      PyObject *kwds)
 {
-    uint32_t cpupool = 0, sched = XEN_SCHEDULER_CREDIT;
+    uint32_t cpupool = XC_CPUPOOL_POOLID_ANY, sched = XEN_SCHEDULER_CREDIT;
 
     static char *kwd_list[] = { "pool", "sched", NULL };