[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] xl: Add "xl domname" command, a clone of "xm domname".
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1273221081 -3600 # Node ID 9a289224efeacf6c0dadf7a7a2591ebdc68e9415 # Parent 311eb39e96496db80f5289450bd7d9ecfc7bfdbb xl: Add "xl domname" command, a clone of "xm domname". Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx> --- tools/libxl/xl_cmdimpl.c | 43 +++++++++++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdimpl.h | 1 + tools/libxl/xl_cmdtable.c | 1 + 3 files changed, 45 insertions(+) diff -r 311eb39e9649 -r 9a289224efea tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Fri May 07 09:30:56 2010 +0100 +++ b/tools/libxl/xl_cmdimpl.c Fri May 07 09:31:21 2010 +0100 @@ -1240,6 +1240,9 @@ void help(char *command) } else if (!strcmp(command, "domid")) { printf("Usage: xl domid <DomainName>\n\n"); printf("Convert a domain name to domain id.\n"); + } else if (!strcmp(command, "domname")) { + printf("Usage: xl domname <DomainId>\n\n"); + printf("Convert a domain id to domain name.\n"); } } @@ -2997,3 +3000,43 @@ int main_domid(int argc, char **argv) exit(0); } + +int main_domname(int argc, char **argv) +{ + int opt; + char *domname = NULL; + char *endptr = NULL; + + while ((opt = getopt(argc, argv, "h")) != -1) { + switch (opt) { + case 'h': + help("domname"); + exit(0); + default: + fprintf(stderr, "option `%c' not supported.\n", opt); + break; + } + } + + if (!argv[optind]) { + fprintf(stderr, "Must specify a domain id.\n\n"); + help("domname"); + exit(1); + } + domid = strtol(argv[optind], &endptr, 10); + if (domid == 0 && !strcmp(endptr, argv[optind])) { + /*no digits at all*/ + fprintf(stderr, "Invalid domain id.\n\n"); + exit(1); + } + + domname = libxl_domid_to_name(&ctx, domid); + if (!domname) { + fprintf(stderr, "Can't get domain name of domain id '%d', maybe this domain does not exist.\n", domid); + exit(1); + } + + printf("%s\n", domname); + + exit(0); +} diff -r 311eb39e9649 -r 9a289224efea tools/libxl/xl_cmdimpl.h --- a/tools/libxl/xl_cmdimpl.h Fri May 07 09:30:56 2010 +0100 +++ b/tools/libxl/xl_cmdimpl.h Fri May 07 09:31:21 2010 +0100 @@ -36,5 +36,6 @@ int main_memset(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); +int main_domname(int argc, char **argv); void help(char *command); diff -r 311eb39e9649 -r 9a289224efea tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Fri May 07 09:30:56 2010 +0100 +++ b/tools/libxl/xl_cmdtable.c Fri May 07 09:31:21 2010 +0100 @@ -37,6 +37,7 @@ struct cmd_spec cmd_table[] = { { "info", &main_info, "get information about Xen host" }, { "sched-credit", &main_sched_credit, "get/set credit scheduler parameters" }, { "domid", &main_domid, "convert a domain name to domain id"}, + { "domname", &main_domname, "convert a domain id to domain name"}, }; int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |