Hi Balbir,

Balbir Singh wrote:
>>> On Wed, Nov 25, 2009 at 12:20 PM, Ken'ichi Ohmichi
>>> <[email protected]> wrote:
>>>> Hi,
>>>>
>>>> cg_set_control_value() is the function for setting a value to a file
>>>> of cgroup file system. And current function does not handle the error
>>>> of writing to a file. So we cannot know whether setting value is
>>>> enable or not.
>>>>
>>>> This patch adds the error handling for knowing it.
>>> The changelog does not document the motivation to move to open() from
>>> fopen(). Any particular reason for doing so?
>> Sorry for not writing my motivation.
>>
>> If an administrator sets an invalid value in /etc/cgconfig.conf,
>> current 'cgconfig' service cannot set it but the service does not
>> inform him/her of the error.
>> I'd like to add the handling against the error to know it.
>>
>>
>> For example, cpuset.mems is an invalid value in /etc/cgconfig.conf
>> because the system is not multi nodes system, but the service does
>> not handle it.
>>
>>   # cat /etc/cgconfig.conf
>>   mount {
>>         cpuset = /mnt/cgroups/cpuset;
>>   }
>>   group usergroup {
>>         cpuset {
>>                 cpuset.cpus = 0;
>>                 cpuset.mems = 0-100;
>>         }
>>   }
>>
>>   # service cgconfig start
>>   Starting cgconfig service:                                 [  OK  ]
>>   # cat /mnt/cgroups/cpuset/usergroup/cpuset.mems
>>
>>   # cat /mnt/cgroups/cpuset/usergroup/cpuset.cpus
>>   0
>>   #
>>
>>
>> If the patch is applied, the service can handle the error and the
>> service fails by an invalid value like the following.
>>
>>   # cat /etc/cgconfig.conf
>>   mount {
>>         cpuset = /mnt/cgroups/cpuset;
>>   }
>>   group usergroup {
>>         cpuset {
>>                 cpuset.cpus = 0;
>>                 cpuset.mems = 0-100;
>>         }
>>   }
>>
>>   # service cgconfig start
>>   Starting cgconfig service: Loading configuration file /etc/cgconfig.conf 
>> failed
>>   Numerical result out of range
>>   Failed to parse /etc/cgconfig.conf                         [FAILED]
>>   [r...@localhost libcg]#
>>
> 
> Thanks and sorry for the delay in responding, I was wondering why
> fopen() was changed to open(), fprintf() to write(), etc. 

If writing an invalid value on a file of cgroup fs, write(2) returns -1
with a right errno. But fprintf(3) does not return it, because fprintf(3)
write on some buffer. So it is better that we check the return value of
write(2).


Thanks
Ken'ichi Ohmichi

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to