Re: [libvirt] [PATCH 3/5] Fix check for existance of cgroups at creation

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

 



On Fri, Nov 13, 2009 at 12:00 AM, Daniel P. Berrange
<berrange@xxxxxxxxxx> wrote:
> In the scenario where the cgroups were mounted but the
> particular group did not exist, and the caller had not
> requested auto-creation, the code would fail to return
> an error condition. This caused the lxc_controller to
> think the cgroup existed, and it then later failed when
> attempting to use it
>
> * src/util/cgroup.c: Raise an error if the cgroup path does not
>  exist
> ---
>  src/util/cgroup.c |   17 ++++++++---------
>  1 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/src/util/cgroup.c b/src/util/cgroup.c
> index bdd4eb6..c80cf50 100644
> --- a/src/util/cgroup.c
> +++ b/src/util/cgroup.c
> @@ -442,7 +442,7 @@ static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
>     return rc;
>  }
>
> -static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group)
> +static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int create)
>  {
>     int i;
>     int rc = 0;
> @@ -461,7 +461,8 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group)
>
>         VIR_DEBUG("Make controller %s", path);
>         if (access(path, F_OK) != 0) {
> -            if (mkdir(path, 0755) < 0) {
> +            if (!create ||
> +                mkdir(path, 0755) < 0) {

Got it. if creation is not requested, then errno of access(2)
is returned before attempting mkdir(2).

The code looks correct to me, ACK.

  ozaki-r

>                 rc = -errno;
>                 VIR_FREE(path);
>                 break;
> @@ -548,7 +549,7 @@ static int virCgroupAppRoot(int privileged,
>     if (rc != 0)
>         goto cleanup;
>
> -    rc = virCgroupMakeGroup(rootgrp, *group);
> +    rc = virCgroupMakeGroup(rootgrp, *group, 1);
>
>  cleanup:
>     virCgroupFree(&rootgrp);
> @@ -647,9 +648,8 @@ int virCgroupForDriver(const char *name,
>     rc = virCgroupNew(path, group);
>     VIR_FREE(path);
>
> -    if (rc == 0 &&
> -        create) {
> -        rc = virCgroupMakeGroup(rootgrp, *group);
> +    if (rc == 0) {
> +        rc = virCgroupMakeGroup(rootgrp, *group, create);
>         if (rc != 0)
>             virCgroupFree(group);
>     }
> @@ -695,9 +695,8 @@ int virCgroupForDomain(virCgroupPtr driver,
>     rc = virCgroupNew(path, group);
>     VIR_FREE(path);
>
> -    if (rc == 0 &&
> -        create) {
> -        rc = virCgroupMakeGroup(driver, *group);
> +    if (rc == 0) {
> +        rc = virCgroupMakeGroup(driver, *group, create);
>         if (rc != 0)
>             virCgroupFree(group);
>     }
> --
> 1.6.2.5
>
> --
> Libvir-list mailing list
> Libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list
>

--
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]