lxc-clone ignores size subfixes (K, M, G) when using -L parameter. The
following is a quick patch to allow, for example, lxc-clone -L 10G.

Signed-off-by: Norberto Bensa <nbe...@gmail.com>
Acked-by: Serge E. Hallyn <serge.hal...@ubuntu.com>

--- lxc.orig/lxc-0.9.0.0~staging~20130708-2041/src/lxc/lxc_clone.c
 2013-07-08 17:46:33.000000000 -0300
+++ lxc.new/lxc-0.9.0.0~staging~20130708-2041/src/lxc/lxc_clone.c
 2013-07-10 23:06:07.156501219 -0300
@@ -6,6 +6,7 @@
 #include <sys/wait.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <ctype.h>

 #include "log.h"
 #include "config.h"
@@ -16,6 +17,27 @@

 lxc_log_define(lxc_clone, lxc);

+static unsigned long get_fssize(char *s)
+{
+       unsigned long ret;
+       char *end;
+
+       ret = strtoul(s, &end, 0);
+       if (end == s)
+               return 0;
+       while (isblank(*end))
+               end++;
+       if (!(*end))
+               return ret;
+       if (*end == 'g' || *end == 'G')
+               ret *= 1000000000;
+       else if (*end == 'm' || *end == 'M')
+               ret *= 1000000;
+       else if (*end == 'k' || *end == 'K')
+               ret *= 1000;
+       return ret;
+}
+
 void usage(const char *me)
 {
        printf("Usage: %s [-s] [-B backingstore] [-L size] [-K] [-M]
[-H]\n", me);
@@ -73,7 +95,7 @@
                switch (c) {
                case 's': snapshot = 1; break;
                case 'B': bdevtype = optarg; break;
-               case 'L': newsize = atol(optarg); break;
+               case 'L': newsize = get_fssize(optarg); break;
                case 'o': orig = optarg; break;
                case 'n': new = optarg; break;
                case 'v': vgname = optarg; break;

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users

Reply via email to