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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]