Re: [PATCH 1/2] cgroup: cgroup_common.py bugfixies and modifications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Acked-by: Jiří Župka <jzupka@xxxxxxxxxx>

----- Original Message -----
> [FIX] incorrect prop/dir variable usage
> [MOD] Use __del__() instead of cleanup - Simplifies the code with
> small drawback (failures can't be handled. Anyway, they are not
> critical and were never handled before...)
> 
> Signed-off-by: Lukas Doktor <ldoktor@xxxxxxxxxx>
> ---
>  client/tests/cgroup/cgroup_common.py |   41
>  +++++++++++++++++++++++++++++-----
>  1 files changed, 35 insertions(+), 6 deletions(-)
> 
> diff --git a/client/tests/cgroup/cgroup_common.py
> b/client/tests/cgroup/cgroup_common.py
> index 836a23e..2a95c76 100755
> --- a/client/tests/cgroup/cgroup_common.py
> +++ b/client/tests/cgroup/cgroup_common.py
> @@ -25,8 +25,20 @@ class Cgroup(object):
>          self.module = module
>          self._client = _client
>          self.root = None
> +        self.cgroups = []
>  
>  
> +    def __del__(self):
> +        """
> +        Destructor
> +        """
> +        self.cgroups.sort(reverse=True)
> +        for pwd in self.cgroups[:]:
> +            for task in self.get_property("tasks", pwd):
> +                if task:
> +                    self.set_root_cgroup(int(task))
> +            self.rm_cgroup(pwd)
> +
>      def initialize(self, modules):
>          """
>          Initializes object for use.
> @@ -57,6 +69,7 @@ class Cgroup(object):
>          except Exception, inst:
>              logging.error("cg.mk_cgroup(): %s" , inst)
>              return None
> +        self.cgroups.append(pwd)
>          return pwd
>  
>  
> @@ -70,6 +83,10 @@ class Cgroup(object):
>          """
>          try:
>              os.rmdir(pwd)
> +            self.cgroups.remove(pwd)
> +        except ValueError:
> +            logging.warn("cg.rm_cgroup(): Removed cgroup which
> wasn't created"
> +                         "using this Cgroup")
>          except Exception, inst:
>              if not supress:
>                  logging.error("cg.rm_cgroup(): %s" , inst)
> @@ -329,6 +346,22 @@ class CgroupModules(object):
>          self.modules.append([])
>          self.mountdir = mkdtemp(prefix='cgroup-') + '/'
>  
> +    def __del__(self):
> +        """
> +        Unmount all cgroups and remove the mountdir
> +        """
> +        for i in range(len(self.modules[0])):
> +            if self.modules[2][i]:
> +                try:
> +                    os.system('umount %s -l' % self.modules[1][i])
> +                except:
> +                    logging.warn("CGM: Couldn't unmount %s
> directory"
> +                                 % self.modules[1][i])
> +        try:
> +            os.system('rm -rf %s' % self.mountdir)
> +        except:
> +            logging.warn("CGM: Couldn't remove the %s directory"
> +                         % self.mountdir)
>  
>      def init(self, _modules):
>          """
> @@ -376,13 +409,9 @@ class CgroupModules(object):
>  
>      def cleanup(self):
>          """
> -        Unmount all cgroups and remove the mountdir.
> +        Kept for compatibility
>          """
> -        for i in range(len(self.modules[0])):
> -            if self.modules[2][i]:
> -                utils.system('umount %s -l' % self.modules[1][i],
> -                             ignore_status=True)
> -        shutil.rmtree(self.mountdir)
> +        pass
>  
>  
>      def get_pwd(self, module):
> --
> 1.7.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux