Skip to contentSkip to conversation

Expose capabilities in get_domain_state

PATCH Superseded Jason Andryuk 5 participants 14 messages Jul 22, 2025 – Jul 23, 2025

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Expose capabilities in get_domain_state

This is the capabilities patches split out from the larger series. get_domain_state is new in 4.21. If they go in before the release, the library won't need to be changed in the future.

v3 is used since they are iterations from the other series.

Jason Andryuk (2):
xen: Add capabilities to get_domain_state
tools/manage: Expose domain capabilities

 tools/include/xenmanage.h   | 14 ++++++++++++--
 tools/libs/manage/core.c    | 21 +++++++++++++++++----
 tools/xenstored/domain.c    |  8 ++++----
 xen/common/domain.c         | 10 +++++++++-
 xen/include/public/domctl.h |  7 +++++--
 5 files changed, 47 insertions(+), 13 deletions(-)
Signature · 1 line
2.50.1
#1 lore raw

PATCH v3 1/2 xen: Add capabilities to get_domain_state

Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.

The xenstore domain can use this information to assign appropriate permissions on connections.

Repurpose the 16bit pad field for this purpose.

---
v2:
Init info->caps = 0
Remove stale comment on caps field
Add Juergen's R-b

---
 xen/common/domain.c         | 10 +++++++++-
 xen/include/public/domctl.h |  7 +++++--
 2 files changed, 14 insertions(+), 3 deletions(-)
xen/common/domain.c +9 -1
index c347de4335..bb33b1f1c7 100644
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info,
         info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
     if ( d->is_dying == DOMDYING_dead )
         info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
     info->unique_id = d->unique_id;
 }
 
@@ -205,7 +213,7 @@ int get_domain_state(struct xen_domctl_get_domain_state *info, struct domain *d,
     int rc = -ENOENT;
     struct domain *hdl;
 
-    if ( info->pad0 || info->pad1 )
+    if ( info->pad0 )
         return -EINVAL;
 
     if ( d )
xen/include/public/domctl.h +5 -2
index f1f6f96bc2..136820ea5b 100644
@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state {
 #define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN  0x0002  /* Shutdown finished. */
 #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING     0x0004  /* Domain dying. */
 #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD      0x0008  /* Domain dead. */
-    uint16_t pad0;           /* Must be 0 on input, returned as 0. */
-    uint32_t pad1;           /* Must be 0 on input, returned as 0. */
+    uint16_t caps;
+#define XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL     0x0001  /* Control domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE    0x0002  /* Hardware domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE    0x0004  /* Xenstore domain. */
+    uint32_t pad0;           /* Must be 0 on input, returned as 0. */
     uint64_t unique_id;      /* Unique domain identifier. */
 };
 
Signature · 1 line
2.50.1
#2 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 30 lines · Jason Andryuk

Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.

The xenstore domain can use this information to assign appropriate permissions on connections.

Repurpose the 16bit pad field for this purpose.

---
v2:
Init info->caps = 0
Remove stale comment on caps field
Add Juergen's R-b

---
  xen/common/domain.c         | 10 +++++++++-
  xen/include/public/domctl.h |  7 +++++--
  2 files changed, 14 insertions(+), 3 deletions(-)
xen/common/domain.c +0 -0
index c347de4335..bb33b1f1c7 100644
xen/include/public/domctl.h +0 -0
index f1f6f96bc2..136820ea5b 100644

xen/include/public/domctl.h struct xen_domctl_get_domain_state { · line 1276

Quoted 10 lines
xen/include/public/domctl.h +5 -2
@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state {
  #define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN  0x0002  /* Shutdown finished. */
  #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING     0x0004  /* Domain dying. */
  #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD      0x0008  /* Domain dead. */
-    uint16_t pad0;           /* Must be 0 on input, returned as 0. */
-    uint32_t pad1;           /* Must be 0 on input, returned as 0. */
+    uint16_t caps;
+#define XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL     0x0001  /* Control domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE    0x0002  /* Hardware domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE    0x0004  /* Xenstore domain. */
+    uint32_t pad0;           /* Must be 0 on input, returned as 0. */

I have wondered if we should use some of this padding to start returning the valid capability bits. When the hypercall (and library) will be ready in case the number increases.

The other alternative would be to return the bits in some other call, in which case this one would not need to change. And returning the unchanging valids bits on each call seems unnecessary.

Regards,
Jason

Quoted 3 lines
xen/include/public/domctl.h +0 -0
      uint64_t unique_id;      /* Unique domain identifier. */
  };
 
#3 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 37 lines · Jason Andryuk
Quoted 36 lines · Jason Andryuk

Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.

The xenstore domain can use this information to assign appropriate permissions on connections.

Repurpose the 16bit pad field for this purpose.

---
v2:
Init info->caps = 0
Remove stale comment on caps field
Add Juergen's R-b

---
  xen/common/domain.c         | 10 +++++++++-
  xen/include/public/domctl.h |  7 +++++--
  2 files changed, 14 insertions(+), 3 deletions(-)
xen/common/domain.c +0 -0
index c347de4335..bb33b1f1c7 100644
xen/include/public/domctl.h +1 -2
index f1f6f96bc2..136820ea5b 100644
@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state {
  #define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN  0x0002  /* Shutdown finished. */
  #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING     0x0004  /* Domain dying. */
  #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD      0x0008  /* Domain dead. */
-    uint16_t pad0;           /* Must be 0 on input, returned as 0. */
-    uint32_t pad1;           /* Must be 0 on input, returned as 0. */
+    uint16_t caps;
Quoted 8 lines

xen/include/public/domctl.h struct xen_domctl_get_domain_state { · line 1276

Quoted 4 lines
xen/include/public/domctl.h +4 -0
+#define XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL     0x0001  /* Control domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE    0x0002  /* Hardware domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE    0x0004  /* Xenstore domain. */
+    uint32_t pad0;           /* Must be 0 on input, returned as 0. */

I have wondered if we should use some of this padding to start returning the valid capability bits. When the hypercall (and library) will be ready in case the number increases.

How would a caller use that information? The hypervisor wouldn't return "invalid" bits set. (If any such plausible use could be envisioned, it being a stable sub-op, providing such information would certainly make sense.)

Quoted 3 lines

The other alternative would be to return the bits in some other call, in which case this one would not need to change. And returning the unchanging valids bits on each call seems unnecessary.

Indeed. Yet the same interface could still be used (then perhaps also to indicate the valid XEN_DOMCTL_GETDOMSTATE_STATE_* bits): Have the caller pass in another special DOMID_* (DOMID_INVALID already has a meaning, though).

Jan

#4 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 47 lines · Jan Beulich
Quoted 37 lines · Jason Andryuk
Quoted 36 lines · Jason Andryuk

Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.

The xenstore domain can use this information to assign appropriate permissions on connections.

Repurpose the 16bit pad field for this purpose.

---
v2:
Init info->caps = 0
Remove stale comment on caps field
Add Juergen's R-b

---
   xen/common/domain.c         | 10 +++++++++-
   xen/include/public/domctl.h |  7 +++++--
   2 files changed, 14 insertions(+), 3 deletions(-)
xen/common/domain.c +0 -0
index c347de4335..bb33b1f1c7 100644
xen/include/public/domctl.h +1 -2
index f1f6f96bc2..136820ea5b 100644
@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state {
   #define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN  0x0002  /* Shutdown finished. */
   #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING     0x0004  /* Domain dying. */
   #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD      0x0008  /* Domain dead. */
-    uint16_t pad0;           /* Must be 0 on input, returned as 0. */
-    uint32_t pad1;           /* Must be 0 on input, returned as 0. */
+    uint16_t caps;
Quoted 8 lines

xen/include/public/domctl.h struct xen_domctl_get_domain_state { · line 1276

Quoted 4 lines
xen/include/public/domctl.h +4 -0
+#define XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL     0x0001  /* Control domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE    0x0002  /* Hardware domain. */
+#define XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE    0x0004  /* Xenstore domain. */
+    uint32_t pad0;           /* Must be 0 on input, returned as 0. */

I have wondered if we should use some of this padding to start returning the valid capability bits. When the hypercall (and library) will be ready in case the number increases.

Quoted 4 lines

How would a caller use that information? The hypervisor wouldn't return "invalid" bits set. (If any such plausible use could be envisioned, it being a stable sub-op, providing such information would certainly make sense.)

When scanning all domains there is a difference between "there is no domain with capability FOO" and "hypervisor doesn't report capability FOO".

The question is what a caller would do in the latter case.

Quoted 9 lines
Quoted 4 lines

The other alternative would be to return the bits in some other call, in which case this one would not need to change. And returning the unchanging valids bits on each call seems unnecessary.

Indeed. Yet the same interface could still be used (then perhaps also to indicate the valid XEN_DOMCTL_GETDOMSTATE_STATE_* bits): Have the caller pass in another special DOMID_* (DOMID_INVALID already has a meaning, though).

I'd rather go this route, as this would not burn another padding field for rare use cases. DOMID_XEN might be a good fit.

Juergen

Reviewed-by on v3 1/2
#5 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

In reply to Jason Andryuk
Quoted 10 lines · Jason Andryuk

Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.

The xenstore domain can use this information to assign appropriate permissions on connections.

Repurpose the 16bit pad field for this purpose.

#6 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

In reply to Jason Andryuk
Quoted 6 lines · Jason Andryuk
xen/common/domain.c +0 -0
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info,
         info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
     if ( d->is_dying == DOMDYING_dead )
         info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;

xen/common/domain.c static void set_domain_state_info(struct xen_domctl_get_domain_state *info, · line 207

Quoted 10 lines
xen/common/domain.c +8 -0
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
     info->unique_id = d->unique_id;
 }

This being a stable sub-op, don't we need a way to indicate to the caller _that_ this field has valid data now? When non-zero it's easy to tell, but getting back zero is ambiguous.

Jan

#7 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 13 lines · Jan Beulich
Quoted 12 lines · Jason Andryuk
xen/common/domain.c +6 -0
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info,
          info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
      if ( d->is_dying == DOMDYING_dead )
          info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
Quoted 8 lines

xen/common/domain.c static void set_domain_state_info(struct xen_domctl_get_domain_state *info, · line 207

Quoted 4 lines
xen/common/domain.c +2 -0
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
      info->unique_id = d->unique_id;
  }

This being a stable sub-op, don't we need a way to indicate to the caller _that_ this field has valid data now? When non-zero it's easy to tell, but getting back zero is ambiguous.

The hypercall sub-op was introduced in this development cycle only, so there is no released Xen hypervisor without the capability setting.

In case this patch doesn't make it into 4.21, the case you are mentioning must be handled, of course.

Juergen

#8 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 23 lines · Jürgen Groß
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Jason Andryuk
xen/common/domain.c +6 -0
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info,
          info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
      if ( d->is_dying == DOMDYING_dead )
          info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
Quoted 8 lines

xen/common/domain.c static void set_domain_state_info(struct xen_domctl_get_domain_state *info, · line 207

Quoted 4 lines
xen/common/domain.c +2 -0
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
      info->unique_id = d->unique_id;
  }

This being a stable sub-op, don't we need a way to indicate to the caller _that_ this field has valid data now? When non-zero it's easy to tell, but getting back zero is ambiguous.

Quoted 5 lines

The hypercall sub-op was introduced in this development cycle only, so there is no released Xen hypervisor without the capability setting.

In case this patch doesn't make it into 4.21, the case you are mentioning must be handled, of course.

Hmm, yes, this way it's on the edge. As a stable sub-op, someone could have backported the change, though. IOW (and in general) I wonder whether for stable sub-ops we shouldn't be pretty strict about functional extensions, not tying their addition to releases at all.

Jan

#9 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 27 lines · Jan Beulich
Quoted 26 lines · Jürgen Groß
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Jason Andryuk
xen/common/domain.c +6 -0
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info,
           info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
       if ( d->is_dying == DOMDYING_dead )
           info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
Quoted 8 lines

xen/common/domain.c static void set_domain_state_info(struct xen_domctl_get_domain_state *info, · line 207

Quoted 4 lines
xen/common/domain.c +2 -0
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
       info->unique_id = d->unique_id;
   }

This being a stable sub-op, don't we need a way to indicate to the caller _that_ this field has valid data now? When non-zero it's easy to tell, but getting back zero is ambiguous.

The hypercall sub-op was introduced in this development cycle only, so there is no released Xen hypervisor without the capability setting.

Quoted 7 lines
Quoted 2 lines

In case this patch doesn't make it into 4.21, the case you are mentioning must be handled, of course.

Hmm, yes, this way it's on the edge. As a stable sub-op, someone could have backported the change, though. IOW (and in general) I wonder whether for stable sub-ops we shouldn't be pretty strict about functional extensions, not tying their addition to releases at all.

Should we really care about downstreams backporting not yet released functionality?

Using your reasoning this would mean we'd need to issue XSAs for not yet released hypervisor issues of stable interfaces, too. I don't think we want to do that.

Juergen

#10 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 36 lines · Jürgen Groß
Quoted 27 lines · Jan Beulich
Quoted 26 lines · Jürgen Groß
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Jason Andryuk
xen/common/domain.c +6 -0
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info,
           info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
       if ( d->is_dying == DOMDYING_dead )
           info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
Quoted 8 lines

xen/common/domain.c static void set_domain_state_info(struct xen_domctl_get_domain_state *info, · line 207

Quoted 4 lines
xen/common/domain.c +2 -0
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
       info->unique_id = d->unique_id;
   }

This being a stable sub-op, don't we need a way to indicate to the caller _that_ this field has valid data now? When non-zero it's easy to tell, but getting back zero is ambiguous.

The hypercall sub-op was introduced in this development cycle only, so there is no released Xen hypervisor without the capability setting.

Quoted 7 lines
Quoted 2 lines

In case this patch doesn't make it into 4.21, the case you are mentioning must be handled, of course.

Hmm, yes, this way it's on the edge. As a stable sub-op, someone could have backported the change, though. IOW (and in general) I wonder whether for stable sub-ops we shouldn't be pretty strict about functional extensions, not tying their addition to releases at all.

Quoted 6 lines

Should we really care about downstreams backporting not yet released functionality?

Using your reasoning this would mean we'd need to issue XSAs for not yet released hypervisor issues of stable interfaces, too. I don't think we want to do that.

To me, the latter doesn't necessarily follow from the former. But anyway, I'm not going to insist, but I wanted the situation to at least be considered. In particular also forward-looking, when we may gain more stable sub-ops. At some point it may turn out necessary to backport such even into upstream branches.

Jan

#11 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 40 lines · Jan Beulich
Quoted 39 lines · Jürgen Groß
Quoted 27 lines · Jan Beulich
Quoted 26 lines · Jürgen Groß
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Jason Andryuk
xen/common/domain.c +6 -0
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info,
            info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
        if ( d->is_dying == DOMDYING_dead )
            info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
Quoted 8 lines

xen/common/domain.c static void set_domain_state_info(struct xen_domctl_get_domain_state *info, · line 207

Quoted 4 lines
xen/common/domain.c +2 -0
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
        info->unique_id = d->unique_id;
    }

This being a stable sub-op, don't we need a way to indicate to the caller _that_ this field has valid data now? When non-zero it's easy to tell, but getting back zero is ambiguous.

The hypercall sub-op was introduced in this development cycle only, so there is no released Xen hypervisor without the capability setting.

Quoted 7 lines
Quoted 2 lines

In case this patch doesn't make it into 4.21, the case you are mentioning must be handled, of course.

Hmm, yes, this way it's on the edge. As a stable sub-op, someone could have backported the change, though. IOW (and in general) I wonder whether for stable sub-ops we shouldn't be pretty strict about functional extensions, not tying their addition to releases at all.

Should we really care about downstreams backporting not yet released functionality?

Quoted 8 lines
Quoted 3 lines

Using your reasoning this would mean we'd need to issue XSAs for not yet released hypervisor issues of stable interfaces, too. I don't think we want to do that.

To me, the latter doesn't necessarily follow from the former. But anyway, I'm not going to insist, but I wanted the situation to at least be considered. In particular also forward-looking, when we may gain more stable sub-ops. At some point it may turn out necessary to backport such even into upstream branches.

I think it is fine to discuss this situation.

I'd suggest not to support any potential downstream backports of not yet released functionality. Consider a new interface being developed in a larger patch series. In case the series is not being committed in one go, would you want to support backports of only a part of it? What about fixes of that interface in the current release cycle, e.g. due to the use cases having been committed only some time later uncovering the need to change the interface to make it safe?

Juergen

#12 lore raw

Re: [PATCH v3 1/2] xen: Add capabilities to get_domain_state

Quoted 65 lines · Jürgen Groß
Quoted 53 lines · Jan Beulich
Quoted 44 lines · Jürgen Groß
Quoted 35 lines · Jan Beulich
Quoted 26 lines · Jürgen Groß
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Jason Andryuk
xen/common/domain.c +8 -0
@@ -195,6 +195,14 @@ static void set_domain_state_info(struct
 xen_domctl_get_domain_state *info,
             info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING;
         if ( d->is_dying == DOMDYING_dead )
             info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
+
+    info->caps = 0;
+    if ( is_control_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL;
+    if ( is_hardware_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE;
+    if ( is_xenstore_domain(d) )
+        info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE;
Quoted 8 lines

xen/common/domain.c static void set_domain_state_info(struct · line 208

Quoted 2 lines
xen/common/domain.c +0 -0
         info->unique_id = d->unique_id;
     }

This being a stable sub-op, don't we need a way to indicate to the caller
_that_ this field has valid data now? When non-zero it's easy to tell, but
getting back zero is ambiguous.

Quoted 7 lines

The hypercall sub-op was introduced in this development cycle only, so
there is no released Xen hypervisor without the capability setting.

In case this patch doesn't make it into 4.21, the case you are mentioning
must be handled, of course.

Quoted 7 lines

Hmm, yes, this way it's on the edge. As a stable sub-op, someone could have
backported the change, though. IOW (and in general) I wonder whether for
stable sub-ops we shouldn't be pretty strict about functional extensions,
not tying their addition to releases at all.

Quoted 7 lines

Should we really care about downstreams backporting not yet released functionality?

Using your reasoning this would mean we'd need to issue XSAs for not yet
released hypervisor issues of stable interfaces, too. I don't think we want to do that.

Quoted 8 lines

To me, the latter doesn't necessarily follow from the former. But anyway, I'm
not going to insist, but I wanted the situation to at least be considered. In
particular also forward-looking, when we may gain more stable sub-ops. At some
point it may turn out necessary to backport such even into upstream branches.

I think it is fine to discuss this situation.

Quoted 11 lines

I'd suggest not to support any potential downstream backports of not yet released functionality. Consider a new interface being developed in a larger
patch series. In case the series is not being committed in one go, would you
want to support backports of only a part of it? What about fixes of that interface in the current release cycle, e.g. due to the use cases having been
committed only some time later uncovering the need to change the interface
to make it safe?

Interfaces cannot be fixed until they're in a RELEASE-* tag.  Anything else would be absurd position to put upstream Xen into.

Downstreams backporting a not-yet-fixed interface is equivalent to taking a private ABI into their patchqueue.  They get to keep both pieces if it goes wrong.

(and I say this as someone who frequently walks this tightrope in the XenServer patchqueue.)

~Andrew

#13 lore raw

PATCH v3 2/2 tools/manage: Expose domain capabilities

In reply to Jason Andryuk

Add an additional "caps" argument to the libxenmanage functions to obtain a domains capabilities - control, hardware, and xenstore.

Update the xenstored callers at the same time.

---
v2:
Add Juergen's R-b

---
 tools/include/xenmanage.h | 14 ++++++++++++--
 tools/libs/manage/core.c  | 21 +++++++++++++++++----
 tools/xenstored/domain.c  |  8 ++++----
 3 files changed, 33 insertions(+), 10 deletions(-)
tools/include/xenmanage.h +12 -2
index 956b7a0a44..6fc0d9fe24 100644
@@ -45,6 +45,12 @@ int xenmanage_close(xenmanage_handle *hdl);
 #define XENMANAGE_GETDOMSTATE_STATE_DYING     0x0004  /* Domain dying. */
 #define XENMANAGE_GETDOMSTATE_STATE_DEAD      0x0008  /* Domain dead. */
 
+/* Control Domain capability. */
+#define XENMANAGE_GETDOMSTATE_CAP_CONTROL     0x0001
+/* Hardware Domain capability. */
+#define XENMANAGE_GETDOMSTATE_CAP_HARDWARE    0x0002
+/* Xenstore Domain capability. */
+#define XENMANAGE_GETDOMSTATE_CAP_XENSTORE    0x0004
 /*
  * Return state information of an existing domain.
  *
@@ -59,7 +65,8 @@ int xenmanage_close(xenmanage_handle *hdl);
  * Return value: 0 if information was stored, -1 else (errno is set)
  */
 int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid,
-                              unsigned int *state, uint64_t *unique_id);
+                              unsigned int *state, unsigned int *caps,
+                              uint64_t *unique_id);
 
 /*
  * Return information of a domain having changed state recently.
@@ -73,12 +80,15 @@ int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid,
  *   domid:     where to store the domid of the domain (not NULL)
  *   state:     where to store the state (XENMANAGE_GETDOMSTATE_STATE_ flags,
  *              nothing stored if NULL)
+ *   caps:      where to store the capabilities (XENMANAGE_GETDOMSTATE_CAP_
+ *              flags, nothing stored if NULL)
  *   unique_id: where to store the unique id of the domain (nothing stored if
  *              NULL)
  * Return value: 0 if information was stored, -1 else (errno is set)
  */
 int xenmanage_poll_changed_domain(xenmanage_handle *hdl, unsigned int *domid,
-                                  unsigned int *state, uint64_t *unique_id);
+                                  unsigned int *state, unsigned int *caps,
+                                  uint64_t *unique_id);
 #endif /* XENMANAGE_H */
 
 /*
tools/libs/manage/core.c +17 -4
index 8fb421df41..2fabdecaab 100644
@@ -92,6 +92,7 @@ static int xenmanage_do_domctl_get_domain_state(xenmanage_handle *hdl,
                                                 unsigned int domid_in,
                                                 unsigned int *domid_out,
                                                 unsigned int *state,
+                                                unsigned int *caps,
                                                 uint64_t *unique_id)
 {
     struct xen_domctl *buf;
@@ -130,6 +131,16 @@ static int xenmanage_do_domctl_get_domain_state(xenmanage_handle *hdl,
             if ( st->state & XEN_DOMCTL_GETDOMSTATE_STATE_DEAD )
                 *state |= XENMANAGE_GETDOMSTATE_STATE_DEAD;
         }
+        if ( caps )
+        {
+            *caps = 0;
+            if ( st->caps & XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL )
+                *caps |= XENMANAGE_GETDOMSTATE_CAP_CONTROL;
+            if ( st->caps & XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE )
+                *caps |= XENMANAGE_GETDOMSTATE_CAP_HARDWARE;
+            if ( st->caps & XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE )
+                *caps |= XENMANAGE_GETDOMSTATE_CAP_XENSTORE;
+        }
         if ( unique_id )
             *unique_id = st->unique_id;
     }
@@ -142,7 +153,8 @@ static int xenmanage_do_domctl_get_domain_state(xenmanage_handle *hdl,
 }
 
 int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid,
-                              unsigned int *state, uint64_t *unique_id)
+                              unsigned int *state, unsigned int *caps,
+                              uint64_t *unique_id)
 {
     if ( !hdl || domid >= DOMID_FIRST_RESERVED )
     {
@@ -150,12 +162,13 @@ int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid,
         return -1;
     }
 
-    return xenmanage_do_domctl_get_domain_state(hdl, domid, NULL, state,
+    return xenmanage_do_domctl_get_domain_state(hdl, domid, NULL, state, caps,
                                                 unique_id);
 }
 
 int xenmanage_poll_changed_domain(xenmanage_handle *hdl, unsigned int *domid,
-                                  unsigned int *state, uint64_t *unique_id)
+                                  unsigned int *state, unsigned int *caps,
+                                  uint64_t *unique_id)
 {
     if ( !hdl || !domid )
     {
@@ -164,5 +177,5 @@ int xenmanage_poll_changed_domain(xenmanage_handle *hdl, unsigned int *domid,
     }
 
     return xenmanage_do_domctl_get_domain_state(hdl, DOMID_INVALID, domid,
-                                                state, unique_id);
+                                                state, caps, unique_id);
 }
tools/xenstored/domain.c +4 -4
index 5ca40e7d6b..1241f8c73e 100644
@@ -667,7 +667,7 @@ static int check_domain(const void *k, void *v, void *arg)
 	unsigned int state;
 	uint64_t unique_id;
 
-	if (xenmanage_get_domain_info(xm_handle, domain->domid, &state,
+	if (xenmanage_get_domain_info(xm_handle, domain->domid, &state, NULL,
 				      &unique_id)) {
 		unique_id = 0;
 		state = 0;
@@ -700,7 +700,7 @@ static void do_check_domains(void)
 	struct domain *domain;
 	bool notify = false;
 
-	while (!xenmanage_poll_changed_domain(xm_handle, &domid, &state,
+	while (!xenmanage_poll_changed_domain(xm_handle, &domid, &state, NULL,
 					      &unique_id)) {
 		domain = find_domain_struct(domid);
 		if (domain)
@@ -829,7 +829,7 @@ static struct domain *find_or_alloc_existing_domain(unsigned int domid)
 	domain = find_domain_struct(domid);
 	if (!domain || !domain->unique_id)
 		dom_valid = !xenmanage_get_domain_info(xm_handle, domid,
-						       NULL, &unique_id);
+						       NULL, NULL, &unique_id);
 
 	if (dom_valid) {
 		if (!domain)
@@ -1381,7 +1381,7 @@ int domain_alloc_permrefs(struct node_perms *perms)
 		domid = perms->p[i].id;
 		d = find_domain_struct(domid);
 		if (!d) {
-			if (xenmanage_get_domain_info(xm_handle, domid,
+			if (xenmanage_get_domain_info(xm_handle, domid, NULL,
 						      NULL, &unique_id))
 				perms->p[i].perms |= XS_PERM_IGNORE;
 			else if (!alloc_domain(NULL, domid, unique_id))
Signature · 1 line
2.50.1