[libvirt] [PATCH]lxc: don't start container when no root fs found

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Fri Sep 27 12:27:06 UTC 2013


From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>

Currently, if we don't explicitly add root fs for container,
libvirt will add one for us implicitly with "/" as src.
It would be not safe.
Unless user asked for it, we should not assume this.

Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 src/lxc/lxc_process.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 4835bd5..4f4a906 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -911,29 +911,14 @@ virLXCProcessEnsureRootFS(virDomainObjPtr vm)
 {
     virDomainFSDefPtr root = virDomainGetRootFilesystem(vm->def);
 
-    if (root)
+    if (root) {
         return 0;
-
-    if (VIR_ALLOC(root) < 0)
-        goto error;
-
-    root->type = VIR_DOMAIN_FS_TYPE_MOUNT;
-
-    if (VIR_STRDUP(root->src, "/") < 0 ||
-        VIR_STRDUP(root->dst, "/") < 0)
-        goto error;
-
-    if (VIR_INSERT_ELEMENT(vm->def->fss,
-                           0,
-                           vm->def->nfss,
-                           root) < 0)
-        goto error;
-
-    return 0;
-
-error:
-    virDomainFSDefFree(root);
-    return -1;
+    } else {
+        errno = EINVAL;
+        virReportSystemError(errno, "%s",
+                             _("No root fs found for container"));
+        return -1;
+    }
 }
 
 /**
-- 
1.8.2.1




More information about the libvir-list mailing list