tools/manage: Expose domain capabilities

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.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
This commit is contained in:
Jason Andryuk authored and Jan Beulich committed 2025-07-31 09:43:46 +02:00
1 parent 0ba439b942
commit d885b9daf4
3 files changed
+33 -10

No files matched your search

+12 -2
View File
@@ -45,6 +45,12 @@ int xenmanage_close(xenmanage_handle *hdl);
#define XENMANAGE_GETDOMSTATE_STATE_DYING 0x0004 /* Domain dying. */ #define XENMANAGE_GETDOMSTATE_STATE_DYING 0x0004 /* Domain dying. */
#define XENMANAGE_GETDOMSTATE_STATE_DEAD 0x0008 /* Domain dead. */ #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. * 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) * Return value: 0 if information was stored, -1 else (errno is set)
*/ */
int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid, 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. * 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) * domid: where to store the domid of the domain (not NULL)
* state: where to store the state (XENMANAGE_GETDOMSTATE_STATE_ flags, * state: where to store the state (XENMANAGE_GETDOMSTATE_STATE_ flags,
* nothing stored if NULL) * 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 * unique_id: where to store the unique id of the domain (nothing stored if
* NULL) * NULL)
* Return value: 0 if information was stored, -1 else (errno is set) * Return value: 0 if information was stored, -1 else (errno is set)
*/ */
int xenmanage_poll_changed_domain(xenmanage_handle *hdl, unsigned int *domid, 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 */ #endif /* XENMANAGE_H */
/* /*
+17 -4
View File
@@ -92,6 +92,7 @@ static int xenmanage_do_domctl_get_domain_state(xenmanage_handle *hdl,
unsigned int domid_in, unsigned int domid_in,
unsigned int *domid_out, unsigned int *domid_out,
unsigned int *state, unsigned int *state,
unsigned int *caps,
uint64_t *unique_id) uint64_t *unique_id)
{ {
struct xen_domctl *buf; 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 ) if ( st->state & XEN_DOMCTL_GETDOMSTATE_STATE_DEAD )
*state |= XENMANAGE_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 ) if ( unique_id )
*unique_id = st->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, 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 ) if ( !hdl || domid >= DOMID_FIRST_RESERVED )
{ {
@@ -150,12 +162,13 @@ int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid,
return -1; 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); unique_id);
} }
int xenmanage_poll_changed_domain(xenmanage_handle *hdl, unsigned int *domid, 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 ) 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, return xenmanage_do_domctl_get_domain_state(hdl, DOMID_INVALID, domid,
state, unique_id); state, caps, unique_id);
} }
+4 -4
View File
@@ -673,7 +673,7 @@ static int check_domain(const void *k, void *v, void *arg)
unsigned int state; unsigned int state;
uint64_t unique_id; 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)) {
unique_id = 0; unique_id = 0;
state = 0; state = 0;
@@ -706,7 +706,7 @@ static void do_check_domains(void)
struct domain *domain; struct domain *domain;
bool notify = false; bool notify = false;
while (!xenmanage_poll_changed_domain(xm_handle, &domid, &state, while (!xenmanage_poll_changed_domain(xm_handle, &domid, &state, NULL,
&unique_id)) { &unique_id)) {
domain = find_domain_struct(domid); domain = find_domain_struct(domid);
if (domain) if (domain)
@@ -836,7 +836,7 @@ static struct domain *find_or_alloc_existing_domain(unsigned int domid)
domain = find_domain_struct(domid); domain = find_domain_struct(domid);
if (!domain || !domain->unique_id) if (!domain || !domain->unique_id)
dom_valid = !xenmanage_get_domain_info(xm_handle, domid, dom_valid = !xenmanage_get_domain_info(xm_handle, domid,
NULL, &unique_id); NULL, NULL, &unique_id);
if (dom_valid) { if (dom_valid) {
if (!domain) if (!domain)
@@ -1447,7 +1447,7 @@ int domain_alloc_permrefs(struct node_perms *perms)
domid = perms->p[i].id; domid = perms->p[i].id;
d = find_domain_struct(domid); d = find_domain_struct(domid);
if (!d) { if (!d) {
if (xenmanage_get_domain_info(xm_handle, domid, if (xenmanage_get_domain_info(xm_handle, domid, NULL,
NULL, &unique_id)) NULL, &unique_id))
perms->p[i].perms |= XS_PERM_IGNORE; perms->p[i].perms |= XS_PERM_IGNORE;
else if (!alloc_domain(NULL, domid, unique_id)) else if (!alloc_domain(NULL, domid, unique_id))
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.