LGTM barring nitpicks, thanks! On Mon, Aug 18, 2014 at 3:38 AM, Yuto KAWAMURA(kawamuray) < [email protected]> wrote:
> Add the _SetCgroupInstanceValue function which can be used to set the > value to the instance cgroup parameter. > s/to the/of an/ > > Signed-off-by: Yuto KAWAMURA(kawamuray) <[email protected]> > --- > lib/hypervisor/hv_lxc.py | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py > index 2eb9c95..e94862f 100644 > --- a/lib/hypervisor/hv_lxc.py > +++ b/lib/hypervisor/hv_lxc.py > @@ -329,6 +329,33 @@ class LXCHypervisor(hv_base.BaseHypervisor): > return utils.ReadFile(param_path).rstrip("\n") > > @classmethod > + def _SetCgroupInstanceValue(cls, instance_name, param_name, > param_value): > + """Set the value to the specified instance cgroup parameter. > + > + @type instance_name: string > + @param instance_name: instance name > + @type param_name: string > + @param param_name: cgroup subsystem parameter name > + @type param_value: string > + @param param_value: cgroup subsystem parameter value to be set > + > + """ > + param_path = cls._GetCgroupInstanceParamPath(instance_name, > param_name) > + # When interacting with cgroup fs, errno is a quite important > information > s/ a / / > + # to see what happened when settings cgroup parameter, so just through > s/settings/setting a/ s/through/throw/ > + # an error to the upper level. > + # e.g., we could know that the container can't reclaim its memory by > + # checking if the errno is the EBUSY when setting the > ... is EBUSY ... > + # memory.memsw.limit_in_bytes. > + fd = -1 > + try: > + fd = os.open(param_path, os.O_WRONLY) > + os.write(fd, param_value) > + finally: > + if fd != -1: > + os.close(fd) > + + @classmethod > def _GetCgroupCpuList(cls, instance_name): > """Return the list of CPU ids for an instance. > > -- > 2.0.4 > > Hrvoje Ribicic Ganeti Engineering Google Germany GmbH Dienerstr. 12, 80331, München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores Steuernummer: 48/725/00206 Umsatzsteueridentifikationsnummer: DE813741370
