libxl: const-correctness for libxl_uuid2string
PATCH 1/2 libxl: const-correctness for libxl_uuid2string
Signed-off-by Ian Jackson <[email protected]>
--- tools/libxl/libxl.h | 2 +- tools/libxl/libxl_dom.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl.h +1 -1
@@ -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 */
tools/libxl/libxl_dom.c +1 -1
@@ -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;
Signature · 1 line
1.5.6.5
PATCH 2/2 xl: support "xl list <domain>"
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 <[email protected]>
--- tools/libxl/xl_cmdimpl.c | 56 ++++++++++++++++++++++++++++------------------ 1 files changed, 34 insertions(+), 22 deletions(-)
tools/libxl/xl_cmdimpl.c +34 -22
@@ -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 ); }
Signature · 1 line
1.5.6.5
Re: [PATCH 2/2] xl: support "xl list <domain>"
Quoted 5 lines · Ian Jackson
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_domainsandlist_domains_details.Signed-off-by Ian Jackson <[email protected]>
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 <[email protected]>
Quoted 112 lines
--- tools/libxl/xl_cmdimpl.c | 56 ++++++++++++++++++++++++++++------------------ 1 files changed, 34 insertions(+), 22 deletions(-)tools/libxl/xl_cmdimpl.c +34
-22@@ -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 ); }
Quoted 1 line · Ian Jackson
Signed-off-by Ian Jackson <[email protected]>
Looks ok to me.
Acked-by Ian Campbell <[email protected]>
Quoted 31 lines
--- tools/libxl/libxl.h | 2 +- tools/libxl/libxl_dom.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/libxl/libxl.h +1
-1@@ -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 */ tools/libxl/libxl_dom.c +1
-1@@ -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;