Skip to content

Commit

Permalink
xen-dom-mgmt: Use correct domid for domain_post_create
Browse files Browse the repository at this point in the history
Currently, when domid auto allocation is used, we pass 0 to
domain_post_create, causing it to fail. Fix this by returning the
allocated domid from domain_create and passing it to domain_post_create.

Signed-off-by: Mykyta Poturai <[email protected]>
Reviewed-by: Dmytro Firsov <[email protected]>
Reviewed-by: Grygorii Strashko <[email protected]>
  • Loading branch information
Deedone committed May 14, 2024
1 parent 531d52b commit 3e5ac59
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion xen-dom-mgmt/include/xen_dom_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern "C" {
*
* @param domcfg The configuration for the new domain.
* @param domid The ID of the new domain.
* @return 0 on success, or an error code on failure.
* @return domid on success, or a negative error code on failure.
*/
int domain_create(struct xen_domain_cfg *domcfg, uint32_t domid);

Expand Down
5 changes: 4 additions & 1 deletion xen-dom-mgmt/src/xen-dom-mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,10 @@ int domain_create(struct xen_domain_cfg *domcfg, uint32_t domid)
++dom_num;
k_mutex_unlock(&dl_mutex);

return rc;
if (rc) {
return rc;
}
return domid;

stop_domain_console:
#ifdef CONFIG_XEN_CONSOLE_SRV
Expand Down
4 changes: 2 additions & 2 deletions xen-shell-cmd/src/xen_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ static int domu_create(const struct shell *shell, int argc, char **argv)
}

ret = domain_create(cfg, domid);
if (ret) {
if (ret < 0) {
return ret; /* domain_create should care about error logs */
}

return domain_post_create(cfg, domid);
return domain_post_create(cfg, ret);
}

int domu_destroy(const struct shell *shell, size_t argc, char **argv)
Expand Down

0 comments on commit 3e5ac59

Please sign in to comment.