Skip to content

Commit

Permalink
xen: domctl: Get back created domain id
Browse files Browse the repository at this point in the history
If 0 is passed as domain id to the Xen createdomain hypercall, it will
allocate a new domain id and return it via the domctl structure.
Allow callers to access this new domain id via a pointer arg.
This will allow to create domains without explicitly specifying the
domain id for them.

Signed-off-by: Mykyta Poturai <[email protected]>
Acked-by: Mykola Kvach <[email protected]>
Acked-by: Dmytro Firsov <[email protected]>
Reviewed-by: Grygorii Strashko <[email protected]>
(cherry picked from commit eb0ed21
 zephyr-v3.6.0-xt)
  • Loading branch information
Deedone authored and Grygorii Strashko committed May 3, 2024
1 parent 03c3eb6 commit 20a5306
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
22 changes: 15 additions & 7 deletions drivers/xen/dom0/domctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,23 @@ int xen_domctl_max_vcpus(int domid, int max_vcpus)
return do_domctl(&domctl);
}

int xen_domctl_createdomain(int domid, struct xen_domctl_createdomain *config)
int xen_domctl_createdomain(int *domid, struct xen_domctl_createdomain *config)
{
xen_domctl_t domctl = {
.cmd = XEN_DOMCTL_createdomain,
.domain = domid,
.u.createdomain = *config,
};
int ret;
xen_domctl_t domctl;

return do_domctl(&domctl);
if (!domid || !config) {
return -EINVAL;
}

domctl.cmd = XEN_DOMCTL_createdomain,
domctl.domain = *domid,
domctl.u.createdomain = *config,

ret = do_domctl(&domctl);
*domid = domctl.domain;

return ret;
}

int xen_domctl_destroydomain(int domid)
Expand Down
8 changes: 6 additions & 2 deletions include/zephyr/xen/dom0/domctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,15 @@ int xen_domctl_max_vcpus(int domid, int max_vcpus);
/**
* @brief Creates a new domain with the specified domain ID and configuration.
*
* @param domid The domain ID of the new domain.
* NB. domid is an IN/OUT parameter for this operation.
* If it is specified as an invalid value (0 or >= DOMID_FIRST_RESERVED),
* an id is auto-allocated and returned.
* @param[in,out] domid Pointer to domain ID of the new domain.
* @param config Pointer to a structure containing the configuration for the new domain.
* @return 0 on success, or a negative error code on failure.
*/
int xen_domctl_createdomain(int domid, struct xen_domctl_createdomain *config);
int xen_domctl_createdomain(int *domid, struct xen_domctl_createdomain *config);

/**
* @brief Clean and invalidate caches associated with given region of
Expand Down

0 comments on commit 20a5306

Please sign in to comment.