[lxc-devel] [PATCH] lxc-create: do not use 'local'

2012-11-26 Thread Natanael Copa
Apparently 'local' is not POSIX. Don't use it.

Signed-off-by: Natanael Copa 
---
 src/lxc/lxc-create.in | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
index 26ec6a2..30f0c22 100644
--- a/src/lxc/lxc-create.in
+++ b/src/lxc/lxc-create.in
@@ -68,9 +68,8 @@ usage_err() {
 }
 
 optarg_check() {
-local opt="$1" optarg="$2"
-if [ -z "$optarg" ]; then
-usage_err "option '$opt' requires an argument"
+if [ -z "$2" ]; then
+usage_err "option '$1' requires an argument"
 fi
 }
 
@@ -84,7 +83,7 @@ vgname=lxc
 custom_rootfs=""
 
 while [ $# -gt 0 ]; do
-local opt="$1"
+opt="$1"
 shift
 case "$opt" in
-h|--help)
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] lxc-create: do not use 'local'

2012-11-26 Thread Stéphane Graber
On 11/26/2012 06:00 AM, Natanael Copa wrote:
> Apparently 'local' is not POSIX. Don't use it.
> 
> Signed-off-by: Natanael Copa 

Acked-by: Stéphane Graber 

Applied to staging branch. Thanks.

> ---
>  src/lxc/lxc-create.in | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
> index 26ec6a2..30f0c22 100644
> --- a/src/lxc/lxc-create.in
> +++ b/src/lxc/lxc-create.in
> @@ -68,9 +68,8 @@ usage_err() {
>  }
>  
>  optarg_check() {
> -local opt="$1" optarg="$2"
> -if [ -z "$optarg" ]; then
> -usage_err "option '$opt' requires an argument"
> +if [ -z "$2" ]; then
> +usage_err "option '$1' requires an argument"
>  fi
>  }
>  
> @@ -84,7 +83,7 @@ vgname=lxc
>  custom_rootfs=""
>  
>  while [ $# -gt 0 ]; do
> -local opt="$1"
> +opt="$1"
>  shift
>  case "$opt" in
>   -h|--help)
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] lxc-create: fix passing over first argument to template script

2012-11-26 Thread Stéphane Graber
On 11/22/2012 08:16 AM, Natanael Copa wrote:
> The e60a8164c12d565f70071ff6b32b823dd495df9e introduced a bug that caused
> first argument passed over to the template script get lost.
> 
> This patch fixes it.
> 
> Signed-off-by: Natanael Copa 
> ---
>  src/lxc/lxc-create.in | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
> index e8056e9..26ec6a2 100644
> --- a/src/lxc/lxc-create.in
> +++ b/src/lxc/lxc-create.in
> @@ -137,7 +137,6 @@ while [ $# -gt 0 ]; do
>   shift
>   ;;
>  --)
> - shift
>   break;;
>   -?)
>   usage_err "unknown option '$opt'"
> 

Acked-by: Stéphane Graber 

Applied to staging branch. Thanks.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH 1/2] python: Add add_device() function

2012-11-26 Thread Stéphane Graber
On 11/23/2012 03:19 PM, Serge Hallyn wrote:
> Quoting Stéphane Graber (stgra...@ubuntu.com):
>>> The cgroup tweaking should be done using generic code.  Maybe it's
>>> time to add those to the c api...
>>
>> Totally agreed, I was actually going to nag you again this cycle about
>> getting a set_cgroup_item() and get_cgroup_item() function in the API so
>> I can remove all that ugly code from the python wrapper :)
> 
> Won't get to it today so I've added that as a blueprint item so I don't
> forget.
> 
> Meanwhile,
> 
> Acked-by: Serge E. Hallyn 
> 
> to your patch as it'll get people using it and telling us what changes
> they might want.
> 
> -serge
> 

Thanks, pushed to staging.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Add lxc.autodev (v2)

2012-11-26 Thread Stéphane Graber
On 11/23/2012 03:16 PM, Serge Hallyn wrote:
> Add a container config option to mount and populate /dev in a container.
> 
> We might want to add options to specify a max size for /dev other than
> the default 100k, and to specify other devices to create.  And maybe
> someone can think of a better name than autodev.
> 
> Changelog: Don't error out if we couldn't mknod a /dev/ttyN.
> Changelog: Describe the option in lxc.conf manpage.
> 
> Signed-off-by: Serge Hallyn 

Acked-by: Stéphane Graber 

I'll push the fix I highlighted below too.

This change is now in the staging branch.

Thanks

> ---
>  doc/lxc.conf.sgml.in |   25 
>  src/lxc/conf.c   |   77 
> ++
>  src/lxc/conf.h   |1 +
>  src/lxc/confile.c|   12 
>  4 files changed, 115 insertions(+)
> 
> diff --git a/doc/lxc.conf.sgml.in b/doc/lxc.conf.sgml.in
> index 6c3d7b2..eed07fc 100644
> --- a/doc/lxc.conf.sgml.in
> +++ b/doc/lxc.conf.sgml.in
> @@ -502,6 +502,31 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
> 02111-1307 USA
>  
>  
>  
> +  /dev directory
> +  
> + By default, lxc does nothing with the container's
> + /dev.  This allows the container's
> + /dev to be set up as needed in the container
> + rootfs.  If lxc.autodev is to 1, then after mounting the container's

Should be "If lxc.autodev is set to 1"

> + rootfs LXC will mount a fresh tmpfs under /dev
> + (limited to 100k) and fill in a minimal set of initial devices.
> +  
> +  
> + 
> +   
> + lxc.autodev
> +   
> +   
> + 
> +   Set this to 1 to have LXC mount and populate a minimal
> +   /dev when starting the container.
> + 
> +   
> + 
> +  
> +
> +
> +
>Mount points
>
>   The mount points section specifies the different places to be
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index fe574ac..f1c41f1 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -653,6 +653,15 @@ static int setup_tty(const struct lxc_rootfs *rootfs,
>   return -1;
>   }
>   } else {
> + /* If we populated /dev, then we need to create 
> /dev/ttyN */
> + if (access(path, F_OK)) {
> + ret = creat(path, 0660);
> + if (ret==-1) {
> + SYSERROR("error creating %s\n", path);
> + /* this isn't fatal, continue */
> + } else
> + close(ret);
> + }
>   if (mount(pty_info->name, path, "none", MS_BIND, 0)) {
>   WARN("failed to mount '%s'->'%s'",
>   pty_info->name, path);
> @@ -860,6 +869,67 @@ static int setup_rootfs_pivot_root(const char *rootfs, 
> const char *pivotdir)
>   return 0;
>  }
>  
> +struct lxc_devs {
> + char *name;
> + mode_t mode;
> + int maj;
> + int min;
> +};
> +
> +struct lxc_devs lxc_devs[] = {
> + { "null",   S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 3 },
> + { "zero",   S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 5 },
> + { "full",   S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 7 },
> + { "urandom",S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 9 },
> + { "random", S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 8 },
> + { "tty",S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 5, 0 },
> + { "console",S_IFCHR | S_IRUSR | S_IWUSR,   5, 1 },
> +};
> +
> +/*
> + * Do we want to add options for max size of /dev and a file to
> + * specify which devices to create?
> + */
> +static int setup_autodev(char *root)
> +{
> + int ret;
> + struct lxc_devs *d;
> + char path[MAXPATHLEN];
> + int i;
> +
> + INFO("Creating and populating /dev under %s\n", root);
> + ret = snprintf(path, MAXPATHLEN, "%s/dev", root);
> + if (ret < 0 || ret > MAXPATHLEN)
> + return -1;
> + ret = mount("none", path, "tmpfs", 0, "size=10");
> + if (ret) {
> + SYSERROR("Failed to mount /dev at %s\n", root);
> + return -1;
> + }
> + for (i = 0; i < sizeof(lxc_devs) / sizeof(lxc_devs[0]); i++) {
> + d = &lxc_devs[i];
> + ret = snprintf(path, MAXPATHLEN, "%s/dev/%s", root, d->name);
> + if (ret < 0 || ret >= MAXPATHLEN)
> + return -1;
> + ret = mknod(path, d->mode, makedev(d->maj, d->min));
> + if (ret) {
> + SYSERROR("Error creating %s\n", d->name);
> + return -1;
> + }
> + }
> + ret = snprintf(path, MAXPATHLEN, "%s/dev/pts", root);
> + if (ret < 0 || ret >= MAXPATHLEN)
> +   

[lxc-devel] [PATCH 2/3] python: Use builtin len() function for network interfaces

2012-11-26 Thread Stéphane Graber
Use our own len() function for network interfaces as doing
len(container.get_config_item("lxc.network")) will fail when the
list is empty.

Signed-off-by: Stéphane Graber 
---
 src/python-lxc/lxc/__init__.py | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py
index c572e10..78852ec 100644
--- a/src/python-lxc/lxc/__init__.py
+++ b/src/python-lxc/lxc/__init__.py
@@ -115,23 +115,27 @@ class ContainerNetworkList():
 self.container = container
 
 def __getitem__(self, index):
-count = len(self.container.get_config_item("lxc.network"))
-if index >= count:
+if index >= len(self):
 raise IndexError("list index out of range")
 
 return ContainerNetwork(self.container, index)
 
 def __len__(self):
-return len(self.container.get_config_item("lxc.network"))
+values = self.container.get_config_item("lxc.network")
+
+if values:
+return len(values)
+else:
+return 0
 
 def add(self, network_type):
-index = len(self.container.get_config_item("lxc.network"))
+index = len(self)
 
 return self.container.set_config_item("lxc.network.%s.type" % index,
   network_type)
 
 def remove(self, index):
-count = len(self.container.get_config_item("lxc.network"))
+count = len(self)
 if index >= count:
 raise IndexError("list index out of range")
 
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH 1/3] python: PEP8 compatibility

2012-11-26 Thread Stéphane Graber
The new version of the pep8 command is detecting more indentation
mistakes than it used to, this fixes them.

Signed-off-by: Stéphane Graber 
---
 src/lxc/lxc-start-ephemeral.in  | 81 +++--
 src/python-lxc/examples/api_test.py | 20 -
 src/python-lxc/lxc/__init__.py  | 51 +++
 src/python-lxc/setup.py | 14 +++
 4 files changed, 84 insertions(+), 82 deletions(-)

diff --git a/src/lxc/lxc-start-ephemeral.in b/src/lxc/lxc-start-ephemeral.in
index 3366209..ccf6059 100644
--- a/src/lxc/lxc-start-ephemeral.in
+++ b/src/lxc/lxc-start-ephemeral.in
@@ -46,16 +46,17 @@ def randomMAC():
 import random
 
 mac = [0x00, 0x16, 0x3e,
-random.randint(0x00, 0x7f),
-random.randint(0x00, 0xff),
-random.randint(0x00, 0xff)]
+   random.randint(0x00, 0x7f),
+   random.randint(0x00, 0xff),
+   random.randint(0x00, 0xff)]
 return ':'.join(map(lambda x: "%02x" % x, mac))
 
 # Begin parsing the command line
-parser = argparse.ArgumentParser(
-description=_("LXC: Start an ephemeral container"),
-formatter_class=argparse.RawTextHelpFormatter, epilog=_(
-"""If a COMMAND is given, then the container will run only as long
+parser = argparse.ArgumentParser(description=_(
+ "LXC: Start an ephemeral container"),
+ formatter_class=argparse.RawTextHelpFormatter,
+ epilog=_("If a COMMAND is given, then the "
+  """container will run only as long
 as the command runs.
 If no COMMAND is given, this command will attach to tty1 and stop the
 container when exiting (with ctrl-a-q).
@@ -64,29 +65,31 @@ If no COMMAND is given and -d is used, the name and IP 
addresses of the
 container will be printed to the console."""))
 
 parser.add_argument("--orig", "-o", type=str, required=True,
-help=_("name of the original container"))
+help=_("name of the original container"))
 
 parser.add_argument("--bdir", "-b", type=str,
-help=_("directory to bind mount into container"))
+help=_("directory to bind mount into container"))
 
 parser.add_argument("--user", "-u", type=str,
-help=_("the user to connect to the container as"))
+help=_("the user to connect to the container as"))
 
 parser.add_argument("--key", "-S", type=str,
-help=_("the path to the SSH key to use to connect"))
+help=_("the path to the SSH key to use to connect"))
 
 parser.add_argument("--daemon", "-d", action="store_true",
-help=_("run in the background"))
+help=_("run in the background"))
 
 parser.add_argument("--union-type", "-U", type=str, default="overlayfs",
-choices=("overlayfs", "aufs"),
-help=_("type of union (overlayfs or aufs), defaults to overlayfs."))
+choices=("overlayfs", "aufs"),
+help=_("type of union (overlayfs or aufs), "
+   "defaults to overlayfs."))
 
 parser.add_argument("--keep-data", "-k", action="store_true",
-help=_("Use a persistent backend instead of tmpfs."))
+help=_("Use a persistent backend instead of tmpfs."))
 
 parser.add_argument("command", metavar='CMD', type=str, nargs="*",
-help=_("Run specific command in container (command as argument)"))
+help=_("Run specific command in container "
+   "(command as argument)"))
 
 args = parser.parse_args()
 
@@ -129,7 +132,7 @@ if orig.get_config_item("lxc.mount"):
 for line in orig_fd.read().split("\n"):
 # Start by replacing any reference to the container rootfs
 line.replace(orig.get_config_item("lxc.rootfs"),
-dest.get_config_item("lxc.rootfs"))
+ dest.get_config_item("lxc.rootfs"))
 
 # Skip any line that's not a bind mount
 fields = line.split()
@@ -143,17 +146,17 @@ if orig.get_config_item("lxc.mount"):
 
 # Process any remaining line
 dest_mount = os.path.abspath(os.path.join("%s/rootfs/" % (
-dest_path), fields[1]))
+ dest_path), fields[1]))
 
 if dest_mount == os.path.abspath("%s/rootfs/%s" % (
-dest_path, args.bdir)):
+ dest_path, args.bdir)):
 
 dest_fd.write("%s\n" % line)
 continue
 
 if "%s/rootfs/" % dest_path not in dest_mount:
-print(_(
-"Skipping mount entry '%s' as it's outside of the container rootfs.") % line)
+print(_("Skipping mount entry '%s' as it's outside "
+"of the container rootfs.") % line

[lxc-devel] [PATCH 0/3] Various python fixes

2012-11-26 Thread Stéphane Graber
PEP-8 and other bugfixes for the python code.

Stéphane Graber (3):
  python: PEP8 compatibility
  python: Use builtin len() function for network interfaces
  gitignore: Ignore python cache

 .gitignore  |  2 +
 src/lxc/lxc-start-ephemeral.in  | 81 +++--
 src/python-lxc/examples/api_test.py | 20 -
 src/python-lxc/lxc/__init__.py  | 65 +++--
 src/python-lxc/setup.py | 14 +++
 5 files changed, 95 insertions(+), 87 deletions(-)

-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH 3/3] gitignore: Ignore python cache

2012-11-26 Thread Stéphane Graber
Signed-off-by: Stéphane Graber 
---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 398e4fc..76c9533 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,6 +65,8 @@ src/lxc/lxc-unshare
 src/lxc/lxc-version
 src/lxc/lxc-wait
 
+src/python-lxc/lxc/__pycache__/
+
 src/tests/lxc-test-containertests
 src/tests/lxc-test-createtest
 src/tests/lxc-test-destroytest
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Fix checkconfig to handle kernel memory cgroup name change

2012-11-26 Thread Stéphane Graber
On 11/14/2012 12:03 PM, Dwight Engen wrote:
> The kernel config option for the memory cgroup was changed in 3.6
> from CONFIG_CGROUP_MEM_RES_CTLR to CONFIG_MEMCG with commit c255a458.
> 
> Signed-off-by: Dwight Engen 

Sorry for the delay, I somehow missed that one.

Acked-by: Stéphane Graber 

Pushed to staging. Thanks.

> ---
>  src/lxc/lxc-checkconfig.in |   25 +++--
>  1 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/src/lxc/lxc-checkconfig.in b/src/lxc/lxc-checkconfig.in
> index 8c2b5e5..8263c17 100644
> --- a/src/lxc/lxc-checkconfig.in
> +++ b/src/lxc/lxc-checkconfig.in
> @@ -68,6 +68,15 @@ print_cgroups() {
>  }
>  
>  CGROUP_MNT_PATH=`print_cgroups cgroup /proc/self/mounts | head -1`
> +KVER_MAJOR=$($GREP '^# Linux' $CONFIG | \
> +sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
> +if [[ $KVER_MAJOR == 2 ]]; then
> +KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
> +sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
> +else
> +KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
> +sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/')
> +fi
>  
>  echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS yes
>  
> @@ -80,22 +89,18 @@ fi
>  echo -n "Cgroup device: " && is_enabled CONFIG_CGROUP_DEVICE
>  echo -n "Cgroup sched: " && is_enabled CONFIG_CGROUP_SCHED
>  echo -n "Cgroup cpu account: " && is_enabled CONFIG_CGROUP_CPUACCT
> -echo -n "Cgroup memory controller: " && is_enabled CONFIG_CGROUP_MEM_RES_CTLR
> +echo -n "Cgroup memory controller: " 
> +if [ $KVER_MAJOR -ge 3 -a $KVER_MINOR -ge 6 ]; then
> +is_enabled CONFIG_MEMCG
> +else
> +is_enabled CONFIG_CGROUP_MEM_RES_CTLR
> +fi
>  is_set CONFIG_SMP && echo -n "Cgroup cpuset: " && is_enabled CONFIG_CPUSETS
>  echo
>  echo "--- Misc ---"
>  echo -n "Veth pair device: " && is_enabled CONFIG_VETH
>  echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN
>  echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q
> -KVER_MAJOR=$($GREP '^# Linux' $CONFIG | \
> -sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
> -if [[ $KVER_MAJOR == 2 ]]; then
> -KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
> -sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
> -else
> -KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
> -sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/')
> -fi
>  echo -n "File capabilities: " &&
>  ( [[ ${KVER_MAJOR} == 2 && ${KVER_MINOR} < 33 ]] &&
> is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ) ||
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] link /dev/kmsg to /dev/console in the container

2012-11-26 Thread William Dauchy
Hello,

I tried to update from lxc-0.8-rc2 to lxc-0.8.

I don't understand this commit: 1bd051a
link /dev/kmsg to /dev/console in the container

I don't see why lxc is doing this job. I'm using a read only rootfs
with an additional rw disk (e.g for the console); so the start is now
broken because it can't setup kmsg.

What solution do we have? I really dont' think it's lxc's job to do this.

Regards,
--
William

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH 2/3] python: Use builtin len() function for network interfaces

2012-11-26 Thread Serge Hallyn
Quoting Stéphane Graber (stgra...@ubuntu.com):
> Use our own len() function for network interfaces as doing
> len(container.get_config_item("lxc.network")) will fail when the
> list is empty.
> 
> Signed-off-by: Stéphane Graber 

Acked-by: Serge E. Hallyn 

> ---
>  src/python-lxc/lxc/__init__.py | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py
> index c572e10..78852ec 100644
> --- a/src/python-lxc/lxc/__init__.py
> +++ b/src/python-lxc/lxc/__init__.py
> @@ -115,23 +115,27 @@ class ContainerNetworkList():
>  self.container = container
>  
>  def __getitem__(self, index):
> -count = len(self.container.get_config_item("lxc.network"))
> -if index >= count:
> +if index >= len(self):
>  raise IndexError("list index out of range")
>  
>  return ContainerNetwork(self.container, index)
>  
>  def __len__(self):
> -return len(self.container.get_config_item("lxc.network"))
> +values = self.container.get_config_item("lxc.network")
> +
> +if values:
> +return len(values)
> +else:
> +return 0
>  
>  def add(self, network_type):
> -index = len(self.container.get_config_item("lxc.network"))
> +index = len(self)
>  
>  return self.container.set_config_item("lxc.network.%s.type" % index,
>network_type)
>  
>  def remove(self, index):
> -count = len(self.container.get_config_item("lxc.network"))
> +count = len(self)
>  if index >= count:
>  raise IndexError("list index out of range")
>  
> -- 
> 1.8.0
> 
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] Resource cleanups

2012-11-26 Thread Dwight Engen
Hello,

Recently I wrote a lua binding for lxc on which I built a simple
lxc-top tool. In testing that my container class was properly freeing
all resources during garbage collection, I discovered that lxc itself
needs some cleanups. I will be posting a series of patches to do these
cleanups, which fix some memory/fd leaks for long(er) running processes
using the API. In addition I fixed some use after free errors and an
out-of-bounds error I found with valgrind.

In writing the binding, I found that some of the C API could easily be
const'ified (ie. the char *value in a lot of the config API), which
makes it easier to write a binding without having to strdup in the
binding. I think this also makes the API a bit cleaner. I'm going to
clean up these patches and submit them for consideration also.

I can post the lua binding, api test script, and top tool if there is
interest. Thanks.

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] Fix fd leak in lxc log

2012-11-26 Thread Dwight Engen
lxc_log_init will leak an fd when it is called by a long running
program that may call lxc_container_new multiple times. Fix by
only opening the log if it is not already open.

Signed-off-by: Dwight Engen 
---
 src/lxc/log.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/lxc/log.c b/src/lxc/log.c
index 7f3b6b2..02ee21c 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -153,6 +153,9 @@ extern int lxc_log_init(const char *file, const char 
*priority,
 {
int lxc_priority = LXC_LOG_PRIORITY_ERROR;
 
+   if (lxc_log_fd != -1)
+   return 0;
+
if (priority) {
lxc_priority = lxc_log_priority_to_int(priority);
 
-- 
1.7.1


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] Fix use of list item memory after free

2012-11-26 Thread Dwight Engen
Valgrind showed use of ->next field after item has been free()ed.
Introduce a lxc_list_for_each_safe() which allows traversal of a list
when the body of the loop may remove the currently iterated item.

Signed-off-by: Dwight Engen 
---
 src/lxc/conf.c|   38 +++---
 src/lxc/confile.c |4 ++--
 src/lxc/list.h|5 +
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index fe574ac..79760a0 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -725,7 +725,7 @@ static int umount_oldrootfs(const char *oldrootfs)
 {
char path[MAXPATHLEN];
void *cbparm[2];
-   struct lxc_list mountlist, *iterator;
+   struct lxc_list mountlist, *iterator, *next;
int ok, still_mounted, last_still_mounted;
int rc;
 
@@ -765,7 +765,7 @@ static int umount_oldrootfs(const char *oldrootfs)
last_still_mounted = still_mounted;
still_mounted = 0;
 
-   lxc_list_for_each(iterator, &mountlist) {
+   lxc_list_for_each_safe(iterator, &mountlist, next) {
 
/* umount normally */
if (!umount(iterator->elem)) {
@@ -2368,7 +2368,7 @@ int run_lxc_hooks(const char *name, char *hook, struct 
lxc_conf *conf)
 static void lxc_remove_nic(struct lxc_list *it)
 {
struct lxc_netdev *netdev = it->elem;
-   struct lxc_list *it2;
+   struct lxc_list *it2,*next;
 
lxc_list_del(it);
 
@@ -2386,12 +2386,12 @@ static void lxc_remove_nic(struct lxc_list *it)
free(netdev->ipv4_gateway);
if (netdev->ipv6_gateway)
free(netdev->ipv6_gateway);
-   lxc_list_for_each(it2, &netdev->ipv4) {
+   lxc_list_for_each_safe(it2, &netdev->ipv4, next) {
lxc_list_del(it2);
free(it2->elem);
free(it2);
}
-   lxc_list_for_each(it2, &netdev->ipv6) {
+   lxc_list_for_each_safe(it2, &netdev->ipv6, next) {
lxc_list_del(it2);
free(it2->elem);
free(it2);
@@ -2433,15 +2433,15 @@ int lxc_clear_nic(struct lxc_conf *c, char *key)
if (!p1) {
lxc_remove_nic(it);
} else if (strcmp(p1, "ipv4") == 0) {
-   struct lxc_list *it2;
-   lxc_list_for_each(it2, &netdev->ipv4) {
+   struct lxc_list *it2,*next;
+   lxc_list_for_each_safe(it2, &netdev->ipv4, next) {
lxc_list_del(it2);
free(it2->elem);
free(it2);
}
} else if (strcmp(p1, "ipv6") == 0) {
-   struct lxc_list *it2;
-   lxc_list_for_each(it2, &netdev->ipv6) {
+   struct lxc_list *it2,*next;
+   lxc_list_for_each_safe(it2, &netdev->ipv6, next) {
lxc_list_del(it2);
free(it2->elem);
free(it2);
@@ -2489,8 +2489,8 @@ int lxc_clear_nic(struct lxc_conf *c, char *key)
 
 int lxc_clear_config_network(struct lxc_conf *c)
 {
-   struct lxc_list *it;
-   lxc_list_for_each(it, &c->network) {
+   struct lxc_list *it,*next;
+   lxc_list_for_each_safe(it, &c->network, next) {
lxc_remove_nic(it);
}
return 0;
@@ -2498,9 +2498,9 @@ int lxc_clear_config_network(struct lxc_conf *c)
 
 int lxc_clear_config_caps(struct lxc_conf *c)
 {
-   struct lxc_list *it;
+   struct lxc_list *it,*next;
 
-   lxc_list_for_each(it, &c->caps) {
+   lxc_list_for_each_safe(it, &c->caps, next) {
lxc_list_del(it);
free(it->elem);
free(it);
@@ -2510,14 +2510,14 @@ int lxc_clear_config_caps(struct lxc_conf *c)
 
 int lxc_clear_cgroups(struct lxc_conf *c, char *key)
 {
-   struct lxc_list *it;
+   struct lxc_list *it,*next;
bool all = false;
char *k = key + 11;
 
if (strcmp(key, "lxc.cgroup") == 0)
all = true;
 
-   lxc_list_for_each(it, &c->cgroup) {
+   lxc_list_for_each_safe(it, &c->cgroup, next) {
struct lxc_cgroup *cg = it->elem;
if (!all && strcmp(cg->subsystem, k) != 0)
continue;
@@ -2532,9 +2532,9 @@ int lxc_clear_cgroups(struct lxc_conf *c, char *key)
 
 int lxc_clear_mount_entries(struct lxc_conf *c)
 {
-   struct lxc_list *it;
+   struct lxc_list *it,*next;
 
-   lxc_list_for_each(it, &c->mount_list) {
+   lxc_list_for_each_safe(it, &c->mount_list, next) {
lxc_list_del(it);
free(it->elem);
free(it);
@@ -2544,7 +2544,7 @@ int lxc_clear_mount_entries(struct lxc_conf *c)
 
 int lxc_clear_hooks(struct lxc_conf *c, char *key)
 {
-   struct lxc_list *it;
+   struct lxc_list *it,*next;
bool all = false, done = false;
char *k = key + 9;
int i;
@@ -2554,7 +2554,7 @@ int lxc_cl

[lxc-devel] [PATCH] Ensure argv passed by createl to create is NULL terminated

2012-11-26 Thread Dwight Engen
Signed-off-by: Dwight Engen 
---
 src/lxc/lxccontainer.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 37f5ed7..4818b2c 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -683,13 +683,14 @@ static bool lxcapi_createl(struct lxc_container *c, char 
*t, ...)
if (!arg)
break;
nargs++;
-   temp = realloc(args, nargs * sizeof(*args));
+   temp = realloc(args, (nargs+1) * sizeof(*args));
if (!temp)
goto out;
args = temp;
args[nargs - 1] = arg;
}
va_end(ap);
+   args[nargs] = NULL;
 
bret = c->create(c, t, args);
 
-- 
1.7.1


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] Free allocated configuration memory

2012-11-26 Thread Dwight Engen
Most of these were found with valgrind by repeatedly doing lxc_container_new
followed by lxc_container_put. Also free memory when config items are
re-parsed, as happens when lxcapi_set_config_item() is called. Refactored
path type config items to use a common underlying routine.

Signed-off-by: Dwight Engen 
---
 src/lxc/conf.c |9 +
 src/lxc/confile.c  |   93 +--
 src/lxc/lxccontainer.c |   13 ---
 3 files changed, 59 insertions(+), 56 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index fe574ac..5ff64f6 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2396,6 +2396,7 @@ static void lxc_remove_nic(struct lxc_list *it)
free(it2->elem);
free(it2);
}
+   free(netdev);
free(it);
 }
 
@@ -2578,6 +2579,14 @@ void lxc_conf_free(struct lxc_conf *conf)
free(conf->console.path);
if (conf->rootfs.mount != default_rootfs_mount)
free(conf->rootfs.mount);
+   if (conf->rootfs.path)
+   free(conf->rootfs.path);
+   if (conf->utsname)
+   free(conf->utsname);
+   if (conf->ttydir)
+   free(conf->ttydir);
+   if (conf->fstab)
+   free(conf->fstab);
lxc_clear_config_network(conf);
 #if HAVE_APPARMOR
if (conf->aa_profile)
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index cf1c891..bacad01 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -486,17 +486,21 @@ static int config_network_hwaddr(const char *key, char 
*value,
 struct lxc_conf *lxc_conf)
 {
struct lxc_netdev *netdev;
+   char *hwaddr;
 
netdev = network_netdev(key, value, &lxc_conf->network);
if (!netdev)
return -1;
 
-   netdev->hwaddr = strdup(value);
-   if (!netdev->hwaddr) {
+   hwaddr = strdup(value);
+   if (!hwaddr) {
SYSERROR("failed to dup string '%s'", value);
return -1;
}
 
+   if (netdev->hwaddr)
+   free(netdev->hwaddr);
+   netdev->hwaddr = hwaddr;
return 0;
 }
 
@@ -519,17 +523,21 @@ static int config_network_mtu(const char *key, char 
*value,
  struct lxc_conf *lxc_conf)
 {
struct lxc_netdev *netdev;
+   char *mtu;
 
netdev = network_netdev(key, value, &lxc_conf->network);
if (!netdev)
return -1;
 
-   netdev->mtu = strdup(value);
-   if (!netdev->mtu) {
+   mtu = strdup(value);
+   if (!mtu) {
SYSERROR("failed to dup string '%s'", value);
return -1;
}
 
+   if (netdev->mtu)
+   free(netdev->mtu);
+   netdev->mtu = mtu;
return 0;
 }
 
@@ -785,6 +793,8 @@ static int config_seccomp(const char *key, char *value,
return -1;
}
 
+   if (lxc_conf->seccomp)
+   free(lxc_conf->seccomp);
lxc_conf->seccomp = path;
 
return 0;
@@ -857,6 +867,8 @@ static int config_ttydir(const char *key, char *value,
return -1;
}
 
+   if (lxc_conf->ttydir)
+   free(lxc_conf->ttydir);
lxc_conf->ttydir = path;
 
return 0;
@@ -875,6 +887,8 @@ static int config_aa_profile(const char *key, char *value, 
struct lxc_conf *lxc_
return -1;
}
 
+   if (lxc_conf->aa_profile)
+   free(lxc_conf->aa_profile);
lxc_conf->aa_profile = path;
 
return 0;
@@ -939,22 +953,33 @@ out:
return -1;
 }
 
-static int config_fstab(const char *key, char *value, struct lxc_conf 
*lxc_conf)
+static int config_path_item(const char *key, const char *value,
+   struct lxc_conf *lxc_conf, char **conf_item)
 {
+   char *valdup;
if (strlen(value) >= MAXPATHLEN) {
ERROR("%s path is too long", value);
return -1;
}
 
-   lxc_conf->fstab = strdup(value);
-   if (!lxc_conf->fstab) {
+   valdup = strdup(value);
+   if (!valdup) {
SYSERROR("failed to duplicate string %s", value);
return -1;
}
+   if (*conf_item)
+   free(*conf_item);
+   *conf_item = valdup;
 
return 0;
 }
 
+static int config_fstab(const char *key, const char *value,
+   struct lxc_conf *lxc_conf)
+{
+   return config_path_item(key, value, lxc_conf, &lxc_conf->fstab);
+}
+
 static int config_mount(const char *key, char *value, struct lxc_conf 
*lxc_conf)
 {
char *fstab_token = "lxc.mount";
@@ -994,7 +1019,7 @@ static int config_mount(const char *key, char *value, 
struct lxc_conf *lxc_conf)
 static int config_cap_drop(const char *key, char *value,
   struct lxc_conf *lxc_conf)
 {
-   char *dropcaps, *sptr, *token;
+   char *dropcaps, *dropptr, *sptr, *token;
struct lxc_list *dro

Re: [lxc-devel] [PATCH 1/3] python: PEP8 compatibility

2012-11-26 Thread Serge Hallyn
Quoting Stéphane Graber (stgra...@ubuntu.com):
> The new version of the pep8 command is detecting more indentation
> mistakes than it used to, this fixes them.
> 

Every instance looks like bike-shedding to me, but ok.

Acked-by: Serge E. Hallyn 

> Signed-off-by: Stéphane Graber 
> ---
>  src/lxc/lxc-start-ephemeral.in  | 81 
> +++--
>  src/python-lxc/examples/api_test.py | 20 -
>  src/python-lxc/lxc/__init__.py  | 51 +++
>  src/python-lxc/setup.py | 14 +++
>  4 files changed, 84 insertions(+), 82 deletions(-)
> 
> diff --git a/src/lxc/lxc-start-ephemeral.in b/src/lxc/lxc-start-ephemeral.in
> index 3366209..ccf6059 100644
> --- a/src/lxc/lxc-start-ephemeral.in
> +++ b/src/lxc/lxc-start-ephemeral.in
> @@ -46,16 +46,17 @@ def randomMAC():
>  import random
>  
>  mac = [0x00, 0x16, 0x3e,
> -random.randint(0x00, 0x7f),
> -random.randint(0x00, 0xff),
> -random.randint(0x00, 0xff)]
> +   random.randint(0x00, 0x7f),
> +   random.randint(0x00, 0xff),
> +   random.randint(0x00, 0xff)]
>  return ':'.join(map(lambda x: "%02x" % x, mac))
>  
>  # Begin parsing the command line
> -parser = argparse.ArgumentParser(
> -description=_("LXC: Start an ephemeral container"),
> -formatter_class=argparse.RawTextHelpFormatter, epilog=_(
> -"""If a COMMAND is given, then the container will run only as long
> +parser = argparse.ArgumentParser(description=_(
> + "LXC: Start an ephemeral container"),
> + 
> formatter_class=argparse.RawTextHelpFormatter,
> + epilog=_("If a COMMAND is given, then the "
> +  """container will run only as long
>  as the command runs.
>  If no COMMAND is given, this command will attach to tty1 and stop the
>  container when exiting (with ctrl-a-q).
> @@ -64,29 +65,31 @@ If no COMMAND is given and -d is used, the name and IP 
> addresses of the
>  container will be printed to the console."""))
>  
>  parser.add_argument("--orig", "-o", type=str, required=True,
> -help=_("name of the original container"))
> +help=_("name of the original container"))
>  
>  parser.add_argument("--bdir", "-b", type=str,
> -help=_("directory to bind mount into container"))
> +help=_("directory to bind mount into container"))
>  
>  parser.add_argument("--user", "-u", type=str,
> -help=_("the user to connect to the container as"))
> +help=_("the user to connect to the container as"))
>  
>  parser.add_argument("--key", "-S", type=str,
> -help=_("the path to the SSH key to use to connect"))
> +help=_("the path to the SSH key to use to connect"))
>  
>  parser.add_argument("--daemon", "-d", action="store_true",
> -help=_("run in the background"))
> +help=_("run in the background"))
>  
>  parser.add_argument("--union-type", "-U", type=str, default="overlayfs",
> -choices=("overlayfs", "aufs"),
> -help=_("type of union (overlayfs or aufs), defaults to overlayfs."))
> +choices=("overlayfs", "aufs"),
> +help=_("type of union (overlayfs or aufs), "
> +   "defaults to overlayfs."))
>  
>  parser.add_argument("--keep-data", "-k", action="store_true",
> -help=_("Use a persistent backend instead of tmpfs."))
> +help=_("Use a persistent backend instead of tmpfs."))
>  
>  parser.add_argument("command", metavar='CMD', type=str, nargs="*",
> -help=_("Run specific command in container (command as argument)"))
> +help=_("Run specific command in container "
> +   "(command as argument)"))
>  
>  args = parser.parse_args()
>  
> @@ -129,7 +132,7 @@ if orig.get_config_item("lxc.mount"):
>  for line in orig_fd.read().split("\n"):
>  # Start by replacing any reference to the container rootfs
>  line.replace(orig.get_config_item("lxc.rootfs"),
> -dest.get_config_item("lxc.rootfs"))
> + dest.get_config_item("lxc.rootfs"))
>  
>  # Skip any line that's not a bind mount
>  fields = line.split()
> @@ -143,17 +146,17 @@ if orig.get_config_item("lxc.mount"):
>  
>  # Process any remaining line
>  dest_mount = os.path.abspath(os.path.join("%s/rootfs/" % (
> -dest_path), fields[1]))
> + dest_path), fields[1]))
>  
>  if dest_mount == os.path.abspath("%s/rootfs/%s" % (
> -dest_path, args.bdir)):
> + dest_path, args.bdir)):
>  
>  dest_fd.write("%s\n" % line

Re: [lxc-devel] [PATCH 3/3] gitignore: Ignore python cache

2012-11-26 Thread Serge Hallyn
Quoting Stéphane Graber (stgra...@ubuntu.com):
> Signed-off-by: Stéphane Graber 

Acked-by: Serge E. Hallyn 

> ---
>  .gitignore | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/.gitignore b/.gitignore
> index 398e4fc..76c9533 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -65,6 +65,8 @@ src/lxc/lxc-unshare
>  src/lxc/lxc-version
>  src/lxc/lxc-wait
>  
> +src/python-lxc/lxc/__pycache__/
> +
>  src/tests/lxc-test-containertests
>  src/tests/lxc-test-createtest
>  src/tests/lxc-test-destroytest
> -- 
> 1.8.0
> 
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] link /dev/kmsg to /dev/console in the container

2012-11-26 Thread Serge Hallyn
Quoting William Dauchy (wdau...@gmail.com):
> Hello,
> 
> I tried to update from lxc-0.8-rc2 to lxc-0.8.
> 
> I don't understand this commit: 1bd051a
> link /dev/kmsg to /dev/console in the container
> 
> I don't see why lxc is doing this job. I'm using a read only rootfs
> with an additional rw disk (e.g for the console); so the start is now
> broken because it can't setup kmsg.
> 
> What solution do we have? I really dont' think it's lxc's job to do this.

No, it's the kernel's.  Patch for that is however not yet ready.

Failure to set up kmsg should not fail container startup.  Commit
f62b344996937459ae5f31b0358cb440ddde421f fixed that, but that is
apparenly not in 0.8.0.  You can fetch it from git://github.com/lxc/lxc.git
staging branch.

-serge

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Fix fd leak in lxc log

2012-11-26 Thread Serge Hallyn
Quoting Dwight Engen (dwight.en...@oracle.com):
> lxc_log_init will leak an fd when it is called by a long running
> program that may call lxc_container_new multiple times. Fix by
> only opening the log if it is not already open.
> 
> Signed-off-by: Dwight Engen 

Acked-by: Serge E. Hallyn 

> ---
>  src/lxc/log.c |3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/src/lxc/log.c b/src/lxc/log.c
> index 7f3b6b2..02ee21c 100644
> --- a/src/lxc/log.c
> +++ b/src/lxc/log.c
> @@ -153,6 +153,9 @@ extern int lxc_log_init(const char *file, const char 
> *priority,
>  {
>   int lxc_priority = LXC_LOG_PRIORITY_ERROR;
>  
> + if (lxc_log_fd != -1)
> + return 0;
> +
>   if (priority) {
>   lxc_priority = lxc_log_priority_to_int(priority);
>  
> -- 
> 1.7.1
> 
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Fix use of list item memory after free

2012-11-26 Thread Serge Hallyn
Quoting Dwight Engen (dwight.en...@oracle.com):
> Valgrind showed use of ->next field after item has been free()ed.
> Introduce a lxc_list_for_each_safe() which allows traversal of a list
> when the body of the loop may remove the currently iterated item.
> 
> Signed-off-by: Dwight Engen 

Thanks (boy do I feel like an idiot)

Acked-by: Serge E. Hallyn 

> ---
>  src/lxc/conf.c|   38 +++---
>  src/lxc/confile.c |4 ++--
>  src/lxc/list.h|5 +
>  3 files changed, 26 insertions(+), 21 deletions(-)
> 
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index fe574ac..79760a0 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -725,7 +725,7 @@ static int umount_oldrootfs(const char *oldrootfs)
>  {
>   char path[MAXPATHLEN];
>   void *cbparm[2];
> - struct lxc_list mountlist, *iterator;
> + struct lxc_list mountlist, *iterator, *next;
>   int ok, still_mounted, last_still_mounted;
>   int rc;
>  
> @@ -765,7 +765,7 @@ static int umount_oldrootfs(const char *oldrootfs)
>   last_still_mounted = still_mounted;
>   still_mounted = 0;
>  
> - lxc_list_for_each(iterator, &mountlist) {
> + lxc_list_for_each_safe(iterator, &mountlist, next) {
>  
>   /* umount normally */
>   if (!umount(iterator->elem)) {
> @@ -2368,7 +2368,7 @@ int run_lxc_hooks(const char *name, char *hook, struct 
> lxc_conf *conf)
>  static void lxc_remove_nic(struct lxc_list *it)
>  {
>   struct lxc_netdev *netdev = it->elem;
> - struct lxc_list *it2;
> + struct lxc_list *it2,*next;
>  
>   lxc_list_del(it);
>  
> @@ -2386,12 +2386,12 @@ static void lxc_remove_nic(struct lxc_list *it)
>   free(netdev->ipv4_gateway);
>   if (netdev->ipv6_gateway)
>   free(netdev->ipv6_gateway);
> - lxc_list_for_each(it2, &netdev->ipv4) {
> + lxc_list_for_each_safe(it2, &netdev->ipv4, next) {
>   lxc_list_del(it2);
>   free(it2->elem);
>   free(it2);
>   }
> - lxc_list_for_each(it2, &netdev->ipv6) {
> + lxc_list_for_each_safe(it2, &netdev->ipv6, next) {
>   lxc_list_del(it2);
>   free(it2->elem);
>   free(it2);
> @@ -2433,15 +2433,15 @@ int lxc_clear_nic(struct lxc_conf *c, char *key)
>   if (!p1) {
>   lxc_remove_nic(it);
>   } else if (strcmp(p1, "ipv4") == 0) {
> - struct lxc_list *it2;
> - lxc_list_for_each(it2, &netdev->ipv4) {
> + struct lxc_list *it2,*next;
> + lxc_list_for_each_safe(it2, &netdev->ipv4, next) {
>   lxc_list_del(it2);
>   free(it2->elem);
>   free(it2);
>   }
>   } else if (strcmp(p1, "ipv6") == 0) {
> - struct lxc_list *it2;
> - lxc_list_for_each(it2, &netdev->ipv6) {
> + struct lxc_list *it2,*next;
> + lxc_list_for_each_safe(it2, &netdev->ipv6, next) {
>   lxc_list_del(it2);
>   free(it2->elem);
>   free(it2);
> @@ -2489,8 +2489,8 @@ int lxc_clear_nic(struct lxc_conf *c, char *key)
>  
>  int lxc_clear_config_network(struct lxc_conf *c)
>  {
> - struct lxc_list *it;
> - lxc_list_for_each(it, &c->network) {
> + struct lxc_list *it,*next;
> + lxc_list_for_each_safe(it, &c->network, next) {
>   lxc_remove_nic(it);
>   }
>   return 0;
> @@ -2498,9 +2498,9 @@ int lxc_clear_config_network(struct lxc_conf *c)
>  
>  int lxc_clear_config_caps(struct lxc_conf *c)
>  {
> - struct lxc_list *it;
> + struct lxc_list *it,*next;
>  
> - lxc_list_for_each(it, &c->caps) {
> + lxc_list_for_each_safe(it, &c->caps, next) {
>   lxc_list_del(it);
>   free(it->elem);
>   free(it);
> @@ -2510,14 +2510,14 @@ int lxc_clear_config_caps(struct lxc_conf *c)
>  
>  int lxc_clear_cgroups(struct lxc_conf *c, char *key)
>  {
> - struct lxc_list *it;
> + struct lxc_list *it,*next;
>   bool all = false;
>   char *k = key + 11;
>  
>   if (strcmp(key, "lxc.cgroup") == 0)
>   all = true;
>  
> - lxc_list_for_each(it, &c->cgroup) {
> + lxc_list_for_each_safe(it, &c->cgroup, next) {
>   struct lxc_cgroup *cg = it->elem;
>   if (!all && strcmp(cg->subsystem, k) != 0)
>   continue;
> @@ -2532,9 +2532,9 @@ int lxc_clear_cgroups(struct lxc_conf *c, char *key)
>  
>  int lxc_clear_mount_entries(struct lxc_conf *c)
>  {
> - struct lxc_list *it;
> + struct lxc_list *it,*next;
>  
> - lxc_list_for_each(it, &c->mount_list) {
> + lxc_list_for_each_safe(it, &c->mount_list, next) {
>   lxc_list_del(it);
>   free(it->elem);
>   free(it);
> @@ -2544,7 +2544,7 @@ int lxc_clear_mount_entries(struct lxc_conf *c)
>  
>  int lxc_clear

Re: [lxc-devel] link /dev/kmsg to /dev/console in the container

2012-11-26 Thread William Dauchy
Hi Serge,

Thank you for you reply.

On Mon, Nov 26, 2012 at 6:28 PM, Serge Hallyn
 wrote:
> No, it's the kernel's.  Patch for that is however not yet ready.
>
> Failure to set up kmsg should not fail container startup.  Commit
> f62b344996937459ae5f31b0358cb440ddde421f fixed that, but that is
> apparenly not in 0.8.0.  You can fetch it from git://github.com/lxc/lxc.git
> staging branch.

I didn't now this tree. I'm using git://lxc.git.sourceforge.net/gitroot/lxc/lxc
I will therefore port this patch in my build.

Thanks,

--
William

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Fix fd leak in lxc log

2012-11-26 Thread Stéphane Graber
On 11/26/2012 12:38 PM, Serge Hallyn wrote:
> Quoting Dwight Engen (dwight.en...@oracle.com):
>> lxc_log_init will leak an fd when it is called by a long running
>> program that may call lxc_container_new multiple times. Fix by
>> only opening the log if it is not already open.
>>
>> Signed-off-by: Dwight Engen 
> 
> Acked-by: Serge E. Hallyn 

Thanks, applied to staging.

>> ---
>>  src/lxc/log.c |3 +++
>>  1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/lxc/log.c b/src/lxc/log.c
>> index 7f3b6b2..02ee21c 100644
>> --- a/src/lxc/log.c
>> +++ b/src/lxc/log.c
>> @@ -153,6 +153,9 @@ extern int lxc_log_init(const char *file, const char 
>> *priority,
>>  {
>>  int lxc_priority = LXC_LOG_PRIORITY_ERROR;
>>  
>> +if (lxc_log_fd != -1)
>> +return 0;
>> +
>>  if (priority) {
>>  lxc_priority = lxc_log_priority_to_int(priority);
>>  
>> -- 
>> 1.7.1
>>
>>
>> --
>> Monitor your physical, virtual and cloud infrastructure from a single
>> web console. Get in-depth insight into apps, servers, databases, vmware,
>> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
>> Pricing starts from $795 for 25 servers or applications!
>> http://p.sf.net/sfu/zoho_dev2dev_nov
>> ___
>> Lxc-devel mailing list
>> Lxc-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Fix use of list item memory after free

2012-11-26 Thread Stéphane Graber
On 11/26/2012 12:40 PM, Serge Hallyn wrote:
> Quoting Dwight Engen (dwight.en...@oracle.com):
>> Valgrind showed use of ->next field after item has been free()ed.
>> Introduce a lxc_list_for_each_safe() which allows traversal of a list
>> when the body of the loop may remove the currently iterated item.
>>
>> Signed-off-by: Dwight Engen 
> 
> Thanks (boy do I feel like an idiot)
> 
> Acked-by: Serge E. Hallyn 

Thanks, applied to staging.

>> ---
>>  src/lxc/conf.c|   38 +++---
>>  src/lxc/confile.c |4 ++--
>>  src/lxc/list.h|5 +
>>  3 files changed, 26 insertions(+), 21 deletions(-)
>>
>> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
>> index fe574ac..79760a0 100644
>> --- a/src/lxc/conf.c
>> +++ b/src/lxc/conf.c
>> @@ -725,7 +725,7 @@ static int umount_oldrootfs(const char *oldrootfs)
>>  {
>>  char path[MAXPATHLEN];
>>  void *cbparm[2];
>> -struct lxc_list mountlist, *iterator;
>> +struct lxc_list mountlist, *iterator, *next;
>>  int ok, still_mounted, last_still_mounted;
>>  int rc;
>>  
>> @@ -765,7 +765,7 @@ static int umount_oldrootfs(const char *oldrootfs)
>>  last_still_mounted = still_mounted;
>>  still_mounted = 0;
>>  
>> -lxc_list_for_each(iterator, &mountlist) {
>> +lxc_list_for_each_safe(iterator, &mountlist, next) {
>>  
>>  /* umount normally */
>>  if (!umount(iterator->elem)) {
>> @@ -2368,7 +2368,7 @@ int run_lxc_hooks(const char *name, char *hook, struct 
>> lxc_conf *conf)
>>  static void lxc_remove_nic(struct lxc_list *it)
>>  {
>>  struct lxc_netdev *netdev = it->elem;
>> -struct lxc_list *it2;
>> +struct lxc_list *it2,*next;
>>  
>>  lxc_list_del(it);
>>  
>> @@ -2386,12 +2386,12 @@ static void lxc_remove_nic(struct lxc_list *it)
>>  free(netdev->ipv4_gateway);
>>  if (netdev->ipv6_gateway)
>>  free(netdev->ipv6_gateway);
>> -lxc_list_for_each(it2, &netdev->ipv4) {
>> +lxc_list_for_each_safe(it2, &netdev->ipv4, next) {
>>  lxc_list_del(it2);
>>  free(it2->elem);
>>  free(it2);
>>  }
>> -lxc_list_for_each(it2, &netdev->ipv6) {
>> +lxc_list_for_each_safe(it2, &netdev->ipv6, next) {
>>  lxc_list_del(it2);
>>  free(it2->elem);
>>  free(it2);
>> @@ -2433,15 +2433,15 @@ int lxc_clear_nic(struct lxc_conf *c, char *key)
>>  if (!p1) {
>>  lxc_remove_nic(it);
>>  } else if (strcmp(p1, "ipv4") == 0) {
>> -struct lxc_list *it2;
>> -lxc_list_for_each(it2, &netdev->ipv4) {
>> +struct lxc_list *it2,*next;
>> +lxc_list_for_each_safe(it2, &netdev->ipv4, next) {
>>  lxc_list_del(it2);
>>  free(it2->elem);
>>  free(it2);
>>  }
>>  } else if (strcmp(p1, "ipv6") == 0) {
>> -struct lxc_list *it2;
>> -lxc_list_for_each(it2, &netdev->ipv6) {
>> +struct lxc_list *it2,*next;
>> +lxc_list_for_each_safe(it2, &netdev->ipv6, next) {
>>  lxc_list_del(it2);
>>  free(it2->elem);
>>  free(it2);
>> @@ -2489,8 +2489,8 @@ int lxc_clear_nic(struct lxc_conf *c, char *key)
>>  
>>  int lxc_clear_config_network(struct lxc_conf *c)
>>  {
>> -struct lxc_list *it;
>> -lxc_list_for_each(it, &c->network) {
>> +struct lxc_list *it,*next;
>> +lxc_list_for_each_safe(it, &c->network, next) {
>>  lxc_remove_nic(it);
>>  }
>>  return 0;
>> @@ -2498,9 +2498,9 @@ int lxc_clear_config_network(struct lxc_conf *c)
>>  
>>  int lxc_clear_config_caps(struct lxc_conf *c)
>>  {
>> -struct lxc_list *it;
>> +struct lxc_list *it,*next;
>>  
>> -lxc_list_for_each(it, &c->caps) {
>> +lxc_list_for_each_safe(it, &c->caps, next) {
>>  lxc_list_del(it);
>>  free(it->elem);
>>  free(it);
>> @@ -2510,14 +2510,14 @@ int lxc_clear_config_caps(struct lxc_conf *c)
>>  
>>  int lxc_clear_cgroups(struct lxc_conf *c, char *key)
>>  {
>> -struct lxc_list *it;
>> +struct lxc_list *it,*next;
>>  bool all = false;
>>  char *k = key + 11;
>>  
>>  if (strcmp(key, "lxc.cgroup") == 0)
>>  all = true;
>>  
>> -lxc_list_for_each(it, &c->cgroup) {
>> +lxc_list_for_each_safe(it, &c->cgroup, next) {
>>  struct lxc_cgroup *cg = it->elem;
>>  if (!all && strcmp(cg->subsystem, k) != 0)
>>  continue;
>> @@ -2532,9 +2532,9 @@ int lxc_clear_cgroups(struct lxc_conf *c, char *key)
>>  
>>  int lxc_clear_mount_entries(struct lxc_conf *c)
>>  {
>> -struct lxc_list *it;
>> +struct lxc_list *it,*next;
>>  
>> -lxc_list_for_each(it, &c->mount_list) {
>> +lxc_list_for_each_safe(it, &c->mount_list, next) {
>>  lxc_list_del(it);
>>  free

[lxc-devel] lxc python binding

2012-11-26 Thread Dwight Engen
Hi Stéphane,

While I was testing the lua binding I did (based largely on the Python
one :) I noticed a memory leak when container objects were garbage
collected, and I think the Python binding may have it as well. I think
Container_dealloc() should probably do lxc_container_put() as shown in
the patch, but I am not too familiar with the Python type system /
object lifetime and I don't have python3 in order to test it. What do
you think?

8<---

diff --git a/src/python-lxc/lxc.c b/src/python-lxc/lxc.c
index b489079..162821d 100644
--- a/src/python-lxc/lxc.c
+++ b/src/python-lxc/lxc.c
@@ -62,6 +62,8 @@ convert_tuple_to_char_pointer_array(PyObject *argv) {
 static void
 Container_dealloc(Container* self)
 {
+/* XXX not much we can do if _put fails? */
+lxc_container_put(self->container);
 Py_TYPE(self)->tp_free((PyObject*)self);
 }
 

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Fix use of list item memory after free

2012-11-26 Thread Dwight Engen
On Mon, 26 Nov 2012 11:40:40 -0600
Serge Hallyn  wrote:

> Quoting Dwight Engen (dwight.en...@oracle.com):
> > Valgrind showed use of ->next field after item has been free()ed.
> > Introduce a lxc_list_for_each_safe() which allows traversal of a
> > list when the body of the loop may remove the currently iterated
> > item.
> > 
> > Signed-off-by: Dwight Engen 
> 
> Thanks (boy do I feel like an idiot)
> 
> Acked-by: Serge E. Hallyn 

No big deal, I guess it would only affect the threaded case where
another thread picked up the free()ed memory as we iterated. I only
noticed because of valgrind :)

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Free allocated configuration memory

2012-11-26 Thread Serge Hallyn
Quoting Dwight Engen (dwight.en...@oracle.com):
> Most of these were found with valgrind by repeatedly doing lxc_container_new
> followed by lxc_container_put. Also free memory when config items are
> re-parsed, as happens when lxcapi_set_config_item() is called. Refactored
> path type config items to use a common underlying routine.
> 
> Signed-off-by: Dwight Engen 

Thanks, Dwight.

Acked-by: Serge E. Hallyn 

> ---
>  src/lxc/conf.c |9 +
>  src/lxc/confile.c  |   93 +--
>  src/lxc/lxccontainer.c |   13 ---
>  3 files changed, 59 insertions(+), 56 deletions(-)
> 
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index fe574ac..5ff64f6 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -2396,6 +2396,7 @@ static void lxc_remove_nic(struct lxc_list *it)
>   free(it2->elem);
>   free(it2);
>   }
> + free(netdev);
>   free(it);
>  }
>  
> @@ -2578,6 +2579,14 @@ void lxc_conf_free(struct lxc_conf *conf)
>   free(conf->console.path);
>   if (conf->rootfs.mount != default_rootfs_mount)
>   free(conf->rootfs.mount);
> + if (conf->rootfs.path)
> + free(conf->rootfs.path);
> + if (conf->utsname)
> + free(conf->utsname);
> + if (conf->ttydir)
> + free(conf->ttydir);
> + if (conf->fstab)
> + free(conf->fstab);
>   lxc_clear_config_network(conf);
>  #if HAVE_APPARMOR
>   if (conf->aa_profile)
> diff --git a/src/lxc/confile.c b/src/lxc/confile.c
> index cf1c891..bacad01 100644
> --- a/src/lxc/confile.c
> +++ b/src/lxc/confile.c
> @@ -486,17 +486,21 @@ static int config_network_hwaddr(const char *key, char 
> *value,
>struct lxc_conf *lxc_conf)
>  {
>   struct lxc_netdev *netdev;
> + char *hwaddr;
>  
>   netdev = network_netdev(key, value, &lxc_conf->network);
>   if (!netdev)
>   return -1;
>  
> - netdev->hwaddr = strdup(value);
> - if (!netdev->hwaddr) {
> + hwaddr = strdup(value);
> + if (!hwaddr) {
>   SYSERROR("failed to dup string '%s'", value);
>   return -1;
>   }
>  
> + if (netdev->hwaddr)
> + free(netdev->hwaddr);
> + netdev->hwaddr = hwaddr;
>   return 0;
>  }
>  
> @@ -519,17 +523,21 @@ static int config_network_mtu(const char *key, char 
> *value,
> struct lxc_conf *lxc_conf)
>  {
>   struct lxc_netdev *netdev;
> + char *mtu;
>  
>   netdev = network_netdev(key, value, &lxc_conf->network);
>   if (!netdev)
>   return -1;
>  
> - netdev->mtu = strdup(value);
> - if (!netdev->mtu) {
> + mtu = strdup(value);
> + if (!mtu) {
>   SYSERROR("failed to dup string '%s'", value);
>   return -1;
>   }
>  
> + if (netdev->mtu)
> + free(netdev->mtu);
> + netdev->mtu = mtu;
>   return 0;
>  }
>  
> @@ -785,6 +793,8 @@ static int config_seccomp(const char *key, char *value,
>   return -1;
>   }
>  
> + if (lxc_conf->seccomp)
> + free(lxc_conf->seccomp);
>   lxc_conf->seccomp = path;
>  
>   return 0;
> @@ -857,6 +867,8 @@ static int config_ttydir(const char *key, char *value,
>   return -1;
>   }
>  
> + if (lxc_conf->ttydir)
> + free(lxc_conf->ttydir);
>   lxc_conf->ttydir = path;
>  
>   return 0;
> @@ -875,6 +887,8 @@ static int config_aa_profile(const char *key, char 
> *value, struct lxc_conf *lxc_
>   return -1;
>   }
>  
> + if (lxc_conf->aa_profile)
> + free(lxc_conf->aa_profile);
>   lxc_conf->aa_profile = path;
>  
>   return 0;
> @@ -939,22 +953,33 @@ out:
>   return -1;
>  }
>  
> -static int config_fstab(const char *key, char *value, struct lxc_conf 
> *lxc_conf)
> +static int config_path_item(const char *key, const char *value,
> + struct lxc_conf *lxc_conf, char **conf_item)
>  {
> + char *valdup;
>   if (strlen(value) >= MAXPATHLEN) {
>   ERROR("%s path is too long", value);
>   return -1;
>   }
>  
> - lxc_conf->fstab = strdup(value);
> - if (!lxc_conf->fstab) {
> + valdup = strdup(value);
> + if (!valdup) {
>   SYSERROR("failed to duplicate string %s", value);
>   return -1;
>   }
> + if (*conf_item)
> + free(*conf_item);
> + *conf_item = valdup;
>  
>   return 0;
>  }
>  
> +static int config_fstab(const char *key, const char *value,
> + struct lxc_conf *lxc_conf)
> +{
> + return config_path_item(key, value, lxc_conf, &lxc_conf->fstab);
> +}
> +
>  static int config_mount(const char *key, char *value, struct lxc_conf 
> *lxc_conf)
>  {
>   char *fstab_token = "lxc.mount";
> @@ -994,7 +1019,7 @@ static int config_mount(const char *key, char *value, 
> struct lxc_conf *lxc_c

Re: [lxc-devel] [PATCH] Ensure argv passed by createl to create is NULL terminated

2012-11-26 Thread Serge Hallyn
Quoting Dwight Engen (dwight.en...@oracle.com):
> Signed-off-by: Dwight Engen 

Acked-by: Serge E. Hallyn 

> ---
>  src/lxc/lxccontainer.c |3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index 37f5ed7..4818b2c 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -683,13 +683,14 @@ static bool lxcapi_createl(struct lxc_container *c, 
> char *t, ...)
>   if (!arg)
>   break;
>   nargs++;
> - temp = realloc(args, nargs * sizeof(*args));
> + temp = realloc(args, (nargs+1) * sizeof(*args));
>   if (!temp)
>   goto out;
>   args = temp;
>   args[nargs - 1] = arg;
>   }
>   va_end(ap);
> + args[nargs] = NULL;
>  
>   bret = c->create(c, t, args);
>  
> -- 
> 1.7.1
> 
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Free allocated configuration memory

2012-11-26 Thread Stéphane Graber
On 11/26/2012 01:07 PM, Serge Hallyn wrote:
> Quoting Dwight Engen (dwight.en...@oracle.com):
>> Most of these were found with valgrind by repeatedly doing lxc_container_new
>> followed by lxc_container_put. Also free memory when config items are
>> re-parsed, as happens when lxcapi_set_config_item() is called. Refactored
>> path type config items to use a common underlying routine.
>>
>> Signed-off-by: Dwight Engen 
> 
> Thanks, Dwight.
> 
> Acked-by: Serge E. Hallyn 

Thanks, applied to staging.

>> ---
>>  src/lxc/conf.c |9 +
>>  src/lxc/confile.c  |   93 
>> +--
>>  src/lxc/lxccontainer.c |   13 ---
>>  3 files changed, 59 insertions(+), 56 deletions(-)
>>
>> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
>> index fe574ac..5ff64f6 100644
>> --- a/src/lxc/conf.c
>> +++ b/src/lxc/conf.c
>> @@ -2396,6 +2396,7 @@ static void lxc_remove_nic(struct lxc_list *it)
>>  free(it2->elem);
>>  free(it2);
>>  }
>> +free(netdev);
>>  free(it);
>>  }
>>  
>> @@ -2578,6 +2579,14 @@ void lxc_conf_free(struct lxc_conf *conf)
>>  free(conf->console.path);
>>  if (conf->rootfs.mount != default_rootfs_mount)
>>  free(conf->rootfs.mount);
>> +if (conf->rootfs.path)
>> +free(conf->rootfs.path);
>> +if (conf->utsname)
>> +free(conf->utsname);
>> +if (conf->ttydir)
>> +free(conf->ttydir);
>> +if (conf->fstab)
>> +free(conf->fstab);
>>  lxc_clear_config_network(conf);
>>  #if HAVE_APPARMOR
>>  if (conf->aa_profile)
>> diff --git a/src/lxc/confile.c b/src/lxc/confile.c
>> index cf1c891..bacad01 100644
>> --- a/src/lxc/confile.c
>> +++ b/src/lxc/confile.c
>> @@ -486,17 +486,21 @@ static int config_network_hwaddr(const char *key, char 
>> *value,
>>   struct lxc_conf *lxc_conf)
>>  {
>>  struct lxc_netdev *netdev;
>> +char *hwaddr;
>>  
>>  netdev = network_netdev(key, value, &lxc_conf->network);
>>  if (!netdev)
>>  return -1;
>>  
>> -netdev->hwaddr = strdup(value);
>> -if (!netdev->hwaddr) {
>> +hwaddr = strdup(value);
>> +if (!hwaddr) {
>>  SYSERROR("failed to dup string '%s'", value);
>>  return -1;
>>  }
>>  
>> +if (netdev->hwaddr)
>> +free(netdev->hwaddr);
>> +netdev->hwaddr = hwaddr;
>>  return 0;
>>  }
>>  
>> @@ -519,17 +523,21 @@ static int config_network_mtu(const char *key, char 
>> *value,
>>struct lxc_conf *lxc_conf)
>>  {
>>  struct lxc_netdev *netdev;
>> +char *mtu;
>>  
>>  netdev = network_netdev(key, value, &lxc_conf->network);
>>  if (!netdev)
>>  return -1;
>>  
>> -netdev->mtu = strdup(value);
>> -if (!netdev->mtu) {
>> +mtu = strdup(value);
>> +if (!mtu) {
>>  SYSERROR("failed to dup string '%s'", value);
>>  return -1;
>>  }
>>  
>> +if (netdev->mtu)
>> +free(netdev->mtu);
>> +netdev->mtu = mtu;
>>  return 0;
>>  }
>>  
>> @@ -785,6 +793,8 @@ static int config_seccomp(const char *key, char *value,
>>  return -1;
>>  }
>>  
>> +if (lxc_conf->seccomp)
>> +free(lxc_conf->seccomp);
>>  lxc_conf->seccomp = path;
>>  
>>  return 0;
>> @@ -857,6 +867,8 @@ static int config_ttydir(const char *key, char *value,
>>  return -1;
>>  }
>>  
>> +if (lxc_conf->ttydir)
>> +free(lxc_conf->ttydir);
>>  lxc_conf->ttydir = path;
>>  
>>  return 0;
>> @@ -875,6 +887,8 @@ static int config_aa_profile(const char *key, char 
>> *value, struct lxc_conf *lxc_
>>  return -1;
>>  }
>>  
>> +if (lxc_conf->aa_profile)
>> +free(lxc_conf->aa_profile);
>>  lxc_conf->aa_profile = path;
>>  
>>  return 0;
>> @@ -939,22 +953,33 @@ out:
>>  return -1;
>>  }
>>  
>> -static int config_fstab(const char *key, char *value, struct lxc_conf 
>> *lxc_conf)
>> +static int config_path_item(const char *key, const char *value,
>> +struct lxc_conf *lxc_conf, char **conf_item)
>>  {
>> +char *valdup;
>>  if (strlen(value) >= MAXPATHLEN) {
>>  ERROR("%s path is too long", value);
>>  return -1;
>>  }
>>  
>> -lxc_conf->fstab = strdup(value);
>> -if (!lxc_conf->fstab) {
>> +valdup = strdup(value);
>> +if (!valdup) {
>>  SYSERROR("failed to duplicate string %s", value);
>>  return -1;
>>  }
>> +if (*conf_item)
>> +free(*conf_item);
>> +*conf_item = valdup;
>>  
>>  return 0;
>>  }
>>  
>> +static int config_fstab(const char *key, const char *value,
>> +struct lxc_conf *lxc_conf)
>> +{
>> +return config_path_item(key, value, lxc_conf, &lxc_conf->fstab);
>> +}
>> +
>>  static int config_mount(const char *key, char *value, struct lxc_conf 
>> *lxc_c

Re: [lxc-devel] link /dev/kmsg to /dev/console in the container

2012-11-26 Thread William Dauchy
btw, I'm quite surprised to see such a patch between a rc2 and the
final release.

--
William

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] Ensure argv passed by createl to create is NULL terminated

2012-11-26 Thread Stéphane Graber
On 11/26/2012 01:10 PM, Serge Hallyn wrote:
> Quoting Dwight Engen (dwight.en...@oracle.com):
>> Signed-off-by: Dwight Engen 
> 
> Acked-by: Serge E. Hallyn 

Thanks, applied to staging.

>> ---
>>  src/lxc/lxccontainer.c |3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
>> index 37f5ed7..4818b2c 100644
>> --- a/src/lxc/lxccontainer.c
>> +++ b/src/lxc/lxccontainer.c
>> @@ -683,13 +683,14 @@ static bool lxcapi_createl(struct lxc_container *c, 
>> char *t, ...)
>>  if (!arg)
>>  break;
>>  nargs++;
>> -temp = realloc(args, nargs * sizeof(*args));
>> +temp = realloc(args, (nargs+1) * sizeof(*args));
>>  if (!temp)
>>  goto out;
>>  args = temp;
>>  args[nargs - 1] = arg;
>>  }
>>  va_end(ap);
>> +args[nargs] = NULL;
>>  
>>  bret = c->create(c, t, args);
>>  
>> -- 
>> 1.7.1
>>
>>
>> --
>> Monitor your physical, virtual and cloud infrastructure from a single
>> web console. Get in-depth insight into apps, servers, databases, vmware,
>> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
>> Pricing starts from $795 for 25 servers or applications!
>> http://p.sf.net/sfu/zoho_dev2dev_nov
>> ___
>> Lxc-devel mailing list
>> Lxc-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] lxc-info: add option -t, --state-is=STATE to test for a given test

2012-11-26 Thread Natanael Copa
Add an option to test for a give state. This is useful for scripts.
It lets us you do thing like:

 if lxc-info --name myname --state-is RUNNING; then
   ...

Signed-off-by: Natanael Copa 
---
 src/lxc/lxc_info.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
index 809769e..1a1cc22 100644
--- a/src/lxc/lxc_info.c
+++ b/src/lxc/lxc_info.c
@@ -34,12 +34,14 @@
 
 static bool state;
 static bool pid;
+static char *test_state = NULL;
 
 static int my_parser(struct lxc_arguments* args, int c, char* arg)
 {
switch (c) {
case 's': state = true; break;
case 'p': pid = true; break;
+   case 't': test_state = arg; break;
}
return 0;
 }
@@ -47,6 +49,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* 
arg)
 static const struct option my_longopts[] = {
{"state", no_argument, 0, 's'},
{"pid", no_argument, 0, 'p'},
+   {"state-is", required_argument, 0, 't'},
LXC_COMMON_OPTIONS,
 };
 
@@ -58,9 +61,11 @@ static struct lxc_arguments my_args = {
 lxc-info display some information about a container with the identifier NAME\n\
 \n\
 Options :\n\
-  -n, --name=NAME   NAME for name of the container\n\
-  -s, --state   shows the state of the container\n\
-  -p, --pid shows the process id of the init container\n",
+  -n, --name=NAME   NAME for name of the container\n\
+  -s, --state   shows the state of the container\n\
+  -p, --pid shows the process id of the init container\n\
+  -t, --state-is=STATE  test if current state is STATE\n\
+returns success if it matches, false otherwise\n",
.options  = my_longopts,
.parser   = my_parser,
.checker  = NULL,
@@ -81,10 +86,12 @@ int main(int argc, char *argv[])
if (!state && !pid)
state = pid = true;
 
-   if (state) {
+   if (state || test_state) {
ret = lxc_getstate(my_args.name);
if (ret < 0)
return 1;
+   if (test_state)
+   return strcmp(lxc_state2str(ret), test_state) != 0;
 
printf("state:%10s\n", lxc_state2str(ret));
}
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] lxc-info: add option -t, --state-is=STATE to test for a given test

2012-11-26 Thread Serge Hallyn
Quoting Natanael Copa (nc...@alpinelinux.org):
> Add an option to test for a give state. This is useful for scripts.
> It lets us you do thing like:
> 
>  if lxc-info --name myname --state-is RUNNING; then
>...
> 
> Signed-off-by: Natanael Copa 

Acked-by: Serge E. Hallyn 

> ---
>  src/lxc/lxc_info.c | 15 +++
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
> index 809769e..1a1cc22 100644
> --- a/src/lxc/lxc_info.c
> +++ b/src/lxc/lxc_info.c
> @@ -34,12 +34,14 @@
>  
>  static bool state;
>  static bool pid;
> +static char *test_state = NULL;
>  
>  static int my_parser(struct lxc_arguments* args, int c, char* arg)
>  {
>   switch (c) {
>   case 's': state = true; break;
>   case 'p': pid = true; break;
> + case 't': test_state = arg; break;
>   }
>   return 0;
>  }
> @@ -47,6 +49,7 @@ static int my_parser(struct lxc_arguments* args, int c, 
> char* arg)
>  static const struct option my_longopts[] = {
>   {"state", no_argument, 0, 's'},
>   {"pid", no_argument, 0, 'p'},
> + {"state-is", required_argument, 0, 't'},
>   LXC_COMMON_OPTIONS,
>  };
>  
> @@ -58,9 +61,11 @@ static struct lxc_arguments my_args = {
>  lxc-info display some information about a container with the identifier 
> NAME\n\
>  \n\
>  Options :\n\
> -  -n, --name=NAME   NAME for name of the container\n\
> -  -s, --state   shows the state of the container\n\
> -  -p, --pid shows the process id of the init container\n",
> +  -n, --name=NAME   NAME for name of the container\n\
> +  -s, --state   shows the state of the container\n\
> +  -p, --pid shows the process id of the init container\n\
> +  -t, --state-is=STATE  test if current state is STATE\n\
> +returns success if it matches, false otherwise\n",
>   .options  = my_longopts,
>   .parser   = my_parser,
>   .checker  = NULL,
> @@ -81,10 +86,12 @@ int main(int argc, char *argv[])
>   if (!state && !pid)
>   state = pid = true;
>  
> - if (state) {
> + if (state || test_state) {
>   ret = lxc_getstate(my_args.name);
>   if (ret < 0)
>   return 1;
> + if (test_state)
> + return strcmp(lxc_state2str(ret), test_state) != 0;
>  
>   printf("state:%10s\n", lxc_state2str(ret));
>   }
> -- 
> 1.8.0
> 
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH] lxc-info: add option -t, --state-is=STATE to test for a given test

2012-11-26 Thread Stéphane Graber
On 11/26/2012 02:25 PM, Serge Hallyn wrote:
> Quoting Natanael Copa (nc...@alpinelinux.org):
>> Add an option to test for a give state. This is useful for scripts.
>> It lets us you do thing like:
>>
>>  if lxc-info --name myname --state-is RUNNING; then
>>...
>>
>> Signed-off-by: Natanael Copa 
> 
> Acked-by: Serge E. Hallyn 

And pushed to staging. Thanks.

>> ---
>>  src/lxc/lxc_info.c | 15 +++
>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
>> index 809769e..1a1cc22 100644
>> --- a/src/lxc/lxc_info.c
>> +++ b/src/lxc/lxc_info.c
>> @@ -34,12 +34,14 @@
>>  
>>  static bool state;
>>  static bool pid;
>> +static char *test_state = NULL;
>>  
>>  static int my_parser(struct lxc_arguments* args, int c, char* arg)
>>  {
>>  switch (c) {
>>  case 's': state = true; break;
>>  case 'p': pid = true; break;
>> +case 't': test_state = arg; break;
>>  }
>>  return 0;
>>  }
>> @@ -47,6 +49,7 @@ static int my_parser(struct lxc_arguments* args, int c, 
>> char* arg)
>>  static const struct option my_longopts[] = {
>>  {"state", no_argument, 0, 's'},
>>  {"pid", no_argument, 0, 'p'},
>> +{"state-is", required_argument, 0, 't'},
>>  LXC_COMMON_OPTIONS,
>>  };
>>  
>> @@ -58,9 +61,11 @@ static struct lxc_arguments my_args = {
>>  lxc-info display some information about a container with the identifier 
>> NAME\n\
>>  \n\
>>  Options :\n\
>> -  -n, --name=NAME   NAME for name of the container\n\
>> -  -s, --state   shows the state of the container\n\
>> -  -p, --pid shows the process id of the init container\n",
>> +  -n, --name=NAME   NAME for name of the container\n\
>> +  -s, --state   shows the state of the container\n\
>> +  -p, --pid shows the process id of the init container\n\
>> +  -t, --state-is=STATE  test if current state is STATE\n\
>> +returns success if it matches, false otherwise\n",
>>  .options  = my_longopts,
>>  .parser   = my_parser,
>>  .checker  = NULL,
>> @@ -81,10 +86,12 @@ int main(int argc, char *argv[])
>>  if (!state && !pid)
>>  state = pid = true;
>>  
>> -if (state) {
>> +if (state || test_state) {
>>  ret = lxc_getstate(my_args.name);
>>  if (ret < 0)
>>  return 1;
>> +if (test_state)
>> +return strcmp(lxc_state2str(ret), test_state) != 0;
>>  
>>  printf("state:%10s\n", lxc_state2str(ret));
>>  }
>> -- 
>> 1.8.0
>>
>>
>> --
>> Monitor your physical, virtual and cloud infrastructure from a single
>> web console. Get in-depth insight into apps, servers, databases, vmware,
>> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
>> Pricing starts from $795 for 25 servers or applications!
>> http://p.sf.net/sfu/zoho_dev2dev_nov
>> ___
>> Lxc-devel mailing list
>> Lxc-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH 1/1] fix lxc-ubuntu-cloud option parsing bugs

2012-11-26 Thread Serge Hallyn
The -u shortopt matching --userdata was not specified, and when -L
is found shift should have been by 1 not 2 since there is no optarg.

Signed-off-by: Serge Hallyn 
---
 templates/lxc-ubuntu-cloud.in |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
index 8df05da..300b47d 100644
--- a/templates/lxc-ubuntu-cloud.in
+++ b/templates/lxc-ubuntu-cloud.in
@@ -131,7 +131,7 @@ EOF
 return 0
 }
 
-options=$(getopt -o a:hp:r:n:Fi:CLS:T:ds: -l 
arch:,help,path:,release:,name:,flush-cache,hostid:,auth-key:,cloud,no_locales,tarball:,debug,stream:,userdata:
 -- "$@")
+options=$(getopt -o a:hp:r:n:Fi:CLS:T:ds:u: -l 
arch:,help,path:,release:,name:,flush-cache,hostid:,auth-key:,cloud,no_locales,tarball:,debug,stream:,userdata:
 -- "$@")
 if [ $? -ne 0 ]; then
 usage $(basename $0)
 exit 1
@@ -189,7 +189,7 @@ do
 -u|--userdata) userdata=$2; shift 2;;
 -C|--cloud)cloud=1; shift 1;;
 -S|--auth-key) auth_key=$2; shift 2;;
--L|--no_locales)   locales=0; shift 2;;
+-L|--no_locales)   locales=0; shift 1;;
 -T|--tarball)  tarball=$2; shift 2;;
 -d|--debug)debug=1; shift 1;;
 -s|--stream)   stream=$2; shift 2;;
-- 
1.7.9.5


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


Re: [lxc-devel] [PATCH 1/1] fix lxc-ubuntu-cloud option parsing bugs

2012-11-26 Thread Stéphane Graber
On 11/26/2012 03:08 PM, Serge Hallyn wrote:
> The -u shortopt matching --userdata was not specified, and when -L
> is found shift should have been by 1 not 2 since there is no optarg.
> 
> Signed-off-by: Serge Hallyn 

Acked-by: Stéphane Graber 

Pushed to staging. Thanks

> ---
>  templates/lxc-ubuntu-cloud.in |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
> index 8df05da..300b47d 100644
> --- a/templates/lxc-ubuntu-cloud.in
> +++ b/templates/lxc-ubuntu-cloud.in
> @@ -131,7 +131,7 @@ EOF
>  return 0
>  }
>  
> -options=$(getopt -o a:hp:r:n:Fi:CLS:T:ds: -l 
> arch:,help,path:,release:,name:,flush-cache,hostid:,auth-key:,cloud,no_locales,tarball:,debug,stream:,userdata:
>  -- "$@")
> +options=$(getopt -o a:hp:r:n:Fi:CLS:T:ds:u: -l 
> arch:,help,path:,release:,name:,flush-cache,hostid:,auth-key:,cloud,no_locales,tarball:,debug,stream:,userdata:
>  -- "$@")
>  if [ $? -ne 0 ]; then
>  usage $(basename $0)
>  exit 1
> @@ -189,7 +189,7 @@ do
>  -u|--userdata) userdata=$2; shift 2;;
>  -C|--cloud)cloud=1; shift 1;;
>  -S|--auth-key) auth_key=$2; shift 2;;
> --L|--no_locales)   locales=0; shift 2;;
> +-L|--no_locales)   locales=0; shift 1;;
>  -T|--tarball)  tarball=$2; shift 2;;
>  -d|--debug)debug=1; shift 1;;
>  -s|--stream)   stream=$2; shift 2;;
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] Make config api items const

2012-11-26 Thread Dwight Engen
This makes it easier to write a binding, and presents a cleaner API. Use
strdupa in a few places to get mutable strings for tokenizing / parsing.
Also change the argv type in lxcapi_start and lxcapi_create to match
that of execv(3).

Signed-off-by: Dwight Engen 
---
 src/lxc/conf.c |   10 ++--
 src/lxc/conf.h |6 +-
 src/lxc/confile.c  |  168 ++--
 src/lxc/confile.h  |8 +-
 src/lxc/lxc.h  |2 +-
 src/lxc/lxccontainer.c |   24 
 src/lxc/lxccontainer.h |   20 +++---
 src/lxc/lxclock.c  |4 +-
 src/lxc/lxclock.h  |2 +-
 src/lxc/state.c|   16 -
 src/lxc/state.h|2 +-
 11 files changed, 143 insertions(+), 119 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 0753221..eb0c07e 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2478,7 +2478,7 @@ static void lxc_remove_nic(struct lxc_list *it)
 }
 
 /* we get passed in something like '0', '0.ipv4' or '1.ipv6' */
-int lxc_clear_nic(struct lxc_conf *c, char *key)
+int lxc_clear_nic(struct lxc_conf *c, const char *key)
 {
char *p1;
int ret, idx, i;
@@ -2586,11 +2586,11 @@ int lxc_clear_config_caps(struct lxc_conf *c)
return 0;
 }
 
-int lxc_clear_cgroups(struct lxc_conf *c, char *key)
+int lxc_clear_cgroups(struct lxc_conf *c, const char *key)
 {
struct lxc_list *it,*next;
bool all = false;
-   char *k = key + 11;
+   const char *k = key + 11;
 
if (strcmp(key, "lxc.cgroup") == 0)
all = true;
@@ -2620,11 +2620,11 @@ int lxc_clear_mount_entries(struct lxc_conf *c)
return 0;
 }
 
-int lxc_clear_hooks(struct lxc_conf *c, char *key)
+int lxc_clear_hooks(struct lxc_conf *c, const char *key)
 {
struct lxc_list *it,*next;
bool all = false, done = false;
-   char *k = key + 9;
+   const char *k = key + 9;
int i;
 
if (strcmp(key, "lxc.hook") == 0)
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 76bf19d..535823d 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -259,11 +259,11 @@ extern int lxc_create_tty(const char *name, struct 
lxc_conf *conf);
 extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
 
 extern int lxc_clear_config_network(struct lxc_conf *c);
-extern int lxc_clear_nic(struct lxc_conf *c, char *key);
+extern int lxc_clear_nic(struct lxc_conf *c, const char *key);
 extern int lxc_clear_config_caps(struct lxc_conf *c);
-extern int lxc_clear_cgroups(struct lxc_conf *c, char *key);
+extern int lxc_clear_cgroups(struct lxc_conf *c, const char *key);
 extern int lxc_clear_mount_entries(struct lxc_conf *c);
-extern int lxc_clear_hooks(struct lxc_conf *c, char *key);
+extern int lxc_clear_hooks(struct lxc_conf *c, const char *key);
 
 /*
  * Configure the container from inside
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index c1cb693..bc55f8c 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -20,6 +20,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+#define _GNU_SOURCE
 #include 
 #include 
 #include 
@@ -46,40 +47,40 @@
 
 lxc_log_define(lxc_confile, lxc);
 
-static int config_personality(const char *, char *, struct lxc_conf *);
-static int config_pts(const char *, char *, struct lxc_conf *);
-static int config_tty(const char *, char *, struct lxc_conf *);
-static int config_ttydir(const char *, char *, struct lxc_conf *);
+static int config_personality(const char *, const char *, struct lxc_conf *);
+static int config_pts(const char *, const char *, struct lxc_conf *);
+static int config_tty(const char *, const char *, struct lxc_conf *);
+static int config_ttydir(const char *, const char *, struct lxc_conf *);
 #if HAVE_APPARMOR
-static int config_aa_profile(const char *, char *, struct lxc_conf *);
+static int config_aa_profile(const char *, const char *, struct lxc_conf *);
 #endif
-static int config_cgroup(const char *, char *, struct lxc_conf *);
-static int config_mount(const char *, char *, struct lxc_conf *);
-static int config_rootfs(const char *, char *, struct lxc_conf *);
-static int config_rootfs_mount(const char *, char *, struct lxc_conf *);
-static int config_pivotdir(const char *, char *, struct lxc_conf *);
-static int config_utsname(const char *, char *, struct lxc_conf *);
-static int config_hook(const char *key, char *value, struct lxc_conf 
*lxc_conf);
-static int config_network_type(const char *, char *, struct lxc_conf *);
-static int config_network_flags(const char *, char *, struct lxc_conf *);
-static int config_network_link(const char *, char *, struct lxc_conf *);
-static int config_network_name(const char *, char *, struct lxc_conf *);
-static int config_network_veth_pair(const char *, char *, struct lxc_conf *);
-static int config_network_macvlan_mode(const char *, char *, struct lxc_conf 
*);
-static int config_network_hwaddr(const char 

[lxc-devel] [PATCH] Use autoconf LXCPATH instead of hardcoded LXCDIR

2012-11-26 Thread Dwight Engen
LXCDIR is only used in lxc_container_new, whereas LXCPATH is used throughout
the rest of lxc, and even in the same file as lxc_container_new (for example
create_container_dir()).

Signed-off-by: Dwight Engen 
---
 src/lxc/lxccontainer.c |6 +++---
 src/lxc/lxccontainer.h |1 -
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index ed2c483..cc91e05 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -882,13 +882,13 @@ struct lxc_container *lxc_container_new(char *name)
goto err;
}
 
-   len = strlen(LXCDIR)+strlen(c->name)+strlen("/config")+2;
+   len = strlen(LXCPATH)+strlen(c->name)+strlen("/config")+2;
c->configfile = malloc(len);
if (!c->configfile) {
fprintf(stderr, "Error allocating config file pathname\n");
goto err;
}
-   ret = snprintf(c->configfile, len, "%s/%s/config", LXCDIR, c->name);
+   ret = snprintf(c->configfile, len, "%s/%s/config", LXCPATH, c->name);
if (ret < 0 || ret >= len) {
fprintf(stderr, "Error printing out config file name\n");
goto err;
@@ -928,7 +928,7 @@ struct lxc_container *lxc_container_new(char *name)
}
 
/*
-* default configuration file is $LXCDIR/$NAME/config
+* default configuration file is $LXCPATH/$NAME/config
 */
 
return c;
diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h
index cad31ee..9e4267a 100644
--- a/src/lxc/lxccontainer.h
+++ b/src/lxc/lxccontainer.h
@@ -18,7 +18,6 @@ struct lxc_container {
int error_num;
int daemonize;
 
-#define LXCDIR "/var/lib/lxc"
bool (*is_defined)(struct lxc_container *c);  // did 
/var/lib/lxc/$name/config exist
const char *(*state)(struct lxc_container *c);
bool (*is_running)(struct lxc_container *c);  // true so long as 
defined and not stopped
-- 
1.7.1


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] lxc-version: use POSIX shell instead of bash

2012-11-26 Thread Natanael Copa
There is no reason to depend on bash for a single echo.
---
Should we move this to lxc-info --version?

 src/lxc/lxc-version.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc-version.in b/src/lxc/lxc-version.in
index 1bd055a..b6875da 100644
--- a/src/lxc/lxc-version.in
+++ b/src/lxc/lxc-version.in
@@ -1,3 +1,3 @@
-#!/bin/bash
+#!/bin/sh
 
 echo "lxc version: @PACKAGE_VERSION@"
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] lxc-setcap: use POSIX shell instead of bash

2012-11-26 Thread Natanael Copa
Avoid getopt --longoptions

Signed-off-by: Natanael Copa 
---
 src/lxc/lxc-setcap.in | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/lxc/lxc-setcap.in b/src/lxc/lxc-setcap.in
index 7fd390c..02c1e09 100644
--- a/src/lxc/lxc-setcap.in
+++ b/src/lxc/lxc-setcap.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 #
 # lxc: linux Container library
@@ -81,32 +81,40 @@ lxc_dropcaps()
 chmod 0755 @LXCPATH@
 }
 
-shortoptions='hd'
-longoptions='help'
-
-getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- "$@")
-if [ $? != 0 ]; then
+usage_err() {
+[ -n "$1" ] && echo "$1" >&2
 usage
 exit 1
-fi
+}
 
-eval set -- "$getopt"
+optarg_check() {
+if [ -z "$2" ]; then
+usage_err "option '$1' requires an argument"
+fi
+}
 
-while true; do
-case "$1" in
+while [ $# -gt 0 ]; do
+opt="$1"
+shift
+case "$opt" in
-d)
LXC_DROP_CAPS="yes"
-   shift
;;
-h|--help)
help
exit 0
;;
--)
-   shift
break
;;
-   *)
+-?)
+usage_err "unknown option '$opt'"
+;;
+-*)
+# split opts -abc into -a -b -c
+set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
+;;
+ *)
usage
exit 1
;;
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH] lxc-setuid: use POSIX shell instead of bash

2012-11-26 Thread Natanael Copa
Avoid getop --longoptions.

Signed-off-by: Natanael Copa 
---
 src/lxc/lxc-setuid.in | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/lxc/lxc-setuid.in b/src/lxc/lxc-setuid.in
index 84f18af..e6a7b96 100644
--- a/src/lxc/lxc-setuid.in
+++ b/src/lxc/lxc-setuid.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 #
 # lxc: linux Container library
@@ -78,32 +78,40 @@ lxc_dropuid()
 chmod 0755 @LXCPATH@
 }
 
-shortoptions='hd'
-longoptions='help'
-
-getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- "$@")
-if [ $? != 0 ]; then
+usage_err() {
+[ -n "$1" ] && echo "$1" >&2
 usage
 exit 1
-fi
+}
 
-eval set -- "$getopt"
+optarg_check() {
+if [ -z "$2" ]; then
+usage_err "option '$1' requires an argument"
+fi
+}
 
-while true; do
-case "$1" in
+while [ $# -gt 0 ]; do
+opt="$1"
+shift
+case "$opt" in
-d)
LXC_DROP_CAPS="yes"
-   shift
;;
-h|--help)
help
exit 0
;;
--)
-   shift
break
;;
-   *)
+-?)
+usage_err "unknown option '$opt'"
+;;
+-*)
+# split opts -abc into -a -b -c
+set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
+;;
+ *)
usage
exit 1
;;
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH v2] lxc-version: use POSIX shell instead of bash

2012-11-26 Thread Natanael Copa
There is no reason to depend on bash for a single echo.

Signed-off-by: Natanael Copa 
---
Changes v1 -> v2:
 - add signed-off-by

 src/lxc/lxc-version.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc-version.in b/src/lxc/lxc-version.in
index 1bd055a..b6875da 100644
--- a/src/lxc/lxc-version.in
+++ b/src/lxc/lxc-version.in
@@ -1,3 +1,3 @@
-#!/bin/bash
+#!/bin/sh
 
 echo "lxc version: @PACKAGE_VERSION@"
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH v2] lxc-checkconfig: use POSIX shell instead of bash

2012-11-26 Thread Natanael Copa
- replace 'echo -e' with printf
- replace 'if [[ ... ]]' with 'if [ ... ]'
- add \ at after && and || when those are at end of line

Signed-off-by: Natanael Copa 
---
Changes v1 -> v2:
 - rebase against current staging

 src/lxc/lxc-checkconfig.in | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/lxc/lxc-checkconfig.in b/src/lxc/lxc-checkconfig.in
index 7dd6476..d17bb95 100644
--- a/src/lxc/lxc-checkconfig.in
+++ b/src/lxc/lxc-checkconfig.in
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/bin/sh
 
 # Allow environment variables to override grep and config
 : ${CONFIG:=/proc/config.gz}
 : ${GREP:=zgrep}
 
-SETCOLOR_SUCCESS="echo -en \\033[1;32m"
-SETCOLOR_FAILURE="echo -en \\033[1;31m"
-SETCOLOR_WARNING="echo -en \\033[1;33m"
-SETCOLOR_NORMAL="echo -en \\033[0;39m"
+SETCOLOR_SUCCESS="printf \\e[1;32m"
+SETCOLOR_FAILURE="printf \\e[1;31m"
+SETCOLOR_WARNING="printf \\e[1;33m"
+SETCOLOR_NORMAL="printf \\e[0;39m"
 
 is_set() {
 $GREP -q "$1=[y|m]" $CONFIG
@@ -21,12 +21,12 @@ is_enabled() {
 RES=$?
 
 if [ $RES -eq 0 ]; then
-   $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
+   $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
 else
if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
-   $SETCOLOR_FAILURE && echo -e "required" && $SETCOLOR_NORMAL
+   $SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL
else
-   $SETCOLOR_WARNING && echo -e "missing" && $SETCOLOR_NORMAL
+   $SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL
fi
 fi
 }
@@ -70,7 +70,7 @@ print_cgroups() {
 CGROUP_MNT_PATH=`print_cgroups cgroup /proc/self/mounts | head -1`
 KVER_MAJOR=$($GREP '^# Linux' $CONFIG | \
 sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
-if [[ $KVER_MAJOR == 2 ]]; then
+if [ "$KVER_MAJOR" = "2" ]; then
 KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
 sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
 else
@@ -82,7 +82,7 @@ echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS yes
 
 if [ -f $CGROUP_MNT_PATH/cgroup.clone_children ]; then
 echo -n "Cgroup clone_children flag: " &&
-$SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
+$SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
 else
 echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS yes
 fi
@@ -101,12 +101,12 @@ echo "--- Misc ---"
 echo -n "Veth pair device: " && is_enabled CONFIG_VETH
 echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN
 echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q
-echo -n "File capabilities: " &&
-( [[ ${KVER_MAJOR} == 2 && ${KVER_MINOR} < 33 ]] &&
-   is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ) ||
-( [[ ( ${KVER_MAJOR} == 2 && ${KVER_MINOR} > 32 ) ||
- ${KVER_MAJOR} > 2 ]] && $SETCOLOR_SUCCESS &&
- echo -e "enabled" && $SETCOLOR_NORMAL )
+echo -n "File capabilities: " && \
+( [ "${KVER_MAJOR}" = 2 ] && [ ${KVER_MINOR} -lt 33 ] && \
+   is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ) || \
+( ( [ "${KVER_MAJOR}" = "2" ] && [ ${KVER_MINOR} -gt 32 ] ) || \
+ [ ${KVER_MAJOR} -gt 2 ] && $SETCOLOR_SUCCESS && \
+ echo "enabled" && $SETCOLOR_NORMAL )
 
 echo
 echo "Note : Before booting a new kernel, you can check its configuration"
-- 
1.8.0


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel