render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 30951964358bd18f92a8e43646acf9955984033b Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <30951964358bd18f92a8e43646acf9955984033b.1377873639.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Tue, 13 Aug 2013 16:59:27 +0100
43fe83
Subject: [PATCH] Ensure that /dev exists in the container root filesystem
43fe83
43fe83
For https://bugzilla.redhat.com/show_bug.cgi?id=924815
43fe83
43fe83
If booting a container with a root FS that isn't the host's
43fe83
root, we must ensure that the /dev mount point exists.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit c13a2c282b21b129ac7a519bb8c85dcba014469b)
43fe83
---
43fe83
 src/lxc/lxc_container.c | 16 +++++++++++++---
43fe83
 1 file changed, 13 insertions(+), 3 deletions(-)
43fe83
43fe83
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
43fe83
index 0ab4026..8abaea0 100644
43fe83
--- a/src/lxc/lxc_container.c
43fe83
+++ b/src/lxc/lxc_container.c
43fe83
@@ -868,7 +868,7 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED,
43fe83
 static int lxcContainerMountFSDev(virDomainDefPtr def,
43fe83
                                   const char *stateDir)
43fe83
 {
43fe83
-    int ret;
43fe83
+    int ret = -1;
43fe83
     char *path = NULL;
43fe83
 
43fe83
     VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir);
43fe83
@@ -877,14 +877,24 @@ static int lxcContainerMountFSDev(virDomainDefPtr def,
43fe83
                            stateDir, def->name)) < 0)
43fe83
         return ret;
43fe83
 
43fe83
-    VIR_DEBUG("Tring to move %s to /dev", path);
43fe83
+    if (virFileMakePath("/dev") < 0) {
43fe83
+        virReportSystemError(errno, "%s",
43fe83
+                             _("Cannot create /dev"));
43fe83
+        goto cleanup;
43fe83
+    }
43fe83
+
43fe83
+    VIR_DEBUG("Trying to move %s to /dev", path);
43fe83
 
43fe83
-    if ((ret = mount(path, "/dev", NULL, MS_MOVE, NULL)) < 0) {
43fe83
+    if (mount(path, "/dev", NULL, MS_MOVE, NULL) < 0) {
43fe83
         virReportSystemError(errno,
43fe83
                              _("Failed to mount %s on /dev"),
43fe83
                              path);
43fe83
+        goto cleanup;
43fe83
     }
43fe83
 
43fe83
+    ret = 0;
43fe83
+
43fe83
+cleanup:
43fe83
     VIR_FREE(path);
43fe83
     return ret;
43fe83
 }
43fe83
-- 
43fe83
1.8.3.2
43fe83