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

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

 



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.

> +                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.

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

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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]