[libvirt] [PATCH 1/5] lxc: Move lxcContainerAvailable to virprocess
Daniel P. Berrange
berrange at redhat.com
Wed Jan 11 16:59:31 UTC 2017
On Wed, Jan 11, 2017 at 05:43:12PM +0100, Michal Privoznik wrote:
> Other drivers (like qemu) would like to know if the namespaces
> are available therefore it makes sense to move this function to
> a shared module.
>
> At the same time, this function had some default namespaces that
> are checked with every call. It is not necessary - let callers
> pass just those namespaces they are interested in.
>
> With the move the function is renamed to
> virProcessNamespaceAvailable.
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> src/libvirt_private.syms | 1 +
> src/lxc/lxc_container.c | 44 +----------------------------
> src/lxc/lxc_container.h | 2 --
> src/lxc/lxc_driver.c | 7 +++--
> src/util/virprocess.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
> src/util/virprocess.h | 10 +++++++
> 6 files changed, 89 insertions(+), 47 deletions(-)
>
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 9c74d35c4..d02d23b35 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -2275,6 +2275,7 @@ virProcessGetPids;
> virProcessGetStartTime;
> virProcessKill;
> virProcessKillPainfully;
> +virProcessNamespaceAvailable;
> virProcessRunInMountNamespace;
> virProcessSchedPolicyTypeFromString;
> virProcessSchedPolicyTypeToString;
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 32c0c3a4a..e5619b168 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -27,7 +27,6 @@
> #include <config.h>
>
> #include <fcntl.h>
> -#include <sched.h>
> #include <limits.h>
> #include <stdlib.h>
> #include <stdio.h>
> @@ -2265,7 +2264,7 @@ static int lxcContainerChild(void *data)
>
> static int userns_supported(void)
> {
> - return lxcContainerAvailable(LXC_CONTAINER_FEATURE_USER) == 0;
> + return virProcessNamespaceAvailable(VIR_PROCESS_NAMESPACE_USER) == 0;
> }
>
> static int userns_required(virDomainDefPtr def)
> @@ -2399,47 +2398,6 @@ int lxcContainerStart(virDomainDefPtr def,
> return pid;
> }
>
> -ATTRIBUTE_NORETURN static int
> -lxcContainerDummyChild(void *argv ATTRIBUTE_UNUSED)
> -{
> - _exit(0);
> -}
> -
> -int lxcContainerAvailable(int features)
> -{
> - int flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|
> - CLONE_NEWIPC|SIGCHLD;
> - int cpid;
> - char *childStack;
> - char *stack;
> - int stacksize = getpagesize() * 4;
> -
> - if (features & LXC_CONTAINER_FEATURE_USER)
> - flags |= CLONE_NEWUSER;
> -
> - if (features & LXC_CONTAINER_FEATURE_NET)
> - flags |= CLONE_NEWNET;
These two constants need to be dropped from lxc_container.h now
too.
ACK if that's fixed.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
More information about the libvir-list
mailing list