Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xen-dom-mgmt: do not left domain paused on creation #86

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xen-dom-mgmt/include/domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ struct xen_domain_cfg {
void *image_info;

struct backend_configuration back_cfg;

bool f_paused:1; /**< Domain should remain paused after creation */
};

struct xen_domain_console {
Expand Down
6 changes: 1 addition & 5 deletions xen-dom-mgmt/src/xen-dom-mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ struct modules_address {
* This variable used during shell command execution, thus requires no sync. */
static int dom_num = 0;

#define DOMID_DOMD 1

/* Define major and minor versions if was not provided */
#ifndef XEN_VERSION_MAJOR
#define XEN_VERSION_MAJOR 4
Expand Down Expand Up @@ -777,14 +775,12 @@ int domain_create(struct xen_domain_cfg *domcfg, uint32_t domid)
goto stop_domain_console;
}

if (domid == DOMID_DOMD) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you can drop DOMID_DOMD now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

if (!domcfg->f_paused) {
rc = xen_domctl_unpausedomain(domid);
if (rc) {
LOG_ERR("Failed to unpause domain#%u (rc=%d)", domid, rc);
goto stop_domain_console;
}
} else {
LOG_INF("Created domain is paused\nTo unpause issue: xu unpause %u", domid);
}

k_mutex_lock(&dl_mutex, K_FOREVER);
Expand Down
18 changes: 16 additions & 2 deletions xen-shell-cmd/src/xen_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ uint32_t parse_domid(size_t argc, char **argv)
return 0;
}

void parse_and_fill_flags(size_t argc, char **argv, struct xen_domain_cfg *cfg)
{
int i;

for (i = 0; i < argc; i++) {
/* check if domain should remain paused after creation */
if (argv[i][0] == '-' && argv[i][1] == 'p') {
cfg->f_paused = 1;
}
}
}

static int domu_create(const struct shell *shell, int argc, char **argv)
{
int ret;
Expand All @@ -57,6 +69,8 @@ static int domu_create(const struct shell *shell, int argc, char **argv)
return -EINVAL;
}

parse_and_fill_flags(argc, argv, cfg);

ret = domain_create(cfg, domid);
if (ret < 0) {
return ret; /* domain_create should care about error logs */
Expand Down Expand Up @@ -165,8 +179,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
subcmd_xu,
SHELL_CMD_ARG(create, NULL,
" Create Xen domain\n"
" Usage: create cfg_name [-d <domid>]\n",
domu_create, 2, 2),
" Usage: create cfg_name [-d <domid>] [-p]\n",
domu_create, 2, 3),
SHELL_CMD_ARG(destroy, NULL,
" Destroy Xen domain\n"
" Usage: destroy <domid>\n",
Expand Down