Skip to contentSkip to conversation

xen/domain: introduce DOMID_ANY

PATCH In review [email protected] 5 participants 14 messages Jan 9 – Feb 4

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 xen/domain: introduce DOMID_ANY

From: Denis Mukhin <[email protected]>

Add a new symbol DOMID_ANY to improve the readability of the code.

Update all relevant domid_alloc() call sites.

Amends: 2d5065060710 ("xen/domain: unify domain ID allocation")

---
Changes since v3:
- new value for DOMID_ANY instead of aliasing DOMID_INVALID
- Link to v3: https://lore.kernel.org/xen-devel/[email protected]/

---
 tools/tests/domid/harness.h             |  1 +
 tools/tests/domid/test-domid.c          | 12 ++++++------
 xen/common/device-tree/dom0less-build.c |  2 +-
 xen/common/domctl.c                     |  2 +-
 xen/common/domid.c                      |  2 +-
 xen/include/public/xen.h                |  5 +++++
 6 files changed, 15 insertions(+), 9 deletions(-)
tools/tests/domid/harness.h +1 -0
index 17eb22a9a854..65da0d075a2b 100644
@@ -41,6 +41,7 @@ extern unsigned long find_next_zero_bit(const unsigned long *addr,
 
 #define DOMID_FIRST_RESERVED            (100)
 #define DOMID_INVALID                   (101)
+#define DOMID_ANY                       (102)
 
 #endif /* _TEST_HARNESS_ */
 
tools/tests/domid/test-domid.c +6 -6
index 5915c4699a5c..71cc4e7fd86d 100644
@@ -41,20 +41,20 @@ int main(int argc, char **argv)
         domid_free(expected);
 
     /*
-     * Test that that two consecutive calls of domid_alloc(DOMID_INVALID)
+     * Test that that two consecutive calls of domid_alloc(DOMID_ANY)
      * will never return the same ID.
      * NB: ID#0 is reserved and shall not be allocated by
-     * domid_alloc(DOMID_INVALID).
+     * domid_alloc(DOMID_ANY).
      */
     for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == expected,
                "TEST 3: expected %u allocated %u\n", expected, allocated);
     }
     for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == DOMID_INVALID,
                "TEST 4: expected %u allocated %u\n", DOMID_INVALID, allocated);
     }
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
         domid_free(expected);
     for ( expected = 1; expected < DOMID_FIRST_RESERVED / 2; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == expected,
                "TEST 5: expected %u allocated %u\n", expected, allocated);
     }
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
     /* Re-allocate last ID from [1..DOMID_FIRST_RESERVED - 1]. */
     expected = DOMID_FIRST_RESERVED - 1;
     domid_free(DOMID_FIRST_RESERVED - 1);
-    allocated = domid_alloc(DOMID_INVALID);
+    allocated = domid_alloc(DOMID_ANY);
     verify(allocated == expected,
            "TEST 6: expected %u allocated %u\n", expected, allocated);
 
xen/common/device-tree/dom0less-build.c +1 -1
index 495ef7b16aa0..9130c38681df 100644
@@ -842,7 +842,7 @@ void __init create_domUs(void)
         if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED )
             panic("No more domain IDs available\n");
 
-        domid = domid_alloc(DOMID_INVALID);
+        domid = domid_alloc(DOMID_ANY);
         if ( domid == DOMID_INVALID )
             panic("Error allocating ID for domain %s\n", dt_node_name(node));
 
xen/common/domctl.c +1 -1
index 29a7726d32d0..e2c8990531ad 100644
@@ -410,7 +410,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
     case XEN_DOMCTL_createdomain:
     {
         /* NB: ID#0 is reserved, find the first suitable ID instead. */
-        domid_t domid = domid_alloc(op->domain ?: DOMID_INVALID);
+        domid_t domid = domid_alloc(op->domain ?: DOMID_ANY);
 
         if ( domid == DOMID_INVALID )
         {
xen/common/domid.c +1 -1
index 2387ddb08300..76b7f3e7ae6e 100644
@@ -19,7 +19,7 @@ static DECLARE_BITMAP(domid_bitmap, DOMID_FIRST_RESERVED);
  * @param domid Domain ID hint:
  * - If an explicit domain ID is provided, verify its availability and use it
  *   if ID is not used;
- * - If DOMID_INVALID is provided, search [1..DOMID_FIRST_RESERVED-1] range,
+ * - If DOMID_ANY is provided, search [1..DOMID_FIRST_RESERVED-1] range,
  *   starting from the last used ID. Implementation guarantees that two
  *   consecutive calls will never return the same ID. ID#0 is reserved for
  *   the first boot domain (currently, dom0) and excluded from the allocation
xen/include/public/xen.h +5 -0
index 7f15204c3885..b5789c32ae1f 100644
@@ -608,6 +608,11 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 /* DOMID_INVALID is used to identify pages with unknown owner. */
 #define DOMID_INVALID        xen_mk_uint(0x7FF4)
 
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+/* Domain ID allocator: search [1..DOMID_FIRST_RESERVED-1] range. */
+#define DOMID_ANY            xen_mk_uint(0x7FF5)
+#endif
+
 /* Idle domain. */
 #define DOMID_IDLE           xen_mk_uint(0x7FFF)
 
Signature · 1 line
2.52.0
Reviewed-by on v4 1/1
#1 lore raw
Quoted 8 lines · On Fri, 9 Jan 2026, [email protected] wrote:

From: Denis Mukhin <[email protected]>

Add a new symbol DOMID_ANY to improve the readability of the code.

Update all relevant domid_alloc() call sites.

Amends: 2d5065060710 ("xen/domain: unify domain ID allocation")

I think it improves readability and this new version addresses Roger's concerns as far as I can tell.

One minor comment: domid_alloc effectively still accept DOMID_INVALID to say "give me any DOMID" although it is no longer documented or used. If we wanted to enforce a different behavior between DOMID_INVALID and DOMID_ANY we would need to modify domid_alloc.

However, I think this patch is sufficient as it is:

Quoted 130 lines

---
Changes since v3:
- new value for DOMID_ANY instead of aliasing DOMID_INVALID
- Link to v3: https://lore.kernel.org/xen-devel/[email protected]/

---
 tools/tests/domid/harness.h             |  1 +
 tools/tests/domid/test-domid.c          | 12 ++++++------
 xen/common/device-tree/dom0less-build.c |  2 +-
 xen/common/domctl.c                     |  2 +-
 xen/common/domid.c                      |  2 +-
 xen/include/public/xen.h                |  5 +++++
 6 files changed, 15 insertions(+), 9 deletions(-)
tools/tests/domid/harness.h +1 -0
index 17eb22a9a854..65da0d075a2b 100644
@@ -41,6 +41,7 @@ extern unsigned long find_next_zero_bit(const unsigned long *addr,
 
 #define DOMID_FIRST_RESERVED            (100)
 #define DOMID_INVALID                   (101)
+#define DOMID_ANY                       (102)
 
 #endif /* _TEST_HARNESS_ */
 
tools/tests/domid/test-domid.c +6 -6
index 5915c4699a5c..71cc4e7fd86d 100644
@@ -41,20 +41,20 @@ int main(int argc, char **argv)
         domid_free(expected);
 
     /*
-     * Test that that two consecutive calls of domid_alloc(DOMID_INVALID)
+     * Test that that two consecutive calls of domid_alloc(DOMID_ANY)
      * will never return the same ID.
      * NB: ID#0 is reserved and shall not be allocated by
-     * domid_alloc(DOMID_INVALID).
+     * domid_alloc(DOMID_ANY).
      */
     for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == expected,
                "TEST 3: expected %u allocated %u\n", expected, allocated);
     }
     for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == DOMID_INVALID,
                "TEST 4: expected %u allocated %u\n", DOMID_INVALID, allocated);
     }
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
         domid_free(expected);
     for ( expected = 1; expected < DOMID_FIRST_RESERVED / 2; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == expected,
                "TEST 5: expected %u allocated %u\n", expected, allocated);
     }
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
     /* Re-allocate last ID from [1..DOMID_FIRST_RESERVED - 1]. */
     expected = DOMID_FIRST_RESERVED - 1;
     domid_free(DOMID_FIRST_RESERVED - 1);
-    allocated = domid_alloc(DOMID_INVALID);
+    allocated = domid_alloc(DOMID_ANY);
     verify(allocated == expected,
            "TEST 6: expected %u allocated %u\n", expected, allocated);
 
xen/common/device-tree/dom0less-build.c +1 -1
index 495ef7b16aa0..9130c38681df 100644
@@ -842,7 +842,7 @@ void __init create_domUs(void)
         if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED )
             panic("No more domain IDs available\n");
 
-        domid = domid_alloc(DOMID_INVALID);
+        domid = domid_alloc(DOMID_ANY);
         if ( domid == DOMID_INVALID )
             panic("Error allocating ID for domain %s\n", dt_node_name(node));
 
xen/common/domctl.c +1 -1
index 29a7726d32d0..e2c8990531ad 100644
@@ -410,7 +410,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
     case XEN_DOMCTL_createdomain:
     {
         /* NB: ID#0 is reserved, find the first suitable ID instead. */
-        domid_t domid = domid_alloc(op->domain ?: DOMID_INVALID);
+        domid_t domid = domid_alloc(op->domain ?: DOMID_ANY);
 
         if ( domid == DOMID_INVALID )
         {
xen/common/domid.c +1 -1
index 2387ddb08300..76b7f3e7ae6e 100644
@@ -19,7 +19,7 @@ static DECLARE_BITMAP(domid_bitmap, DOMID_FIRST_RESERVED);
  * @param domid Domain ID hint:
  * - If an explicit domain ID is provided, verify its availability and use it
  *   if ID is not used;
- * - If DOMID_INVALID is provided, search [1..DOMID_FIRST_RESERVED-1] range,
+ * - If DOMID_ANY is provided, search [1..DOMID_FIRST_RESERVED-1] range,
  *   starting from the last used ID. Implementation guarantees that two
  *   consecutive calls will never return the same ID. ID#0 is reserved for
  *   the first boot domain (currently, dom0) and excluded from the allocation
xen/include/public/xen.h +5 -0
index 7f15204c3885..b5789c32ae1f 100644
@@ -608,6 +608,11 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 /* DOMID_INVALID is used to identify pages with unknown owner. */
 #define DOMID_INVALID        xen_mk_uint(0x7FF4)
 
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+/* Domain ID allocator: search [1..DOMID_FIRST_RESERVED-1] range. */
+#define DOMID_ANY            xen_mk_uint(0x7FF5)
+#endif
+
 /* Idle domain. */
 #define DOMID_IDLE           xen_mk_uint(0x7FFF)
 
Signature · 1 line
2.52.0
Reviewed-by on v4 1/1
#2 lore raw
In reply to [email protected]
Quoted 8 lines · On 09.01.26 15:07, [email protected] wrote:

From: Denis Mukhin <[email protected]>

Add a new symbol DOMID_ANY to improve the readability of the code.

Update all relevant domid_alloc() call sites.

Amends: 2d5065060710 ("xen/domain: unify domain ID allocation")

I'm really happy you wrote this patch, as I'm working on a series for xenstored, where I need DOMID_ANY. I was just about to introduce something like that myself. :-)

Juergen

#3 lore raw
In reply to [email protected]
Quoted 98 lines · On Fri, Jan 09, 2026 at 06:07:48AM -0800, [email protected] wrote:

From: Denis Mukhin <[email protected]>

Add a new symbol DOMID_ANY to improve the readability of the code.

Update all relevant domid_alloc() call sites.

Amends: 2d5065060710 ("xen/domain: unify domain ID allocation")

---
Changes since v3:
- new value for DOMID_ANY instead of aliasing DOMID_INVALID
- Link to v3: https://lore.kernel.org/xen-devel/[email protected]/

---
 tools/tests/domid/harness.h             |  1 +
 tools/tests/domid/test-domid.c          | 12 ++++++------
 xen/common/device-tree/dom0less-build.c |  2 +-
 xen/common/domctl.c                     |  2 +-
 xen/common/domid.c                      |  2 +-
 xen/include/public/xen.h                |  5 +++++
 6 files changed, 15 insertions(+), 9 deletions(-)
tools/tests/domid/harness.h +1 -0
index 17eb22a9a854..65da0d075a2b 100644
@@ -41,6 +41,7 @@ extern unsigned long find_next_zero_bit(const unsigned long *addr,
 
 #define DOMID_FIRST_RESERVED            (100)
 #define DOMID_INVALID                   (101)
+#define DOMID_ANY                       (102)
 
 #endif /* _TEST_HARNESS_ */
 
tools/tests/domid/test-domid.c +6 -6
index 5915c4699a5c..71cc4e7fd86d 100644
@@ -41,20 +41,20 @@ int main(int argc, char **argv)
         domid_free(expected);
 
     /*
-     * Test that that two consecutive calls of domid_alloc(DOMID_INVALID)
+     * Test that that two consecutive calls of domid_alloc(DOMID_ANY)
      * will never return the same ID.
      * NB: ID#0 is reserved and shall not be allocated by
-     * domid_alloc(DOMID_INVALID).
+     * domid_alloc(DOMID_ANY).
      */
     for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == expected,
                "TEST 3: expected %u allocated %u\n", expected, allocated);
     }
     for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == DOMID_INVALID,
                "TEST 4: expected %u allocated %u\n", DOMID_INVALID, allocated);
     }
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
         domid_free(expected);
     for ( expected = 1; expected < DOMID_FIRST_RESERVED / 2; expected++ )
     {
-        allocated = domid_alloc(DOMID_INVALID);
+        allocated = domid_alloc(DOMID_ANY);
         verify(allocated == expected,
                "TEST 5: expected %u allocated %u\n", expected, allocated);
     }
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
     /* Re-allocate last ID from [1..DOMID_FIRST_RESERVED - 1]. */
     expected = DOMID_FIRST_RESERVED - 1;
     domid_free(DOMID_FIRST_RESERVED - 1);
-    allocated = domid_alloc(DOMID_INVALID);
+    allocated = domid_alloc(DOMID_ANY);
     verify(allocated == expected,
            "TEST 6: expected %u allocated %u\n", expected, allocated);
 
xen/common/device-tree/dom0less-build.c +1 -1
index 495ef7b16aa0..9130c38681df 100644
@@ -842,7 +842,7 @@ void __init create_domUs(void)
         if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED )
             panic("No more domain IDs available\n");
 
-        domid = domid_alloc(DOMID_INVALID);
+        domid = domid_alloc(DOMID_ANY);
         if ( domid == DOMID_INVALID )
             panic("Error allocating ID for domain %s\n", dt_node_name(node));
 
xen/common/domctl.c +0 -0
index 29a7726d32d0..e2c8990531ad 100644

xen/common/domctl.c long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) · line 413

Quoted 5 lines
xen/common/domctl.c +1 -1
@@ -410,7 +410,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
     case XEN_DOMCTL_createdomain:
     {
         /* NB: ID#0 is reserved, find the first suitable ID instead. */
-        domid_t domid = domid_alloc(op->domain ?: DOMID_INVALID);
+        domid_t domid = domid_alloc(op->domain ?: DOMID_ANY);

I don't think you need to do it here, but you want to check the parameter passed to domid_alloc(). It should return an error if:

domid >= DOMID_FIRST_RESERVED && domid != DOMID_ANY

Quoted 21 lines
xen/common/domctl.c +0 -0
         if ( domid == DOMID_INVALID )
         {
xen/common/domid.c +1 -1
index 2387ddb08300..76b7f3e7ae6e 100644
@@ -19,7 +19,7 @@ static DECLARE_BITMAP(domid_bitmap, DOMID_FIRST_RESERVED);
  * @param domid Domain ID hint:
  * - If an explicit domain ID is provided, verify its availability and use it
  *   if ID is not used;
- * - If DOMID_INVALID is provided, search [1..DOMID_FIRST_RESERVED-1] range,
+ * - If DOMID_ANY is provided, search [1..DOMID_FIRST_RESERVED-1] range,
  *   starting from the last used ID. Implementation guarantees that two
  *   consecutive calls will never return the same ID. ID#0 is reserved for
  *   the first boot domain (currently, dom0) and excluded from the allocation
xen/include/public/xen.h +0 -0
index 7f15204c3885..b5789c32ae1f 100644

xen/include/public/xen.h DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); · line 614

Quoted 7 lines
xen/include/public/xen.h +4 -0
@@ -608,6 +608,11 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 /* DOMID_INVALID is used to identify pages with unknown owner. */
 #define DOMID_INVALID        xen_mk_uint(0x7FF4)
 
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+/* Domain ID allocator: search [1..DOMID_FIRST_RESERVED-1] range. */
+#define DOMID_ANY            xen_mk_uint(0x7FF5)
+#endif

I would attempt to word the comment in a more generic way. While this is now only used for the domain ID allocator, it's likely to gain more uses going forward (Juergen already expressed interest):

"DOMID_ANY is used to signal no specific domid requested. Handler should pick a valid domid, or handle it as a broadcast value depending on the context."

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

Thanks, Roger.

#4 lore raw
Quoted 16 lines · Roger Pau Monné

xen/include/public/xen.h DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); · line 614

Quoted 10 lines · On Fri, Jan 09, 2026 at 06:07:48AM -0800, [email protected] wrote:
xen/include/public/xen.h +4 -0
@@ -608,6 +608,11 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 /* DOMID_INVALID is used to identify pages with unknown owner. */
 #define DOMID_INVALID        xen_mk_uint(0x7FF4)
 
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+/* Domain ID allocator: search [1..DOMID_FIRST_RESERVED-1] range. */
+#define DOMID_ANY            xen_mk_uint(0x7FF5)
+#endif

I would attempt to word the comment in a more generic way. While this is now only used for the domain ID allocator, it's likely to gain more uses going forward (Juergen already expressed interest):

Quoted 3 lines

"DOMID_ANY is used to signal no specific domid requested. Handler should pick a valid domid, or handle it as a broadcast value depending on the context."

+1

Quoted 5 lines

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Jan

#5 lore raw
Quoted 29 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné

xen/include/public/xen.h DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); · line 614

Quoted 10 lines · On Fri, Jan 09, 2026 at 06:07:48AM -0800, [email protected] wrote:
xen/include/public/xen.h +4 -0
@@ -608,6 +608,11 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 /* DOMID_INVALID is used to identify pages with unknown owner. */
 #define DOMID_INVALID        xen_mk_uint(0x7FF4)
 
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+/* Domain ID allocator: search [1..DOMID_FIRST_RESERVED-1] range. */
+#define DOMID_ANY            xen_mk_uint(0x7FF5)
+#endif

I would attempt to word the comment in a more generic way. While this is now only used for the domain ID allocator, it's likely to gain more uses going forward (Juergen already expressed interest):

Quoted 3 lines

"DOMID_ANY is used to signal no specific domid requested. Handler should pick a valid domid, or handle it as a broadcast value depending on the context."

+1

Quoted 5 lines

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

Quoted 4 lines

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Thanks, Roger.

#6 lore raw
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

Jan

#7 lore raw
Quoted 19 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Quoted 6 lines

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

I have a patch in work which would want DOMID_ANY not be guarded. I think especially DOMID_ANY could be useful for other cases, too.

Look e.g. at XEN_ARGO_DOMID_ANY. Even if I don't think we can switch it to DOMID_ANY, it shows that the concept as such is not restricted to Xen internal use cases.

Juergen

#8 lore raw
Quoted 24 lines · Juergen Gross
Quoted 23 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Quoted 5 lines
Quoted 2 lines

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

I have a patch in work which would want DOMID_ANY not be guarded. I think especially DOMID_ANY could be useful for other cases, too.

Mind me asking where, outside of the toolstack, you intend to use it? Note that unlike IDLE and perhaps a few others, ...

Quoted 3 lines

Look e.g. at XEN_ARGO_DOMID_ANY. Even if I don't think we can switch it to DOMID_ANY, it shows that the concept as such is not restricted to Xen internal use cases.

... I don't mean ANY to be constrained to just the hypervisor. That more strict guarding came up only because of Roger mentioning IDLE.

Jan

#9 lore raw
Quoted 25 lines · Jan Beulich
Quoted 24 lines · Juergen Gross
Quoted 23 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

I have a patch in work which would want DOMID_ANY not be guarded. I think especially DOMID_ANY could be useful for other cases, too.

Mind me asking where, outside of the toolstack, you intend to use it?

I'd like to be able to use it for Xenstore permissions.

Primary use case would be to allow the special watches for domain creation and removal to be usable for all guests, but there might be use cases where a domU wants to give node read access for everyone.

Juergen

#10 lore raw
Quoted 32 lines · Juergen Gross
Quoted 31 lines · Jan Beulich
Quoted 29 lines · Juergen Gross
Quoted 19 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Quoted 6 lines

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

I have a patch in work which would want DOMID_ANY not be guarded. I think especially DOMID_ANY could be useful for other cases, too.

Quoted 7 lines
Quoted 1 line

Mind me asking where, outside of the toolstack, you intend to use it?

I'd like to be able to use it for Xenstore permissions.

Primary use case would be to allow the special watches for domain creation and removal to be usable for all guests, but there might be use cases where a domU wants to give node read access for everyone.

Would that require exposing beyond the toolstack's boundaries?

Jan

#11 lore raw
Quoted 35 lines · Jan Beulich
Quoted 34 lines · Juergen Gross
Quoted 32 lines · Jan Beulich
Quoted 24 lines · Juergen Gross
Quoted 23 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Quoted 5 lines
Quoted 2 lines

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

I have a patch in work which would want DOMID_ANY not be guarded. I think especially DOMID_ANY could be useful for other cases, too.

Mind me asking where, outside of the toolstack, you intend to use it?

Quoted 7 lines
Quoted 5 lines

I'd like to be able to use it for Xenstore permissions.

Primary use case would be to allow the special watches for domain creation and removal to be usable for all guests, but there might be use cases where a domU wants to give node read access for everyone.

Would that require exposing beyond the toolstack's boundaries?

Yes, as this would require the user to specify DOMID_ANY as the domid in struct xs_permissions.

Juergen

#12 lore raw
Quoted 38 lines · Juergen Gross
Quoted 37 lines · Jan Beulich
Quoted 36 lines · Juergen Gross
Quoted 25 lines · Jan Beulich
Quoted 24 lines · Juergen Gross
Quoted 23 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

I have a patch in work which would want DOMID_ANY not be guarded. I think especially DOMID_ANY could be useful for other cases, too.

Mind me asking where, outside of the toolstack, you intend to use it?

I'd like to be able to use it for Xenstore permissions.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Primary use case would be to allow the special watches for domain creation and removal to be usable for all guests, but there might be use cases where a domU wants to give node read access for everyone.

Would that require exposing beyond the toolstack's boundaries?

Yes, as this would require the user to specify DOMID_ANY as the domid in struct xs_permissions.

Hmm, I see. I wonder though whether things like this wouldn't want a separate layer of abstraction, such that users of the library won't need to include (and hence have available) Xen's public headers.

Jan

#13 lore raw
Quoted 43 lines · Jan Beulich
Quoted 42 lines · Juergen Gross
Quoted 41 lines · Jan Beulich
Quoted 39 lines · Juergen Gross
Quoted 25 lines · Jan Beulich
Quoted 24 lines · Juergen Gross
Quoted 23 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monné

Also, I would remove the tools guards, I think once a DOMID_ constant is allocated it becomes part of the public ABI, and it cannot be withdrawn. See for example DOMID_IDLE: it's only used internally in the hypervisor AFAICT, yet the define is fully visible in the headers.

It was me to ask for it to be guarded like this. DOMID_IDLE (and perhaps others) not being guarded (at least for IDLE: by just __XEN__) imo was a mistake. That mistake may in fact be correctable, if we could prove that the ID cannot usefully be passed into anywhere.

Quoted 4 lines

Even if it's not passed into anything, does it make sense to guard them? The reserved domid values are already consumed, ie: cannot be reused in any way. It just seem to me like more ifdefery churn for no specific benefit.

Well. From an abstract perspective, purely hypothetical at this point, I could see a potential need to re-number them, e.g. to simplify checking against groups of these special IDs.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Yes, excess #ifdef-ary is an issue. Excess exposure of things also is, though. Finding the right balance between both can be interesting.

I have a patch in work which would want DOMID_ANY not be guarded. I think especially DOMID_ANY could be useful for other cases, too.

Mind me asking where, outside of the toolstack, you intend to use it?

I'd like to be able to use it for Xenstore permissions.

Primary use case would be to allow the special watches for domain creation and removal to be usable for all guests, but there might be use cases where a domU wants to give node read access for everyone.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Would that require exposing beyond the toolstack's boundaries?

Yes, as this would require the user to specify DOMID_ANY as the domid in struct xs_permissions.

Hmm, I see. I wonder though whether things like this wouldn't want a separate layer of abstraction, such that users of the library won't need to include (and hence have available) Xen's public headers.

Currently most library header files #include one or more Xen public headers.

xenstore.h e.g. already depends on xen/public/io/xs_wire.h.

Juergen