47a01f461c99eaab928a60f81c4d67f60f7059ea
[libvirt.git] / selinux-mkdir.patch
1 libvirt lxc will fail to start when selinux is disabled.
2 error: Failed to start domain noroot
3 error: internal error guest failed to start: PATH=/bin:/sbin TERM=linux container=lxc-libvirt container_uuid=b9873916-3516-c199-8112-1592ff694a9e LIBVIRT_LXC_UUID=b9873916-3516-c199-8112-1592ff694a9e LIBVIRT_LXC_NAME=noroot /bin/sh
4 2013-01-09 11:04:05.384+0000: 1: info : libvirt version: 1.0.1
5 2013-01-09 11:04:05.384+0000: 1: error : lxcContainerMountBasicFS:546 : Failed to mkdir /sys/fs/selinux: No such file or directory
6 2013-01-09 11:04:05.384+0000: 7536: info : libvirt version: 1.0.1
7 2013-01-09 11:04:05.384+0000: 7536: error : virLXCControllerRun:1466 : error receiving signal from container: Input/output error
8 2013-01-09 11:04:05.404+0000: 7536: error : virCommandWait:2287 : internal error Child process (ip link del veth1) unexpected exit status 1: Cannot find device "veth1"
9
10 fix this problem by checking if selinuxfs is mounted
11 in host before we try to create dir /sys/fs/selinux.
12
13 Signed-off-by: Gao feng <gaofeng cn fujitsu com>
14 ---
15  src/lxc/lxc_container.c | 14 +++++++-------
16  1 file changed, 7 insertions(+), 7 deletions(-)
17
18 diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
19 index 9f22923..d7f4960 100644
20 --- a/src/lxc/lxc_container.c
21 +++ b/src/lxc/lxc_container.c
22 @@ -540,13 +540,6 @@ static int lxcContainerMountBasicFS(bool pivotRoot,
23          VIR_DEBUG("Processing %s -> %s",
24                    mnts[i].src, mnts[i].dst);
25  
26 -        if (virFileMakePath(mnts[i].dst) < 0) {
27 -            virReportSystemError(errno,
28 -                                 _("Failed to mkdir %s"),
29 -                                 mnts[i].src);
30 -            goto cleanup;
31 -        }
32 -
33          srcpath = mnts[i].src;
34  
35          /* Skip if mount doesn't exist in source */
36 @@ -554,6 +547,13 @@ static int lxcContainerMountBasicFS(bool pivotRoot,
37              (access(srcpath, R_OK) < 0))
38              continue;
39  
40 +        if (virFileMakePath(mnts[i].dst) < 0) {
41 +            virReportSystemError(errno,
42 +                                 _("Failed to mkdir %s"),
43 +                                 mnts[i].src);
44 +            goto cleanup;
45 +        }
46 +
47          VIR_DEBUG("Mount %s on %s type=%s flags=%x, opts=%s",
48                    srcpath, mnts[i].dst, mnts[i].type, mnts[i].mflags, mnts[i].opts);
49          if (mount(srcpath, mnts[i].dst, mnts[i].type, mnts[i].mflags, mnts[i].opts) < 0) {