diff --git a/xen-dom-mgmt/src/xen-dom-mgmt.c b/xen-dom-mgmt/src/xen-dom-mgmt.c index 44bd4b56..641fa963 100644 --- a/xen-dom-mgmt/src/xen-dom-mgmt.c +++ b/xen-dom-mgmt/src/xen-dom-mgmt.c @@ -749,7 +749,7 @@ int domain_create(struct xen_domain_cfg *domcfg, uint32_t domid) goto stop_domain_console; } } else { - LOG_INF("Created domain is paused\nTo unpause issue: xu unpause -d %u", domid); + LOG_INF("Created domain is paused\nTo unpause issue: xu unpause %u", domid); } k_mutex_lock(&dl_mutex, K_FOREVER); diff --git a/xen-shell-cmd/src/xen_cmds.c b/xen-shell-cmd/src/xen_cmds.c index 28e4c70d..8b6b154b 100644 --- a/xen-shell-cmd/src/xen_cmds.c +++ b/xen-shell-cmd/src/xen_cmds.c @@ -20,12 +20,14 @@ extern struct xen_domain_cfg domd_cfg; uint32_t parse_domid(size_t argc, char **argv) { /* first would be the cmd name, start from second */ - int pos = 1; - - if (argv[pos][0] == '-' && argv[pos][1] == 'd') { - /* Take next value after "-d" option */ - pos++; - return atoi(argv[pos]); + int i; + + for (i = 0; i < argc - 1; i++) { + if (argv[i][0] == '-' && argv[i][1] == 'd') { + /* Take next value after "-d" option */ + i++; + return atoi(argv[i]); + } } /* Use zero as invalid value */ @@ -35,15 +37,14 @@ uint32_t parse_domid(size_t argc, char **argv) static int domu_create(const struct shell *shell, int argc, char **argv) { int ret; - uint32_t domid; - - if (argc != 3) - return -EINVAL; + uint32_t domid = 0; - domid = parse_domid(argc, argv); - if (!domid) { - LOG_ERR("Invalid domid passed to create cmd"); - return -EINVAL; + if (argc > 2) { + domid = parse_domid(argc, argv); + if (!domid) { + LOG_ERR("Invalid domid passed to create cmd"); + return -EINVAL; + } } /* * TODO: this should be changed in app code. @@ -61,10 +62,10 @@ int domu_destroy(const struct shell *shell, size_t argc, char **argv) { uint32_t domid = 0; - if (argc != 3) + if (argc != 2) return -EINVAL; - domid = parse_domid(argc, argv); + domid = atoi(argv[1]); if (!domid) { shell_error(shell, "Invalid domid passed to destroy cmd\n"); return -EINVAL; @@ -79,10 +80,10 @@ int domu_console_attach(const struct shell *shell, size_t argc, char **argv) uint32_t domid = 0; struct xen_domain *domain; - if (argc != 3) + if (argc != 2) return -EINVAL; - domid = parse_domid(argc, argv); + domid = atoi(argv[1]); if (!domid) { shell_error(shell, "Invalid domid passed to create cmd\n"); return -EINVAL; @@ -103,10 +104,10 @@ int domu_pause(const struct shell *shell, size_t argc, char **argv) { uint32_t domid = 0; - if (argc != 3) + if (argc != 2) return -EINVAL; - domid = parse_domid(argc, argv); + domid = atoi(argv[1]); if (!domid) { shell_error(shell, "Invalid domid passed to destroy cmd\n"); return -EINVAL; @@ -119,17 +120,15 @@ int domu_unpause(const struct shell *shell, size_t argc, char **argv) { uint32_t domid = 0; - if (argc != 3) + if (argc != 2) return -EINVAL; - domid = parse_domid(argc, argv); + domid = atoi(argv[1]); if (!domid) { shell_error(shell, "Invalid domid passed to unpause cmd\n"); return -EINVAL; } - shell_print(shell, "domid=%d\n", domid); - return domain_unpause(domid); } @@ -137,26 +136,26 @@ SHELL_STATIC_SUBCMD_SET_CREATE( subcmd_xu, SHELL_CMD_ARG(create, NULL, " Create Xen domain\n" - " Usage: create -d \n", - domu_create, 3, 0), + " Usage: create [-d ]\n", + domu_create, 1, 2), SHELL_CMD_ARG(destroy, NULL, " Destroy Xen domain\n" - " Usage: destroy -d \n", - domu_destroy, 3, 0), + " Usage: destroy \n", + domu_destroy, 2, 0), SHELL_CMD_ARG(pause, NULL, " Pause Xen domain\n" - " Usage: pause -d \n", - domu_pause, 3, 0), + " Usage: pause \n", + domu_pause, 2, 0), SHELL_CMD_ARG(unpause, NULL, " Unpause Xen domain\n" - " Usage: unpause -d \n", - domu_unpause, 3, 0), + " Usage: unpause \n", + domu_unpause, 2, 0), #ifdef CONFIG_XEN_CONSOLE_SRV - SHELL_CMD_ARG(console_attach, NULL, + SHELL_CMD_ARG(console, NULL, " Attach to a domain console.\n" " Press CTRL+] to detach from console\n" - " Usage: console_attach -d \n", - domu_console_attach, 3, 0), + " Usage: console \n", + domu_console_attach, 2, 0), #endif SHELL_SUBCMD_SET_END);