[lxc-users] [PATCH] check whether rootfs is shared before running hooks

Florian Klink flokli at flokli.de
Thu Mar 27 09:26:35 UTC 2014


Am 26.03.2014 15:40, schrieb Serge Hallyn:
> Quoting Florian Klink (flokli at flokli.de):
>> this expands c597baa8f9 and 2c6f3fc932.
> 
> It can't happen here as this will affect the host.
> 
> So yes, the pre-start hooks by definition cannot happen in
> the container's ns (lxc.container.conf says it happens in
> the host's namespace).

Sorry, my bad... Seems like I mixed up the two different hook types.
Updated patch comes shortly!

> 
> Perhaps the very top of lxc-setup is the place to do this.
> 
>> ---
>>  src/lxc/start.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/src/lxc/start.c b/src/lxc/start.c
>> index ec10496..40696e9 100644
>> --- a/src/lxc/start.c
>> +++ b/src/lxc/start.c
>> @@ -409,6 +409,13 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf, const char
>>  	}
>>  	/* End of environment variable setup for hooks */
>>  
>> +	if (detect_shared_rootfs()) {
>> +		if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL)) {
>> +			SYSERROR("Failed to make / rslave");
>> +			ERROR("Continuing...");
>> +		}
>> +	}
>> +
>>  	if (run_lxc_hooks(name, "pre-start", conf, handler->lxcpath, NULL)) {
>>  		ERROR("failed to run pre-start hooks for container '%s'.", name);
>>  		goto out_aborting;
>> -- 
>> 1.9.1
>> _______________________________________________
>> lxc-users mailing list
>> lxc-users at lists.linuxcontainers.org
>> http://lists.linuxcontainers.org/listinfo/lxc-users




More information about the lxc-users mailing list