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]>
  • Loading branch information
Deedone committed Apr 29, 2024
1 parent f051267 commit 0d371f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 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
2 changes: 1 addition & 1 deletion include/zephyr/xen/dom0/domctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int xen_domctl_assign_dt_device(int domid, char *dtdev_path);
int xen_domctl_bind_pt_irq(int domid, uint32_t machine_irq, uint8_t irq_type, uint8_t bus,
uint8_t device, uint8_t intx, uint8_t isa_irq, uint16_t spi);
int xen_domctl_max_vcpus(int domid, int max_vcpus);
int xen_domctl_createdomain(int domid, struct xen_domctl_createdomain *config);
int xen_domctl_createdomain(int *domid, struct xen_domctl_createdomain *config);
int xen_domctl_cacheflush(int domid, struct xen_domctl_cacheflush *cacheflush);
int xen_domctl_destroydomain(int domid);
int xen_domctl_getvcpu(int domid, uint32_t vcpu, struct xen_domctl_getvcpuinfo *info);
Expand Down

0 comments on commit 0d371f9

Please sign in to comment.