[Libvir] A sample program to create a Linux Container

Dave Leskovec dlesko at linux.vnet.ibm.com
Fri Jan 25 00:06:17 UTC 2008


Attached is a simple program that uses the clone() function to create a 
container.  This is not intended as a patch - just an example of what 
creating a Linux Container looks like.  Something along these lines will 
be used by the Linux Container driver to start the domain.  The code run 
within this container is really simple.  It just mounts the /proc file 
system and then dumps the ps output to a file showing that the container 
is in separate process space.

To run this you will need to have PID namespaces support enabled.  Turn 
on CONFIG_PID_NS when compiling the kernel.  You must run the program as 
root or the clone() call will fail.

Any questions or comments are welcome.  Thanks!

-- 
Best Regards,
Dave Leskovec
IBM Linux Technology Center
Open Virtualization

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lxc_exec.c
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20080124/09b089c7/attachment-0001.c>


More information about the libvir-list mailing list