Skip to contentSkip to conversation

tools/libxc: Introduce XC_CPUPOOL_POOLID_ANY

PATCH In review George Dunlap 2 participants 3 messages Feb 15, 2017 – Feb 16, 2017 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tools/libxc: Introduce XC_CPUPOOL_POOLID_ANY

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.

---
v2: Rebase over libxl.c-split series

CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Juergen Gross <[email protected]>
CC Dario Faggioli <[email protected]>
CC Ronald Rojas <[email protected]>
---
 tools/libxc/include/xenctrl.h     | 2 ++
 tools/libxc/xc_cpupool.c          | 2 +-
 tools/libxl/libxl_cpupool.c       | 7 ++++++-
 tools/python/xen/lowlevel/xc/xc.c | 2 +-
 4 files changed, 10 insertions(+), 3 deletions(-)
tools/libxc/include/xenctrl.h +2 -0
index 85d7fe5..927e373 100644
@@ -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.
  *
tools/libxc/xc_cpupool.c +1 -1
index 70011d1..fbd8cc9 100644
@@ -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 )
tools/libxl/libxl_cpupool.c +6 -1
index f3d22b1..0ff8724 100644
@@ -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)) {
tools/python/xen/lowlevel/xc/xc.c +1 -1
index 39be1d5..9e93d49 100644
@@ -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 };
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH 2/2 tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Callers to libxl_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, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead. Still accept '0' as meaning "ANY" for backwards compatibility.

---
v2: Rebase over libxl.c-split series

CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Juergen Gross <[email protected]>
CC Dario Faggioli <[email protected]>
CC Ronald Rojas <[email protected]>
---
 tools/libxl/libxl.h         | 6 ++++++
 tools/libxl/libxl_cpupool.c | 8 ++++++--
 tools/libxl/xl_cmdimpl.c    | 2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +6 -0
index 3924464..d5559c0 100644
@@ -2086,6 +2086,12 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx, uint32_t domid, char* uuid,
 int libxl_tmem_freeable(libxl_ctx *ctx);
 
 int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap);
+
+/* 
+ * Set poolid to LIBXL_CPUOOL_POOLID_ANY to have Xen choose a
+ * free poolid for you.
+ */
+#define LIBXL_CPUPOOL_POOLID_ANY 0xFFFFFFFF
 int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
                          libxl_scheduler sched,
                          libxl_bitmap cpumap, libxl_uuid *uuid,
tools/libxl/libxl_cpupool.c +6 -2
index 0ff8724..ef9ff84 100644
@@ -139,8 +139,12 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
     char *uuid_string;
     uint32_t xcpoolid;
 
-    /* Zero means "choose a poolid for me" */
-    xcpoolid = (*poolid) ? (*poolid) : XC_CPUPOOL_POOLID_ANY;
+    /* Accept '0' as 'any poolid' for backwards compatibility */
+    if ( *poolid == LIBXL_CPUPOOL_POOLID_ANY
+         || *poolid == 0 ) 
+        xcpoolid = XC_CPUPOOL_POOLID_ANY;
+    else
+        xcpoolid = *poolid;
 
     uuid_string = libxl__uuid2string(gc, *uuid);
     if (!uuid_string) {
tools/libxl/xl_cmdimpl.c +1 -1
index 37ebdce..0add5dc 100644
@@ -8368,7 +8368,7 @@ int main_cpupoolcreate(int argc, char **argv)
     printf("number of cpus: %d\n", n_cpus);
 
     if (!dryrun_only) {
-        poolid = 0;
+        poolid = LIBXL_CPUPOOL_POOLID_ANY;
         if (libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid)) {
             fprintf(stderr, "error on creating cpupool\n");
             goto out_cfg;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel