
On Thu, Mar 20, 2008 at 12:11:39PM -0400, Daniel Veillard wrote:
On Wed, Mar 19, 2008 at 11:14:59PM -0700, Dave Leskovec wrote:
This patch adds the lxc_driver source files. [...] +static int lxcCheckContainerSupport( void ) +{ + int rc = 0; + int flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWUSER| + CLONE_NEWIPC|SIGCHLD; + int cpid; + char *childStack; + char *stack; + int childStatus; + + stack = malloc(getpagesize() * 4); + if(!stack) { + DEBUG0("Unable to allocate stack"); + rc = -1; + goto check_complete; + } + + childStack = stack + (getpagesize() * 4); + + cpid = clone(lxcDummyChild, childStack, flags, NULL); + if ((0 > cpid) && (EINVAL == errno)) { + DEBUG0("clone call returned EINVAL, container support is not enabled"); + rc = -1;
haha, I would have expected a checking of /proc or something similar. That test could still fail, say if the kernel started to disagree on stack of only 4 pages for example.
If there was insufficient mem it would return ENOMEM. The EINVAL errors are all related to invalid flags, so this is a reasonable check. Dan. -- |: Red Hat, Engineering, Boston -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 :|