[RFC] [PATCH 5/5] Mount fuse's meminfo file to container's /proc/meminfo

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

 



we already have virtualize meminfo for container in fuse filesystem,
add function lxcContainerMountProcFuse to mount this meminfo file to
the container's /proc/meminfo.

So we isolate container's /proc/meminfo now.

Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
---
 src/lxc/lxc_container.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 145accb..5e0cf06 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -520,6 +520,27 @@ cleanup:
     return rc;
 }
 
+static int lxcContainerMountProcFuse(virDomainDefPtr def,
+                                     const char *srcprefix)
+{
+    int ret;
+    char *meminfo_path = NULL;
+
+    if ((ret = virAsprintf(&meminfo_path,
+                           "%s/%s/%s/meminfo",
+                           srcprefix, LXC_STATE_DIR,
+                           def->name)) < 0)
+         return ret;
+
+    if ((ret = mount(meminfo_path, "/proc/meminfo",
+                     NULL, MS_BIND, NULL)) < 0) {
+         virReportSystemError(errno,
+                              _("Failed to mount %s on /proc/meminfo"),
+                              meminfo_path);
+    }
+    VIR_FREE(meminfo_path);
+    return ret;
+}
 
 static int lxcContainerMountFSDevPTS(virDomainFSDefPtr root)
 {
@@ -1430,6 +1451,10 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef,
     if (lxcContainerMountBasicFS(vmDef, true, securityDriver) < 0)
         goto cleanup;
 
+    /* Mounts /proc/meminfo etc sysinfo */
+    if (lxcContainerMountProcFuse(vmDef, "/.oldroot") < 0)
+        goto cleanup;
+
     /* Now we can re-mount the cgroups controllers in the
      * same configuration as before */
     if (lxcContainerMountCGroups(mounts, nmounts) < 0)
@@ -1509,6 +1534,10 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef,
     if (lxcContainerMountBasicFS(vmDef, false, securityDriver) < 0)
         goto cleanup;
 
+    /* Mounts /proc/meminfo etc sysinfo */
+    if (lxcContainerMountProcFuse(vmDef, "/.oldroot") < 0)
+        goto cleanup;
+
     /* Now we can re-mount the cgroups controllers in the
      * same configuration as before */
     if (lxcContainerMountCGroups(mounts, nmounts) < 0)
-- 
1.7.7.6

--
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]