[Devel] [PATCH 3/3] hooks_ct: fix ub limits setting for upstream containers

Glauber Costa glommer at parallels.com
Mon May 13 00:50:08 PDT 2013


On 05/11/2013 05:07 AM, Igor M Podlesny wrote:
> On 30 April 2013 11:46, Glauber Costa <glommer at openvz.org> wrote:
>> Currently, vps_setup_res() have an explicit test for state != VPS_STARTING
>> before applying beancounter limits. This means that we can set limits without
>> further problems when the container is running, but will fail to do so when the
>> container is starting. In fact, hooks_vz have an explicit call for it in its
>> startup function.
>>
>> We should do the same, and call our version of setlimits ourselves when the
>> container is coming up.
>>
>> Signed-off-by: Glauber Costa <glommer at openvz.org>
>> ---
>>  src/lib/hooks_ct.c | 147 +++++++++++++++++++++++++++--------------------------
>>  1 file changed, 76 insertions(+), 71 deletions(-)
>>
>> diff --git a/src/lib/hooks_ct.c b/src/lib/hooks_ct.c
>> index 63af536..3cfb6e9 100644
>> --- a/src/lib/hooks_ct.c
>> +++ b/src/lib/hooks_ct.c
>> @@ -153,6 +153,77 @@ static int _env_create(void *data)
>>         return exec_container_init(arg, &create_param);
>>  }
>>
>> +#define add_value(val, var, mult) do { if (val) { var = *val * mult; } } while (0)
> 
>    Aren't macroses supposed to be UPPER CASE named?
> 
Yes, and for a reason: macros behave very differently than functions,
and a convention to allow us to spot them and identify them as macros
very easily is beneficial.

This particular macro is defined right before the function, and
undefined right after it, so it should be extremely clear to every
reader that this is a macro. In this case, I don't see a reason for
being so strict.




More information about the Devel mailing list