On 07/27/2011 12:44 PM, Devendra K. Modium wrote:
Hi All

I am trying to pass an environmental flag to the
LXC container when it is started.I found libvirt_lxc is
already doing it  in lxc_container.c as shown below


static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef)
{
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     virCommandPtr cmd;

     virUUIDFormat(vmDef->uuid, uuidstr);

     cmd = virCommandNew(vmDef->os.init);

     virCommandAddEnvString(cmd, "PATH=/bin:/sbin");
     virCommandAddEnvString(cmd, "TERM=linux-deva");
     virCommandAddEnvPair(cmd, "LIBVIRT_LXC_UUID", uuidstr);
     virCommandAddEnvPair(cmd, "LIBVIRT_LXC_NAME", vmDef->name);

Yes, this list is hard-coded, and only guarantees to affect the environment of the process at the root of the lxc process tree.

But only
TERM flag is getting visible inside the container not remaining.

Does it depends on how /sbin/init is receiving them? Is /sbin/init
only recognizing TERM flag.

Probably something in your lxc process hierarchy is scrubbing environment variables prior to starting additional processes, but that's out of libvirt's control - libvirt can only affect the environment of the parent process.

If so what is intention of sending remaining flags in current libvirt.

Please let me know if there is any elegant way to send environmental
variable to container.

Sounds like it might be an interesting feature to enhance the xml for lxc domains to allow the specification of additional environment variables that should be inherited into the lxc process tree, beyond the few variables already hard-coded by libvirt.

--
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to