[libvirt] [PATCH 1/9] vircgroup: cleanup controllers not managed by systemd on error

Fabiano Fidêncio fidencio at redhat.com
Wed Sep 19 11:36:24 UTC 2018


On Tue, Sep 18, 2018 at 2:17 PM, Pavel Hrdina <phrdina at redhat.com> wrote:

> If virCgroupEnableMissingControllers() fails it could already create
> some directories, we should clean it up as well.
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
>

Reviewed-by: Fabiano Fidêncio <fidencio at redhat.com>


> ---
>  src/util/vircgroup.c | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> index 64507bf8aa..6aa30a82be 100644
> --- a/src/util/vircgroup.c
> +++ b/src/util/vircgroup.c
> @@ -1555,6 +1555,7 @@ virCgroupNewMachineSystemd(const char *name,
>      int rv;
>      virCgroupPtr init;
>      VIR_AUTOFREE(char *) path = NULL;
> +    virErrorPtr saved = NULL;
>
>      VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
>      if ((rv = virSystemdCreateMachine(name,
> @@ -1588,20 +1589,24 @@ virCgroupNewMachineSystemd(const char *name,
>
>      if (virCgroupEnableMissingControllers(path, pidleader,
>                                            controllers, group) < 0) {
> -        return -1;
> +        goto error;
>      }
>
> -    if (virCgroupAddTask(*group, pidleader) < 0) {
> -        virErrorPtr saved = virSaveLastError();
> -        virCgroupRemove(*group);
> -        virCgroupFree(group);
> -        if (saved) {
> -            virSetError(saved);
> -            virFreeError(saved);
> -        }
> -    }
> +    if (virCgroupAddTask(*group, pidleader) < 0)
> +        goto error;
>
>      return 0;
> +
> + error:
> +    saved = virSaveLastError();
> +    virCgroupRemove(*group);
> +    virCgroupFree(group);
> +    if (saved) {
> +        virSetError(saved);
> +        virFreeError(saved);
> +    }
> +
> +    return -1;
>  }
>
>
> --
> 2.17.1
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180919/ad7d396d/attachment-0001.htm>


More information about the libvir-list mailing list