WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH]xl: Some small fixes to xl

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH]xl: Some small fixes to xl
From: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
Date: Wed, 26 May 2010 08:55:10 +0800
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 25 May 2010 17:53:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C81C5690.14E00%keir.fraser@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C81C5690.14E00%keir.fraser@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4
The patch fixes following problems:
-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's 
also
 breaks bash completion, fix it.

Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx> 

diff -r 93410e5e4ad8 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Sat May 22 06:36:41 2010 +0100
+++ b/tools/libxl/libxl.c       Wed May 26 08:54:39 2010 +0800
@@ -2531,7 +2531,7 @@
         }
 
         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 -r 93410e5e4ad8 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Sat May 22 06:36:41 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed May 26 08:54:39 2010 +0800
@@ -3644,7 +3644,8 @@
     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)
@@ -3661,9 +3662,10 @@
 
     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
     {
@@ -3672,6 +3674,8 @@
                0, uptime_str);
     }
 
+    if (now_str)
+        free(now_str);
     if (uptime_str)
         free(uptime_str);
     return;
@@ -3684,7 +3688,8 @@
 {
     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)
@@ -3692,9 +3697,10 @@
     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
     {
@@ -3703,6 +3709,8 @@
                domuid, uptime_str);
     }
 
+    if (now_str)
+        free(now_str);
     if (uptime_str)
         free(uptime_str);
     return;
diff -r 93410e5e4ad8 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Sat May 22 06:36:41 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Wed May 26 08:54:39 2010 +0800
@@ -110,17 +110,13 @@
     },
     { "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,

-- 
Regards
Yang Hongyang

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel