[libvirt] [PATCH] LXC complement PATH environment variable of a controller

Hi, lxc controller usually executes 'ip' command to control veths, however now PATH environment variable of the controller is not set (logging code resets environment variables all) and the execution will definitely fail because the controller cannot find the executable. This patch complements PATH with driver's one. The code is just copied from qemu_conf.c Thanks, ozaki-r
From c98136628c1ea0964191be976b23ac99d0f7bb7b Mon Sep 17 00:00:00 2001 From: Ryota Ozaki <ozaki.ryota@gmail.com> Date: Wed, 14 Oct 2009 05:09:04 +0900 Subject: [PATCH] LXC complement PATH environment variable of a controller
* src/lxc/lxc_driver.c: without PATH, the controller will definitely fail to call ip command --- src/lxc/lxc_driver.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 0b614e3..783dfcc 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1005,6 +1005,19 @@ static int lxcControllerStart(virConnectPtr conn, lenv[lenvc++] = envval; ¥ } while (0) +#define ADD_ENV_COPY(envname) ¥ + do { ¥ + char *val = getenv(envname); ¥ + if (val != NULL) { ¥ + ADD_ENV_PAIR(envname, val); ¥ + } ¥ + } while (0) + + /* + * The controller may call ip command, so we have to remain PATH. + */ + ADD_ENV_COPY("PATH"); + log_level = virLogGetDefaultPriority(); if (virAsprintf(&tmp, "LIBVIRT_DEBUG=%d", log_level) < 0) goto no_memory; -- 1.6.2.5

On Wed, Oct 14, 2009 at 06:05:15AM +0900, Ryota Ozaki wrote:
Hi,
lxc controller usually executes 'ip' command to control veths, however now PATH environment variable of the controller is not set (logging code resets environment variables all) and the execution will definitely fail because the controller cannot find the executable.
This patch complements PATH with driver's one. The code is just copied from qemu_conf.c
ACK, looks good Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Wed, Oct 14, 2009 at 06:05:15AM +0900, Ryota Ozaki wrote:
Hi,
lxc controller usually executes 'ip' command to control veths, however now PATH environment variable of the controller is not set (logging code resets environment variables all) and the execution will definitely fail because the controller cannot find the executable.
This patch complements PATH with driver's one. The code is just copied from qemu_conf.c
Looks fine, but I'm afraid it means LXC networking in 0.7.2 is broken :-\ Applied and commited, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Ryota Ozaki wrote: [Tue Oct 13 2009, 05:05:15PM EDT]
Hi,
lxc controller usually executes 'ip' command to control veths, however now PATH environment variable of the controller is not set (logging code resets environment variables all) and the execution will definitely fail because the controller cannot find the executable.
This patch complements PATH with driver's one. The code is just copied from qemu_conf.c
Gah! Thank you for fixing my goof-up...
participants (4)
-
Amy Griffis
-
Daniel P. Berrange
-
Daniel Veillard
-
Ryota Ozaki