diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-05-07 09:30:56 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-05-07 09:30:56 +0100 |
commit | 8a3067e096ca3aedc358b60ade44a885b0d459ec (patch) | |
tree | 5031319448638e812aabef784bb9349fe7902db1 | |
parent | ac56b9955e2729994dac07b74aec7a4f5d284660 (diff) | |
download | xen-8a3067e096ca3aedc358b60ade44a885b0d459ec.tar.gz xen-8a3067e096ca3aedc358b60ade44a885b0d459ec.tar.bz2 xen-8a3067e096ca3aedc358b60ade44a885b0d459ec.zip |
xl: Add "xl domid" command, a clone of "xm domid".
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
-rw-r--r-- | tools/libxl/xl_cmdimpl.c | 36 | ||||
-rw-r--r-- | tools/libxl/xl_cmdimpl.h | 1 | ||||
-rw-r--r-- | tools/libxl/xl_cmdtable.c | 3 |
3 files changed, 39 insertions, 1 deletions
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 6fc5e1ebbf..f3a4342ec3 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1237,6 +1237,9 @@ void help(char *command) printf(" -d DOMAIN, --domain=DOMAIN Domain to modify\n"); printf(" -w WEIGHT, --weight=WEIGHT Weight (int)\n"); printf(" -c CAP, --cap=CAP Cap (int)\n"); + } else if (!strcmp(command, "domid")) { + printf("Usage: xl domid <DomainName>\n\n"); + printf("Convert a domain name to domain id.\n"); } } @@ -2961,3 +2964,36 @@ int main_sched_credit(int argc, char **argv) exit(0); } + +int main_domid(int argc, char **argv) +{ + int opt; + char *domname = NULL; + + while ((opt = getopt(argc, argv, "h")) != -1) { + switch (opt) { + case 'h': + help("domid"); + exit(0); + default: + fprintf(stderr, "option `%c' not supported.\n", opt); + break; + } + } + + domname = argv[optind]; + if (!domname) { + fprintf(stderr, "Must specify a domain name.\n\n"); + help("domid"); + exit(1); + } + + if (libxl_name_to_domid(&ctx, domname, &domid)) { + fprintf(stderr, "Can't get domid of domain name '%s', maybe this domain does not exist.\n", domname); + exit(1); + } + + printf("%d\n", domid); + + exit(0); +} diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h index b809d65397..6fbcf45a61 100644 --- a/tools/libxl/xl_cmdimpl.h +++ b/tools/libxl/xl_cmdimpl.h @@ -35,5 +35,6 @@ int main_vcpupin(int argc, char **argv); int main_vcpuset(int argc, char **argv); int main_memset(int argc, char **argv); int main_sched_credit(int argc, char **argv); +int main_domid(int argc, char **argv); void help(char *command); diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index eb420aa4af..e15db0ddd3 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -35,7 +35,8 @@ struct cmd_spec cmd_table[] = { { "vcpu-set", &main_vcpuset, "set the number of active VCPUs allowed for the domain" }, { "list-vm", &main_list_vm, "list the VMs,without DOM0" }, { "info", &main_info, "get information about Xen host" }, - { "sched-credit", &main_sched_credit, "get/set credit scheduler parameters" } + { "sched-credit", &main_sched_credit, "get/set credit scheduler parameters" }, + { "domid", &main_domid, "convert a domain name to domain id"}, }; int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec); |