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

Re: [libvirt] [PATCH v2 1/2] cgroup: Change virCgroupRemove to remove all descendant groups at first



On Thu, Jun 24, 2010 at 5:41 AM, Eric Blake <eblake redhat com> wrote:
> On 06/23/2010 10:00 AM, Ryota Ozaki wrote:
>> As same as normal directories, a cgroup cannot be removed if it
>> contains sub groups. This patch changes virCgroupRemove to remove
>> all descendant groups (subdirectories) of a target group before
>> removing the target group.
>>
>> +    for (;;) {
>> +        char *path;
>> +
>> +        errno = 0;
>> +        ent = readdir(grpdir);
>> +        if (ent == NULL) {
>> +            if (errno)
>
> This should also set rc, so the overall function exits with nonzero status.

Oh, right.

>
>> +                VIR_ERROR(_("Failed to readdir for %s (%d)"), grppath, errno);
>> +            break;
>> +        }
>> +
>> +        if (ent->d_name[0] == '.') continue;
>> +        if (ent->d_type != DT_DIR) continue;
>
> Hmm - d_type is not guaranteed by POSIX.  Then again, neither is cgroup,
> so you're just fine exploiting it.

I believe so :-)

>
> ACK with that nit fixed, so I squashed in this before pushing:

Thank you for fixing it.
  ozaki-r

>
> diff --git i/src/util/cgroup.c w/src/util/cgroup.c
> index faec23f..3c23251 100644
> --- i/src/util/cgroup.c
> +++ w/src/util/cgroup.c
> @@ -1,6 +1,7 @@
>  /*
>  * cgroup.c: Tools for managing cgroups
>  *
> + * Copyright (C) 2010 Red Hat, Inc.
>  * Copyright IBM Corp. 2008
>  *
>  * See COPYING.LIB for the License of this software
> @@ -581,7 +582,7 @@ static int virCgroupRemoveRecursively(char *grppath)
>         errno = 0;
>         ent = readdir(grpdir);
>         if (ent == NULL) {
> -            if (errno)
> +            if ((rc = -errno))
>                 VIR_ERROR(_("Failed to readdir for %s (%d)"), grppath,
> errno);
>             break;
>         }
>
>
> --
> Eric Blake   eblake redhat com    +1-801-349-2682
> Libvirt virtualization library http://libvirt.org
>
>


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