<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><pre>Hello, we encounter a problem in the use of lxc, that the command of free and top does
not show container\'s cpu and memory but the host server\'s;we know that it is a problem
of proc directory which is mounted outside the container with remount option.we also
know that we can solve this problem with fuse.
now we put forward another solution which is also based on fuse,but with more
difference,our solution is modify lxc-start.c:
before do_clone() we use fuse to generate a userspaces proc filesystem,call mount() to
mount /lxc/as6.3/proc directory;
after perform mount_rootfs_dir ($rootfs, $target) ,then call mount() to mount
/lxc/as6.3/proc/{stat, meminfo, sysrq-trigger} to target/{stat, meminfo, sysrq-trigger} with --
bind option.
When a virtual machine to read /proc/meminfo, it will read the meminfo of from
userspaces filesystem, we can get the correct value is returned to the virtual machine
from /cgroup/memory.if read /proc/stat, we can get value form /cgroup/cpuacct.
All mount implemented in lxc_start.c using c language, userspace files can be
configured in the configuration file and dynamic loading.
The function of open and read and write of meminfo,stat,sysrq-trigger must be
implemented by us.
this is a example,in configuration file:
lxc.cgroup.memory.limit_in_bytes = 268435456
lxc.cgroup.memory.memsw.limit_in_bytes = 536870912
[shell]#free -m
total used free shared buffers cached
Mem: 256 13 242 0 0 0
-/+ buffers/cache: 13 242
Swap: 512 13 498</pre></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>