]> xenbits.xensource.com Git - xen.git/commitdiff
xl: Some small fixes
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 26 May 2010 07:13:47 +0000 (08:13 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 26 May 2010 07:13:47 +0000 (08:13 +0100)
- 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 <yanghy@cn.fujitsu.com>
tools/libxl/libxl.c
tools/libxl/xl_cmdimpl.c
tools/libxl/xl_cmdtable.c

index 2861d3ffe9ea7e3a1d5889fb4a31d88faad5e250..f988833bf0212cd81acd533bd5547c9ca631241e 100644 (file)
@@ -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;
         }
index 729d5c998bbbd989c87b41bb11066e6e65625ff6..0fe6be9116944025bc15add792ebc4d043e6b6ce 100644 (file)
@@ -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;
index 22c3feada125d7ae24c43d12d7239b4144360011..feda1f9c92e76707835ad8b1564dad9aa3628ae1 100644 (file)
@@ -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)",
-      "<Domain> <MemKB>",
+      "Set the maximum amount reservation for a domain",
+      "<Domain> <MemKB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>",
     },
     { "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)",
-      "<Domain> <MemKB>",
+      "Set the current memory usage for a domain",
+      "<Domain> <MemKB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>",
     },
     { "button-press",
       &main_button_press,