Ian Jackson
2010-Jul-29 17:31 UTC
[Xen-devel] [PATCH 1/2] libxl: const-correctness for libxl_uuid2string
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
tools/libxl/libxl.h | 2 +-
tools/libxl/libxl_dom.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 191d1e1..3391491 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -360,7 +360,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
libxl_device_disk *disk,
uint32_t domid);
-char *libxl_uuid2string(libxl_ctx *ctx, uint8_t uuid[16]);
+char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]);
/* 0 means ERROR_ENOMEM, which we have logged */
/* events handling */
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index b7ee27c..20a16e6 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -427,7 +427,7 @@ int save_device_model(libxl_ctx *ctx, uint32_t domid, int
fd)
return 0;
}
-char *libxl_uuid2string(libxl_ctx *ctx, uint8_t uuid[16]) {
+char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]) {
char *s = string_of_uuid(ctx, uuid);
if (!s) XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate for uuid");
return s;
--
1.5.6.5
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
xm list takes an optional domain argument; make xl list do likewise.
This also gets rid of a small amount of code which was duplicated
between list_domains and list_domains_details.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
tools/libxl/xl_cmdimpl.c | 56 ++++++++++++++++++++++++++++------------------
1 files changed, 34 insertions(+), 22 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 6a1ae0a..1fc9c14 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2094,22 +2094,15 @@ void reboot_domain(char *p)
if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n.",rc);exit(-1);
}
}
-void list_domains_details(void)
+void list_domains_details(const libxl_dominfo *info, int nb_domain)
{
- libxl_dominfo *info;
struct domain_config d_config;
char *config_file;
uint8_t *data;
- int nb_domain, i, len, rc;
+ int i, len, rc;
libxl_device_model_info dm_info;
- info = libxl_list_domain(&ctx, &nb_domain);
-
- if (!info) {
- fprintf(stderr, "libxl_domain_infolist failed.\n");
- exit(1);
- }
for (i = 0; i < nb_domain; i++) {
rc = libxl_userdata_retrieve(&ctx, info[i].domid, "xl",
&data, &len);
if (rc)
@@ -2121,20 +2114,12 @@ void list_domains_details(void)
free(data);
free(config_file);
}
- free(info);
}
-void list_domains(int verbose)
+void list_domains(int verbose, const libxl_dominfo *info, int nb_domain)
{
- libxl_dominfo *info;
- int nb_domain, i;
-
- info = libxl_list_domain(&ctx, &nb_domain);
+ int i;
- if (!info) {
- fprintf(stderr, "libxl_domain_infolist failed.\n");
- exit(1);
- }
printf("Name ID Mem
VCPUs\tState\tTime(s)\n");
for (i = 0; i < nb_domain; i++) {
printf("%-40s %5d %5lu %5d %c%c%c%c%c%c %8.1f",
@@ -2155,7 +2140,6 @@ void list_domains(int verbose)
}
putchar(''\n'');
}
- free(info);
}
void list_vm(void)
@@ -2960,6 +2944,10 @@ int main_list(int argc, char **argv)
{0, 0, 0, 0}
};
+ libxl_dominfo info_buf;
+ libxl_dominfo *info, *info_free=0;
+ int nb_domain, rc;
+
while (1) {
opt = getopt_long(argc, argv, "lvh", long_options,
&option_index);
if (opt == -1)
@@ -2981,10 +2969,34 @@ int main_list(int argc, char **argv)
}
}
+ if (optind >= argc) {
+ info = libxl_list_domain(&ctx, &nb_domain);
+ if (!info) {
+ fprintf(stderr, "libxl_domain_infolist failed.\n");
+ exit(1);
+ }
+ info_free = info;
+ } else if (optind == argc-1) {
+ find_domain(argv[optind]);
+ rc = libxl_domain_info(&ctx, &info_buf, domid);
+ if (rc) {
+ fprintf(stderr, "libxl_domain_info failed (code %d).\n",
rc);
+ exit(-rc);
+ }
+ info = &info_buf;
+ nb_domain = 1;
+ } else {
+ help("list");
+ exit(2);
+ }
+
if (details)
- list_domains_details();
+ list_domains_details(info, nb_domain);
else
- list_domains(verbose);
+ list_domains(verbose, info, nb_domain);
+
+ free(info_free);
+
exit(0);
}
--
1.5.6.5
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2010-Jul-30 13:50 UTC
Re: [Xen-devel] [PATCH 1/2] libxl: const-correctness for libxl_uuid2string
On Thu, 2010-07-29 at 18:31 +0100, Ian Jackson wrote:> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>Looks ok to me. Acked-by: Ian Campbell <ian.campbell@citrix.com>> --- > tools/libxl/libxl.h | 2 +- > tools/libxl/libxl_dom.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h > index 191d1e1..3391491 100644 > --- a/tools/libxl/libxl.h > +++ b/tools/libxl/libxl.h > @@ -360,7 +360,7 @@ int libxl_run_bootloader(libxl_ctx *ctx, > libxl_device_disk *disk, > uint32_t domid); > > -char *libxl_uuid2string(libxl_ctx *ctx, uint8_t uuid[16]); > +char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]); > /* 0 means ERROR_ENOMEM, which we have logged */ > > /* events handling */ > diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c > index b7ee27c..20a16e6 100644 > --- a/tools/libxl/libxl_dom.c > +++ b/tools/libxl/libxl_dom.c > @@ -427,7 +427,7 @@ int save_device_model(libxl_ctx *ctx, uint32_t domid, int fd) > return 0; > } > > -char *libxl_uuid2string(libxl_ctx *ctx, uint8_t uuid[16]) { > +char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]) { > char *s = string_of_uuid(ctx, uuid); > if (!s) XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate for uuid"); > return s;_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2010-Jul-30 13:51 UTC
Re: [Xen-devel] [PATCH 2/2] xl: support "xl list <domain>"
On Thu, 2010-07-29 at 18:31 +0100, Ian Jackson wrote:> xm list takes an optional domain argument; make xl list do likewise. > This also gets rid of a small amount of code which was duplicated > between list_domains and list_domains_details. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>I think I implicitly tested this as part of testing my own series from earlier today, and it looks ok to me, so: Acked-by: Ian Campbell <ian.campbell@citrix.com>> --- > tools/libxl/xl_cmdimpl.c | 56 ++++++++++++++++++++++++++++------------------ > 1 files changed, 34 insertions(+), 22 deletions(-) > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 6a1ae0a..1fc9c14 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -2094,22 +2094,15 @@ void reboot_domain(char *p) > if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n.",rc);exit(-1); } > } > > -void list_domains_details(void) > +void list_domains_details(const libxl_dominfo *info, int nb_domain) > { > - libxl_dominfo *info; > struct domain_config d_config; > > char *config_file; > uint8_t *data; > - int nb_domain, i, len, rc; > + int i, len, rc; > libxl_device_model_info dm_info; > > - info = libxl_list_domain(&ctx, &nb_domain); > - > - if (!info) { > - fprintf(stderr, "libxl_domain_infolist failed.\n"); > - exit(1); > - } > for (i = 0; i < nb_domain; i++) { > rc = libxl_userdata_retrieve(&ctx, info[i].domid, "xl", &data, &len); > if (rc) > @@ -2121,20 +2114,12 @@ void list_domains_details(void) > free(data); > free(config_file); > } > - free(info); > } > > -void list_domains(int verbose) > +void list_domains(int verbose, const libxl_dominfo *info, int nb_domain) > { > - libxl_dominfo *info; > - int nb_domain, i; > - > - info = libxl_list_domain(&ctx, &nb_domain); > + int i; > > - if (!info) { > - fprintf(stderr, "libxl_domain_infolist failed.\n"); > - exit(1); > - } > printf("Name ID Mem VCPUs\tState\tTime(s)\n"); > for (i = 0; i < nb_domain; i++) { > printf("%-40s %5d %5lu %5d %c%c%c%c%c%c %8.1f", > @@ -2155,7 +2140,6 @@ void list_domains(int verbose) > } > putchar(''\n''); > } > - free(info); > } > > void list_vm(void) > @@ -2960,6 +2944,10 @@ int main_list(int argc, char **argv) > {0, 0, 0, 0} > }; > > + libxl_dominfo info_buf; > + libxl_dominfo *info, *info_free=0; > + int nb_domain, rc; > + > while (1) { > opt = getopt_long(argc, argv, "lvh", long_options, &option_index); > if (opt == -1) > @@ -2981,10 +2969,34 @@ int main_list(int argc, char **argv) > } > } > > + if (optind >= argc) { > + info = libxl_list_domain(&ctx, &nb_domain); > + if (!info) { > + fprintf(stderr, "libxl_domain_infolist failed.\n"); > + exit(1); > + } > + info_free = info; > + } else if (optind == argc-1) { > + find_domain(argv[optind]); > + rc = libxl_domain_info(&ctx, &info_buf, domid); > + if (rc) { > + fprintf(stderr, "libxl_domain_info failed (code %d).\n", rc); > + exit(-rc); > + } > + info = &info_buf; > + nb_domain = 1; > + } else { > + help("list"); > + exit(2); > + } > + > if (details) > - list_domains_details(); > + list_domains_details(info, nb_domain); > else > - list_domains(verbose); > + list_domains(verbose, info, nb_domain); > + > + free(info_free); > + > exit(0); > } >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel