[lxc-devel] [PATCH] lxc-create: Store template information in config

Stéphane Graber stgraber at ubuntu.com
Fri Nov 30 21:27:50 UTC 2012


On 11/30/2012 08:56 AM, Serge Hallyn wrote:
> Quoting Stéphane Graber (stgraber at ubuntu.com):
>> Change lxc-create to add the name of the template and any parameters
>> to the container's configuration.
>> This makes it easier to debug and figure out exactly how a container was built.
>>
>> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
>> ---
>>  src/lxc/lxc-create.in | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
>> index 30f0c22..391f1c3 100644
>> --- a/src/lxc/lxc-create.in
>> +++ b/src/lxc/lxc-create.in
>> @@ -281,7 +281,14 @@ if [ ! -r "$lxc_config" ]; then
>>      exit 1
>>  fi
>>  
>> -cp $lxc_config $lxc_path/$lxc_name/config
>> +if [ ! -z $lxc_template ]; then
>> +    echo "# Template used to create this container: $lxc_template" >> $lxc_path/$lxc_name/config
>> +    if [ -n "$*" ]; then
>> +        echo "# Parameters passed to the template: $*" >> $lxc_path/$lxc_name/config
>> +    fi
>> +fi
>> +
>> +cat $lxc_config >> $lxc_path/$lxc_name/config
> 
> What do you think about also storing the sha1sum of the template?

Good idea, I'll add that.

> That way we can perhaps figure out whether a container was created
> by a known buggy version of a template.  (Or we could add version
> numbers and ask distros to adhere to an agreed upon versioning
> scheme)
> 
>>  if [ -n "$custom_rootfs" ]; then
>>  	if grep -q "lxc.rootfs" $lxc_path/$lxc_name/config ; then
>> -- 
>> 1.8.0
>>
>>
>> ------------------------------------------------------------------------------
>> Keep yourself connected to Go Parallel: 
>> VERIFY Test and improve your parallel project with help from experts 
>> and peers. http://goparallel.sourceforge.net
>> _______________________________________________
>> Lxc-devel mailing list
>> Lxc-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/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: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20121130/487c343b/attachment.pgp>


More information about the lxc-devel mailing list