Re: [PATCH v5 6/6] Mount fuse's meminfo file to container's /proc/meminfo

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

 



On Thu, Oct 25, 2012 at 06:38:27PM +0800, Gao feng wrote:
> we already have virtualize meminfo for container through fuse filesystem,
> add function lxcContainerMountProcFuse to mount this meminfo file to
> the container's /proc/meminfo.
> 
> So we can isolate container's /proc/meminfo from host now.
> 
> Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
> ---
>  src/lxc/lxc_container.c |   38 ++++++++++++++++++++++++++++++++++++++
>  1 files changed, 38 insertions(+), 0 deletions(-)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 2789c17..e8fdb37 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -595,6 +595,36 @@ cleanup:
>      return rc;
>  }
>  
> +#if HAVE_FUSE
> +static int lxcContainerMountProcFuse(virDomainDefPtr def,
> +                                     const char *srcprefix)
> +{
> +    int ret = 0;
> +    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;
> +}
> +#else
> +static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED,
> +                                     const char *srcprefix ATTRIBUTE_UNUSED)
> +{
> +    return 0;
> +}
> +#endif
>  
>  static int lxcContainerMountFSDevPTS(virDomainFSDefPtr root)
>  {
> @@ -1550,6 +1580,10 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef,
>      if (lxcContainerMountBasicFS(true, sec_mount_options) < 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,
> @@ -1640,6 +1674,10 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef,
>      if (lxcContainerMountBasicFS(false, sec_mount_options) < 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,

ACK

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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