[libvirt] [PATCH 2/2] vircgroupv2: fix virCgroupV2ValidateMachineGroup

Pavel Hrdina posted 2 patches 7 years, 1 month ago
[libvirt] [PATCH 2/2] vircgroupv2: fix virCgroupV2ValidateMachineGroup
Posted by Pavel Hrdina 7 years, 1 month ago
When libvirt is reconnecting to running domain that uses cgroup v2
the QEMU process reports cgroup for the emulator directory because the
main thread is in that cgroup.  We need to remove the "/emulator" part
in order to match with the root cgroup directory name for that domain.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/util/vircgroupv2.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index dc2b2a65bc..b9925967d7 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -118,6 +118,12 @@ virCgroupV2ValidateMachineGroup(virCgroupPtr group,
     if (virCgroupPartitionEscape(&scopename) < 0)
         return false;
 
+    if (!(tmp = strrchr(group->unified.placement, '/')))
+        return false;
+
+    if (STREQ(tmp, "/emulator"))
+        *tmp = '\0';
+
     if (!(tmp = strrchr(group->unified.placement, '/')))
         return false;
     tmp++;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] vircgroupv2: fix virCgroupV2ValidateMachineGroup
Posted by Michal Privoznik 7 years, 1 month ago
On 12/12/18 11:17 AM, Pavel Hrdina wrote:
> When libvirt is reconnecting to running domain that uses cgroup v2
> the QEMU process reports cgroup for the emulator directory because the
> main thread is in that cgroup.  We need to remove the "/emulator" part
> in order to match with the root cgroup directory name for that domain.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/util/vircgroupv2.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
> index dc2b2a65bc..b9925967d7 100644
> --- a/src/util/vircgroupv2.c
> +++ b/src/util/vircgroupv2.c
> @@ -118,6 +118,12 @@ virCgroupV2ValidateMachineGroup(virCgroupPtr group,
>      if (virCgroupPartitionEscape(&scopename) < 0)
>          return false;
>  
> +    if (!(tmp = strrchr(group->unified.placement, '/')))
> +        return false;
> +
> +    if (STREQ(tmp, "/emulator"))
> +        *tmp = '\0';
> +

How about:

    if (STREQ(tmp, "/emulator")) {
        *tmp = '\0';

        if (!(tmp = strrchr(group->unified.placement, '/')))
            return false;
    }


ACK regardless.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] vircgroupv2: fix virCgroupV2ValidateMachineGroup
Posted by Pavel Hrdina 7 years, 1 month ago
On Thu, Dec 13, 2018 at 04:28:30PM +0100, Michal Privoznik wrote:
> On 12/12/18 11:17 AM, Pavel Hrdina wrote:
> > When libvirt is reconnecting to running domain that uses cgroup v2
> > the QEMU process reports cgroup for the emulator directory because the
> > main thread is in that cgroup.  We need to remove the "/emulator" part
> > in order to match with the root cgroup directory name for that domain.
> > 
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> >  src/util/vircgroupv2.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
> > index dc2b2a65bc..b9925967d7 100644
> > --- a/src/util/vircgroupv2.c
> > +++ b/src/util/vircgroupv2.c
> > @@ -118,6 +118,12 @@ virCgroupV2ValidateMachineGroup(virCgroupPtr group,
> >      if (virCgroupPartitionEscape(&scopename) < 0)
> >          return false;
> >  
> > +    if (!(tmp = strrchr(group->unified.placement, '/')))
> > +        return false;
> > +
> > +    if (STREQ(tmp, "/emulator"))
> > +        *tmp = '\0';
> > +
> 
> How about:
> 
>     if (STREQ(tmp, "/emulator")) {
>         *tmp = '\0';
> 
>         if (!(tmp = strrchr(group->unified.placement, '/')))
>             return false;
>     }

Right, that is better.

> ACK regardless.

Thanks, pushed now.

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