Skip to contentSkip to conversation

tools/libxc: Introduce XC_CPUPOOL_POOLID_ANY

PATCH In review George Dunlap 3 participants 13 messages Feb 8, 2017 – Feb 14, 2017 Arm/actions semi architecture

lore
Share & tools
lore
#1 lore raw

PATCH 2/2 tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

In reply to George Dunlap

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.

---
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.c      | 8 ++++++--
 tools/libxl/libxl.h      | 6 ++++++
 tools/libxl/xl_cmdimpl.c | 2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)
tools/libxl/libxl.c +6 -2
index 51325d9..32e537a 100644
@@ -6287,8 +6287,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/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/xl_cmdimpl.c +1 -1
index 358757f..80ddeac 100644
@@ -8366,7 +8366,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
#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.

---

I realize this is somewhat of a bike shed, but I want to avoid propagating this "magic number" interface into the xenlight bindings if I can.

Also, at some point we might use the IDL to enforce that the libxl values are identical to the Xen values, at which point we can just pass the value in directly.

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.c               | 9 +++++++--
 tools/python/xen/lowlevel/xc/xc.c | 2 +-
 4 files changed, 11 insertions(+), 4 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.c +7 -2
index d400fa2..51325d9 100644
@@ -6285,19 +6285,24 @@ 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) {
         GC_FREE;
         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
Reviewed-by on v1 1/2
#10 lore raw
Quoted 12 lines · George Dunlap

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.

Quoted 6 lines

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.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

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

Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

In reply to George Dunlap
Quoted 8 lines · George Dunlap

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).

Quoted 6 lines

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead.  Still accept '0' as meaning "ANY" for backwards compatibility.

With one remark.

Quoted 9 lines
tools/libxl/libxl.h +0 -0
@@ -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);

tools/libxl/libxl.h int libxl_tmem_shared_auth(libxl_ctx *ctx, uint32_t domid, char* uuid, · line 2094

Quoted 6 lines
tools/libxl/libxl.h +6 -0
+
+/* 
+ * Set poolid to LIBXL_CPUOOL_POOLID_ANY to have Xen choose a
+ * free poolid for you.
+ */
+#define LIBXL_CPUPOOL_POOLID_ANY 0xFFFFFFFF

Do we want this to be here, or in libxl_types.idl.

Asking because, AFAICT, it's the only one LIBXL_FOO_BAR defined like this. I appreciate that there's few point in making this an enum, as it is only one value, and will most likely remain so, but still, I thought I'd at least bring this up.

FWIW, my Reviewed-by stands both if it is kept as is, and if it is moved to IDL.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

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

#3 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Quoted 36 lines · Dario Faggioli
Quoted 8 lines · George Dunlap

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).

Quoted 6 lines

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead. Still accept '0' as meaning "ANY" for backwards compatibility.

With one remark.

Quoted 5 lines
tools/libxl/libxl.h +0 -0
@@ -2086,6 +2086,12 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx,
 uint32_t domid, char* uuid,

tools/libxl/libxl.h int libxl_tmem_shared_auth(libxl_ctx *ctx, · line 2096

Quoted 10 lines
tools/libxl/libxl.h +6 -0
 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
 

Do we want this to be here, or in libxl_types.idl.

Quoted 7 lines

Asking because, AFAICT, it's the only one LIBXL_FOO_BAR defined like this. I appreciate that there's few point in making this an enum, as it is only one value, and will most likely remain so, but still, I thought I'd at least bring this up.

FWIW, my Reviewed-by stands both if it is kept as is, and if it is moved to IDL.

Well there's things like:

#define LIBXL_PCI_FUNC_ALL (~0U)

#define LIBXL_TIMER_MODE_DEFAULT -1
#define LIBXL_MEMKB_DEFAULT ~0ULL

#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)

#define LIBXL_MS_VM_GENID_LEN 16

#define LIBXL_SUSPEND_DEBUG 1
#define LIBXL_SUSPEND_LIVE 2

Many of which seem similar in some ways. Enums I think are meant to be exhaustive (as in, contain all possible options), not be special cases.

But I'm happy to defer to the tools maintainers.

-George

Quoted 4 lines

Regards,
Dario

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

#4 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Quoted 56 lines · George Dunlap
Quoted 36 lines · Dario Faggioli
Quoted 8 lines · George Dunlap

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).

Quoted 6 lines

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead. Still accept '0' as meaning "ANY" for backwards compatibility.

With one remark.

Quoted 5 lines
tools/libxl/libxl.h +0 -0
@@ -2086,6 +2086,12 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx,
 uint32_t domid, char* uuid,

tools/libxl/libxl.h int libxl_tmem_shared_auth(libxl_ctx *ctx, · line 2096

Quoted 10 lines
tools/libxl/libxl.h +6 -0
 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
 

Do we want this to be here, or in libxl_types.idl.

Quoted 7 lines

Asking because, AFAICT, it's the only one LIBXL_FOO_BAR defined like this. I appreciate that there's few point in making this an enum, as it is only one value, and will most likely remain so, but still, I thought I'd at least bring this up.

FWIW, my Reviewed-by stands both if it is kept as is, and if it is moved to IDL.

Well there's things like:

#define LIBXL_PCI_FUNC_ALL (~0U)

#define LIBXL_TIMER_MODE_DEFAULT -1
#define LIBXL_MEMKB_DEFAULT ~0ULL

#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)

#define LIBXL_MS_VM_GENID_LEN 16

Quoted 8 lines

#define LIBXL_SUSPEND_DEBUG 1
#define LIBXL_SUSPEND_LIVE 2

Many of which seem similar in some ways. Enums I think are meant to be exhaustive (as in, contain all possible options), not be special cases.

But I'm happy to defer to the tools maintainers.

I don't really care if it is an enum or a macro.

There is an issue that is more subtle than where it lives or what form it is in.

You need to modify all the poolid fields in various structure to make it as default. Otherwise the whole json infrastructure would still use 0 as the default value.

And maybe a LIBXL_HAVE macro is needed, too.

Wei.

Quoted 7 lines

-George

Quoted 4 lines

Regards,
Dario

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

Acked-by on v1 1/2
#11 lore raw
In reply to George Dunlap
Quoted 17 lines · George Dunlap

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.

---

Quoted 8 lines

I realize this is somewhat of a bike shed, but I want to avoid propagating this "magic number" interface into the xenlight bindings if I can.

Also, at some point we might use the IDL to enforce that the libxl values are identical to the Xen values, at which point we can just pass the value in directly.

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

#5 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

In reply to Wei Liu
Quoted 66 lines · Wei Liu
Quoted 56 lines · George Dunlap
Quoted 36 lines · Dario Faggioli
Quoted 8 lines · George Dunlap

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).

Quoted 6 lines

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead. Still accept '0' as meaning "ANY" for backwards compatibility.

With one remark.

Quoted 5 lines
tools/libxl/libxl.h +0 -0
@@ -2086,6 +2086,12 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx,
 uint32_t domid, char* uuid,

tools/libxl/libxl.h int libxl_tmem_shared_auth(libxl_ctx *ctx, · line 2096

Quoted 10 lines
tools/libxl/libxl.h +6 -0
 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
 

Do we want this to be here, or in libxl_types.idl.

Quoted 7 lines

Asking because, AFAICT, it's the only one LIBXL_FOO_BAR defined like this. I appreciate that there's few point in making this an enum, as it is only one value, and will most likely remain so, but still, I thought I'd at least bring this up.

FWIW, my Reviewed-by stands both if it is kept as is, and if it is moved to IDL.

Well there's things like:

#define LIBXL_PCI_FUNC_ALL (~0U)

#define LIBXL_TIMER_MODE_DEFAULT -1
#define LIBXL_MEMKB_DEFAULT ~0ULL

#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)

#define LIBXL_MS_VM_GENID_LEN 16

Quoted 8 lines

#define LIBXL_SUSPEND_DEBUG 1
#define LIBXL_SUSPEND_LIVE 2

Many of which seem similar in some ways. Enums I think are meant to be exhaustive (as in, contain all possible options), not be special cases.

But I'm happy to defer to the tools maintainers.

Quoted 8 lines

I don't really care if it is an enum or a macro.

There is an issue that is more subtle than where it lives or what form it is in.

You need to modify all the poolid fields in various structure to make it as default. Otherwise the whole json infrastructure would still use 0 as the default value.

Hmm, at the moment there are only two structs that include poolid:
cpupoolinfo, which is OUT-only (so the field should always be initialized) and domain_create_info, for which 0 is a much better default logically than "ANY".

Quoted 2 lines

And maybe a LIBXL_HAVE macro is needed, too.

I thought about that, but figured people could just do #ifdef LIBXL_CPUPOOL_POOLID_ANY. It seemed a bit strange to define a whole new macro just to see if another macro existed.

Thoughts?

-George

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

#6 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Quoted 72 lines · George Dunlap
Quoted 71 lines · Wei Liu
Quoted 56 lines · George Dunlap
Quoted 36 lines · Dario Faggioli
Quoted 8 lines · George Dunlap

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).

Quoted 6 lines

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead. Still accept '0' as meaning "ANY" for backwards compatibility.

With one remark.

Quoted 5 lines
tools/libxl/libxl.h +0 -0
@@ -2086,6 +2086,12 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx,
 uint32_t domid, char* uuid,

tools/libxl/libxl.h int libxl_tmem_shared_auth(libxl_ctx *ctx, · line 2096

Quoted 10 lines
tools/libxl/libxl.h +6 -0
 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
 

Do we want this to be here, or in libxl_types.idl.

Quoted 7 lines

Asking because, AFAICT, it's the only one LIBXL_FOO_BAR defined like this. I appreciate that there's few point in making this an enum, as it is only one value, and will most likely remain so, but still, I thought I'd at least bring this up.

FWIW, my Reviewed-by stands both if it is kept as is, and if it is moved to IDL.

Well there's things like:

#define LIBXL_PCI_FUNC_ALL (~0U)

#define LIBXL_TIMER_MODE_DEFAULT -1
#define LIBXL_MEMKB_DEFAULT ~0ULL

#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)

#define LIBXL_MS_VM_GENID_LEN 16

Quoted 8 lines

#define LIBXL_SUSPEND_DEBUG 1
#define LIBXL_SUSPEND_LIVE 2

Many of which seem similar in some ways. Enums I think are meant to be exhaustive (as in, contain all possible options), not be special cases.

But I'm happy to defer to the tools maintainers.

I don't really care if it is an enum or a macro.

There is an issue that is more subtle than where it lives or what form it is in.

Quoted 9 lines
Quoted 3 lines

You need to modify all the poolid fields in various structure to make it as default. Otherwise the whole json infrastructure would still use 0 as the default value.

Hmm, at the moment there are only two structs that include poolid:
cpupoolinfo, which is OUT-only (so the field should always be initialized) and domain_create_info, for which 0 is a much better default logically than "ANY".

I don't follow here. Isn't 0 already "ANY"?

Quoted 7 lines
Quoted 2 lines

And maybe a LIBXL_HAVE macro is needed, too.

I thought about that, but figured people could just do #ifdef LIBXL_CPUPOOL_POOLID_ANY. It seemed a bit strange to define a whole new macro just to see if another macro existed.

I want to reserve the possibility to change that into an enum in the future.

Wei.

Quoted 4 lines

Thoughts?

-George

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

#7 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Quoted 77 lines · Wei Liu
Quoted 76 lines · George Dunlap
Quoted 74 lines · Wei Liu
Quoted 56 lines · George Dunlap
Quoted 36 lines · Dario Faggioli
Quoted 8 lines · George Dunlap

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).

Quoted 6 lines

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead. Still accept '0' as meaning "ANY" for backwards compatibility.

With one remark.

Quoted 5 lines
tools/libxl/libxl.h +0 -0
@@ -2086,6 +2086,12 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx,
 uint32_t domid, char* uuid,

tools/libxl/libxl.h int libxl_tmem_shared_auth(libxl_ctx *ctx, · line 2096

Quoted 10 lines
tools/libxl/libxl.h +6 -0
 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
 

Do we want this to be here, or in libxl_types.idl.

Quoted 7 lines

Asking because, AFAICT, it's the only one LIBXL_FOO_BAR defined like this. I appreciate that there's few point in making this an enum, as it is only one value, and will most likely remain so, but still, I thought I'd at least bring this up.

FWIW, my Reviewed-by stands both if it is kept as is, and if it is moved to IDL.

Well there's things like:

#define LIBXL_PCI_FUNC_ALL (~0U)

#define LIBXL_TIMER_MODE_DEFAULT -1
#define LIBXL_MEMKB_DEFAULT ~0ULL

#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)

#define LIBXL_MS_VM_GENID_LEN 16

Quoted 8 lines

#define LIBXL_SUSPEND_DEBUG 1
#define LIBXL_SUSPEND_LIVE 2

Many of which seem similar in some ways. Enums I think are meant to be exhaustive (as in, contain all possible options), not be special cases.

But I'm happy to defer to the tools maintainers.

I don't really care if it is an enum or a macro.

There is an issue that is more subtle than where it lives or what form it is in.

You need to modify all the poolid fields in various structure to make it as default. Otherwise the whole json infrastructure would still use 0 as the default value.

Quoted 7 lines
Quoted 5 lines

Hmm, at the moment there are only two structs that include poolid:
cpupoolinfo, which is OUT-only (so the field should always be initialized) and domain_create_info, for which 0 is a much better default logically than "ANY".

I don't follow here. Isn't 0 already "ANY"?

No. This is why I'm bothering to paint this bikeshed: In every context *except* "cpupool create", 0 means cpupool0 -- the one that was created at boot, which always contains dom0, and which cannot be destroyed. (You can only remove all but one of the cpus.) If you remove a cpupool from poolid 0, you remove it from cpupool0, not "any" pool. If you create a domain and ask to put it in poolid 0, it will be put in cpupool0, not "any" pool. The only context in which "0" currently means "any" is when you're creating a cpupool.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

And maybe a LIBXL_HAVE macro is needed, too.

I thought about that, but figured people could just do #ifdef LIBXL_CPUPOOL_POOLID_ANY. It seemed a bit strange to define a whole new macro just to see if another macro existed.

I want to reserve the possibility to change that into an enum in the future.

Yes, I had thought of that -- but like I said, I thought enums were meant mostly for things for which there was an exhaustive list. In this case it's a "magic" value for a parameter which normally has a plain numerical meaning.

But I can add the #define if you wish.

-George

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

#8 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Quoted 86 lines · George Dunlap
Quoted 77 lines · Wei Liu
Quoted 76 lines · George Dunlap
Quoted 74 lines · Wei Liu
Quoted 56 lines · George Dunlap
Quoted 36 lines · Dario Faggioli
Quoted 8 lines · George Dunlap

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).

Quoted 6 lines

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this instead. Still accept '0' as meaning "ANY" for backwards compatibility.

With one remark.

Quoted 5 lines
tools/libxl/libxl.h +0 -0
@@ -2086,6 +2086,12 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx,
 uint32_t domid, char* uuid,

tools/libxl/libxl.h int libxl_tmem_shared_auth(libxl_ctx *ctx, · line 2096

Quoted 10 lines
tools/libxl/libxl.h +6 -0
 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
 

Do we want this to be here, or in libxl_types.idl.

Quoted 7 lines

Asking because, AFAICT, it's the only one LIBXL_FOO_BAR defined like this. I appreciate that there's few point in making this an enum, as it is only one value, and will most likely remain so, but still, I thought I'd at least bring this up.

FWIW, my Reviewed-by stands both if it is kept as is, and if it is moved to IDL.

Well there's things like:

#define LIBXL_PCI_FUNC_ALL (~0U)

#define LIBXL_TIMER_MODE_DEFAULT -1
#define LIBXL_MEMKB_DEFAULT ~0ULL

#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)

#define LIBXL_MS_VM_GENID_LEN 16

Quoted 8 lines

#define LIBXL_SUSPEND_DEBUG 1
#define LIBXL_SUSPEND_LIVE 2

Many of which seem similar in some ways. Enums I think are meant to be exhaustive (as in, contain all possible options), not be special cases.

But I'm happy to defer to the tools maintainers.

I don't really care if it is an enum or a macro.

There is an issue that is more subtle than where it lives or what form it is in.

You need to modify all the poolid fields in various structure to make it as default. Otherwise the whole json infrastructure would still use 0 as the default value.

Quoted 7 lines
Quoted 5 lines

Hmm, at the moment there are only two structs that include poolid:
cpupoolinfo, which is OUT-only (so the field should always be initialized) and domain_create_info, for which 0 is a much better default logically than "ANY".

I don't follow here. Isn't 0 already "ANY"?

Quoted 9 lines

No. This is why I'm bothering to paint this bikeshed: In every context *except* "cpupool create", 0 means cpupool0 -- the one that was created at boot, which always contains dom0, and which cannot be destroyed. (You can only remove all but one of the cpus.) If you remove a cpupool from poolid 0, you remove it from cpupool0, not "any" pool. If you create a domain and ask to put it in poolid 0, it will be put in cpupool0, not "any" pool. The only context in which "0" currently means "any" is when you're creating a cpupool.

OK. This makes sense.

Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 1 line

And maybe a LIBXL_HAVE macro is needed, too.

I thought about that, but figured people could just do #ifdef LIBXL_CPUPOOL_POOLID_ANY. It seemed a bit strange to define a whole new macro just to see if another macro existed.

I want to reserve the possibility to change that into an enum in the future.

Quoted 7 lines

Yes, I had thought of that -- but like I said, I thought enums were meant mostly for things for which there was an exhaustive list. In this case it's a "magic" value for a parameter which normally has a plain numerical meaning.

But I can add the #define if you wish.

You don't need to do that.

Wei.

Quoted 1 line

-George

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

#9 lore raw

Re: [PATCH 2/2] tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Quoted 13 lines · Wei Liu
Quoted 9 lines · George Dunlap

No. This is why I'm bothering to paint this bikeshed: In every context *except* "cpupool create", 0 means cpupool0 -- the one that was created at boot, which always contains dom0, and which cannot be destroyed. (You can only remove all but one of the cpus.) If you remove a cpupool from poolid 0, you remove it from cpupool0, not "any" pool. If you create a domain and ask to put it in poolid 0, it will be put in cpupool0, not "any" pool. The only context in which "0" currently means "any" is when you're creating a cpupool.

OK. This makes sense.

[snip]

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

I want to reserve the possibility to change that into an enum in the future.

Yes, I had thought of that -- but like I said, I thought enums were meant mostly for things for which there was an exhaustive list. In this case it's a "magic" value for a parameter which normally has a plain numerical meaning.

Quoted 4 lines
Quoted 2 lines

But I can add the #define if you wish.

You don't need to do that.

Is that an Ack? :-)

-George

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