43fe83
From 4fdf3d3899e40d74073622f11a8ba2771d16c002 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <4fdf3d3899e40d74073622f11a8ba2771d16c002.1377873638.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Tue, 13 Aug 2013 14:06:57 +0100
43fe83
Subject: [PATCH] Honour root prefix in lxcContainerMountFSBlockAuto
43fe83
43fe83
For https://bugzilla.redhat.com/show_bug.cgi?id=924815
43fe83
43fe83
The lxcContainerMountFSBlockAuto method can be used to mount the
43fe83
initial root filesystem, so it cannot assume a prefix of /.oldroot.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit 2d07f84302eac7656ad6ac227c1e6655b8af1425)
43fe83
---
43fe83
 src/lxc/lxc_container.c | 14 ++++++++------
43fe83
 1 file changed, 8 insertions(+), 6 deletions(-)
43fe83
43fe83
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
43fe83
index a943b22..0ab4026 100644
43fe83
--- a/src/lxc/lxc_container.c
43fe83
+++ b/src/lxc/lxc_container.c
43fe83
@@ -1144,7 +1144,8 @@ lxcContainerMountDetectFilesystem(const char *src ATTRIBUTE_UNUSED,
43fe83
  */
43fe83
 static int lxcContainerMountFSBlockAuto(virDomainFSDefPtr fs,
43fe83
                                         int fsflags,
43fe83
-                                        const char *src)
43fe83
+                                        const char *src,
43fe83
+                                        const char *srcprefix)
43fe83
 {
43fe83
     FILE *fp = NULL;
43fe83
     int ret = -1;
43fe83
@@ -1154,11 +1155,11 @@ static int lxcContainerMountFSBlockAuto(virDomainFSDefPtr fs,
43fe83
     char *line = NULL;
43fe83
     const char *type;
43fe83
 
43fe83
-    VIR_DEBUG("src=%s dst=%s", src, fs->dst);
43fe83
+    VIR_DEBUG("src=%s dst=%s srcprefix=%s", src, fs->dst, srcprefix);
43fe83
 
43fe83
     /* First time around we use /etc/filesystems */
43fe83
 retry:
43fe83
-    if (virAsprintf(&fslist, "/.oldroot%s",
43fe83
+    if (virAsprintf(&fslist, "%s%s", srcprefix,
43fe83
                     tryProc ? "/proc/filesystems" : "/etc/filesystems") < 0)
43fe83
         goto cleanup;
43fe83
 
43fe83
@@ -1270,7 +1271,8 @@ cleanup:
43fe83
  * probing for filesystem type
43fe83
  */
43fe83
 static int lxcContainerMountFSBlockHelper(virDomainFSDefPtr fs,
43fe83
-                                          const char *src)
43fe83
+                                          const char *src,
43fe83
+                                          const char *srcprefix)
43fe83
 {
43fe83
     int fsflags = 0;
43fe83
     int ret = -1;
43fe83
@@ -1300,7 +1302,7 @@ static int lxcContainerMountFSBlockHelper(virDomainFSDefPtr fs,
43fe83
         }
43fe83
         ret = 0;
43fe83
     } else {
43fe83
-        ret = lxcContainerMountFSBlockAuto(fs, fsflags, src);
43fe83
+        ret = lxcContainerMountFSBlockAuto(fs, fsflags, src, srcprefix);
43fe83
     }
43fe83
 
43fe83
 cleanup:
43fe83
@@ -1318,7 +1320,7 @@ static int lxcContainerMountFSBlock(virDomainFSDefPtr fs,
43fe83
     if (virAsprintf(&src, "%s%s", srcprefix, fs->src) < 0)
43fe83
         goto cleanup;
43fe83
 
43fe83
-    ret = lxcContainerMountFSBlockHelper(fs, src);
43fe83
+    ret = lxcContainerMountFSBlockHelper(fs, src, srcprefix);
43fe83
 
43fe83
     VIR_DEBUG("Done mounting filesystem ret=%d", ret);
43fe83
 
43fe83
-- 
43fe83
1.8.3.2
43fe83