提交 bfc48afa 编写于 作者: D Daniel Veillard

cope with kernels where CLONE_NEWUSER is not supported

* src/lxc_container.c src/lxc_container.h: cope with kernels
  where CLONE_NEWUSER is not supported, patch by Serge Hallyn
daniel
上级 a4b1c097
Mon Apr 20 14:25:41 CEST 2009 Daniel Veillard <veillard@redhat.com>
* src/lxc_container.c src/lxc_container.h: cope with kernels
where CLONE_NEWUSER is not supported, patch by Serge Hallyn
Mon Apr 20 12:54:02 GMT 2009 Mark McLoughlin <markmc@redhat.com>
* docs/virsh.pod, virsh.1: fix typo reported by Robert P. J. Day
......
......@@ -277,7 +277,7 @@ static int lxcContainerChildMountSort(const void *a, const void *b)
#endif
#ifndef MS_SLAVE
#define MS_SLAVE (1<<19)
#define MS_SLAVE (1<<19)
#endif
static int lxcContainerPivotRoot(virDomainFSDefPtr root)
......@@ -666,6 +666,11 @@ static int lxcContainerChild( void *data )
return lxcContainerExecInit(vmDef);
}
static int userns_supported(void)
{
return lxcContainerAvailable(LXC_CONTAINER_FEATURE_USER) == 0;
}
/**
* lxcContainerStart:
* @driver: pointer to driver structure
......@@ -694,7 +699,10 @@ int lxcContainerStart(virDomainDefPtr def,
}
stacktop = stack + stacksize;
flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWUSER|CLONE_NEWIPC|SIGCHLD;
flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|SIGCHLD;
if (userns_supported())
flags |= CLONE_NEWUSER;
if (def->nets != NULL)
flags |= CLONE_NEWNET;
......@@ -719,13 +727,16 @@ static int lxcContainerDummyChild(void *argv ATTRIBUTE_UNUSED)
int lxcContainerAvailable(int features)
{
int flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWUSER|
int flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|
CLONE_NEWIPC|SIGCHLD;
int cpid;
char *childStack;
char *stack;
int childStatus;
if (features & LXC_CONTAINER_FEATURE_USER)
flags |= CLONE_NEWUSER;
if (features & LXC_CONTAINER_FEATURE_NET)
flags |= CLONE_NEWNET;
......
......@@ -28,6 +28,7 @@
enum {
LXC_CONTAINER_FEATURE_NET = (1 << 0),
LXC_CONTAINER_FEATURE_USER = (1 << 1),
};
#define LXC_DEV_MAJ_MEMORY 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册