[lxc-devel] [PATCH] clean autodev dir on container exit

Jean-Tiare LE BIGOT jean-tiare.le-bigot at ovh.net
Mon Aug 11 18:01:28 UTC 2014


Hi,

Would this patch fit ? If it's OK, I'll squash/push it tomorrow morning 
(Paris time) along with some minor formating cleanups.

It basically checks for `lxc_conf->reboot == 1` flag set by the signal 
handler and `utmp_shutdown_handler`.

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 1c21559..8bab6ec 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1498,6 +1498,10 @@ int lxc_delete_autodev(struct lxc_handler *handler)
         if ( lxc_conf->autodev <= 0 )
                 return 0;

+       /* don't clean on reboot */
+       if ( lxc_conf->reboot == 1 )
+               return 0;
+
         /*
          * Use the same logic as mk_devtmpfs to compute candidate
          * path for cleanup.

On 08/08/2014 10:52 PM, Michael H. Warfield wrote:
> On Fri, 2014-08-08 at 16:12 -0400, Stéphane Graber wrote:
>> On Fri, Aug 08, 2014 at 04:05:31PM -0400, Michael H. Warfield wrote:
>>> On Fri, 2014-08-08 at 16:41 +0000, Serge Hallyn wrote:
>>>> Quoting Stéphane Graber (stgraber at ubuntu.com):
>>>>> Hello,
>>>>>
>>>>> We received this patch on github: https://github.com/lxc/lxc/pull/289.patch
>>>>>
>>>>> While it does appear to make sense to me that we don't want cruft piling
>>>>> up in /dev, especially on systems creating hundreds/thousands of
>>>>> temporary containers, Serge told me that this may have been done by
>>>>> design.
>>>
>>>> Right, I wasn't sure whether Michael wanted those to persist.  If not, then
>>>> great let's apply as is.  If so, then how about if we have lxc check at
>>>> start time whether the dir already existed - if so it leaves it be, else it
>>>> removes it at shutdown?
>>>
>>> It was intended to be persistent for the duration the host is up.  It
>>> does not persist over host reboots.  The intent was to not be destroying
>>> and recreating those areas in devtmpfs when ever a container reboots and
>>> points back at the same path.  It would then also preserve any udev
>>> changes (which could be a plus or could be a minus).
>>>
>>> I don't have a real strong preference.
>
>> Ok, so per the above, it'd be fine calling the autodev destroy function
>> in a container shutdown case which isn't a reboot right?
>
>> That way we keep the autodev around for when the container reboots but
>> we clear up all the autodev entries from /dev when it gets stopped for
>> good.
>
> Yeah, I think that works for me.
>
> Regards,
> Mike
>

-- 
Jean-Tiare, shared-hosting team


More information about the lxc-devel mailing list