[lxc-devel] [PATCH 1/1] RFC: api change: default container->daemonize to true

Stéphane Graber stgraber at ubuntu.com
Tue Jan 14 21:25:35 UTC 2014


On Mon, Jan 13, 2014 at 11:08:48AM -0600, Serge Hallyn wrote:
> Pretty much the only case where we do NOT want to daemonize
> a container start is lxc-start.  So make c->daemonize true
> by default, and have lxc-start set it to false.
> 
> If there are existing API users who rely on daemonize by
> default, then they will be broken by this.  It seems we should
> do this before beta1 if we're going to do it.
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/lxc_start.c    | 4 ++--
>  src/lxc/lxccontainer.c | 1 +
>  src/tests/startone.c   | 1 +
>  3 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c
> index e6ca355..d5379da 100644
> --- a/src/lxc/lxc_start.c
> +++ b/src/lxc/lxc_start.c
> @@ -325,8 +325,8 @@ int main(int argc, char *argv[])
>  		conf->inherit_ns_fd[i] = fd;
>  	}
>  
> -	if (my_args.daemonize) {
> -		c->want_daemonize(c, true);
> +	if (!my_args.daemonize) {
> +		c->want_daemonize(c, false);
>  	}
>  
>  	if (pid_fp != NULL) {
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index 48fef74..5c2c62a 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -3059,6 +3059,7 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
>  		lxcapi_destroy(c);
>  		lxcapi_clear_config(c);
>  	}
> +	c->daemonize = true;
>  
>  	// assign the member functions
>  	c->is_defined = lxcapi_is_defined;
> diff --git a/src/tests/startone.c b/src/tests/startone.c
> index 678f62e..93992c1 100644
> --- a/src/tests/startone.c
> +++ b/src/tests/startone.c
> @@ -168,6 +168,7 @@ int main(int argc, char *argv[])
>  		fprintf(stderr, "%d: failed to get extra ref to container\n", __LINE__);
>  		exit(1);
>  	}
> +	c->want_daemonize(false);
>  	pid_t pid = fork();
>  	if (pid < 0) {
>  		fprintf(stderr, "%d: fork failed\n", __LINE__);
> -- 
> 1.8.5.2
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140114/85f4a3a9/attachment-0001.pgp>


More information about the lxc-devel mailing list