From: Keir Fraser Date: Wed, 26 May 2010 07:13:47 +0000 (+0100) Subject: xl: Some small fixes X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12085 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a8ad76437ed5fa7e17df49da17d4214484b85a96;p=xen.git xl: Some small fixes - When use mem-set, I got suspicious error output: # xl mem-set 1 256g setting domid 1 memory to : 268435456 [0] libxl.c:2535:libxl_set_memory_target: memory_dynamic_max must be less than or equal to memory_static_max : Success - String generated by strdup() should be freed - When using 'xl help', mem-max and mem-set's output is not as intend, and it also breaks bash completion, fix it. Signed-off-by: Yang Hongyang --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 2861d3ffe9..f988833bf0 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2531,7 +2531,7 @@ int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t targ } if (target_memkb > memorykb) { - XL_LOG_ERRNO(ctx, XL_LOG_ERROR, + XL_LOG(ctx, XL_LOG_ERROR, "memory_dynamic_max must be less than or equal to memory_static_max\n"); return 1; } diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 729d5c998b..0fe6be9116 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3678,7 +3678,8 @@ static void print_dom0_uptime(int short_mode, time_t now) int fd; char buf[512]; uint32_t uptime = 0; - char *uptime_str = 0; + char *uptime_str = NULL; + char *now_str = NULL; fd = open("/proc/uptime", O_RDONLY); if (fd == -1) @@ -3695,9 +3696,10 @@ static void print_dom0_uptime(int short_mode, time_t now) if (short_mode) { + now_str = current_time_to_string(now); uptime_str = uptime_to_string(uptime, 1); - printf(" %s up %s, %s (%d)\n", current_time_to_string(now), - uptime_str, libxl_domid_to_name(&ctx, 0), 0); + printf(" %s up %s, %s (%d)\n", now_str, uptime_str, + libxl_domid_to_name(&ctx, 0), 0); } else { @@ -3706,6 +3708,8 @@ static void print_dom0_uptime(int short_mode, time_t now) 0, uptime_str); } + if (now_str) + free(now_str); if (uptime_str) free(uptime_str); return; @@ -3718,7 +3722,8 @@ static void print_domU_uptime(uint32_t domuid, int short_mode, time_t now) { uint32_t s_time = 0; uint32_t uptime = 0; - char *uptime_str = 0; + char *uptime_str = NULL; + char *now_str = NULL; s_time = libxl_vm_get_start_time(&ctx, domuid); if (s_time == -1) @@ -3726,9 +3731,10 @@ static void print_domU_uptime(uint32_t domuid, int short_mode, time_t now) uptime = now - s_time; if (short_mode) { + now_str = current_time_to_string(now); uptime_str = uptime_to_string(uptime, 1); - printf(" %s up %s, %s (%d)\n", current_time_to_string(now), - uptime_str, libxl_domid_to_name(&ctx, domuid), domuid); + printf(" %s up %s, %s (%d)\n", now_str, uptime_str, + libxl_domid_to_name(&ctx, domuid), domuid); } else { @@ -3737,6 +3743,8 @@ static void print_domU_uptime(uint32_t domuid, int short_mode, time_t now) domuid, uptime_str); } + if (now_str) + free(now_str); if (uptime_str) free(uptime_str); return; diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 22c3feada1..feda1f9c92 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -110,17 +110,13 @@ struct cmd_spec cmd_table[] = { }, { "mem-max", &main_memmax, - "Set the maximum amount reservation for a domain.\n" - "Units default to kilobytes, but can be suffixed with\n" - "'b' (bytes), 'k' (KB), 'm' (MB), 'g' (GB) or 't' (TB)", - " ", + "Set the maximum amount reservation for a domain", + " ", }, { "mem-set", &main_memset, - "Set the current memory usage for a domain.\n" - "Units default to kilobytes, but can be suffixed with\n" - "'b' (bytes), 'k' (KB), 'm' (MB), 'g' (GB) or 't' (TB)", - " ", + "Set the current memory usage for a domain", + " ", }, { "button-press", &main_button_press,