[libvirt] Environmental Variables inside a container

Devendra K. Modium dmodium at isi.edu
Wed Jul 27 18:44:35 UTC 2011

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);

    return cmd;

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.
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.

Thanks for your time.


More information about the libvir-list mailing list