On Thu, 2018-10-04 at 13:41 +0200, Pavel Hrdina wrote:
> On Thu, Oct 04, 2018 at 01:18:14PM +0200, Michal Privoznik wrote:
> > On 10/02/2018 10:43 AM, Pavel Hrdina wrote:
> > > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > > ---
> > > src/util/vircgroupv2.c | 8 ++++++++
> > > 1 file changed, 8 insertions(+)
> > >
> > > diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
> > > index 5cd8e86b97..57be0b92c9 100644
> > > --- a/src/util/vircgroupv2.c
> > > +++ b/src/util/vircgroupv2.c
> > > @@ -306,6 +306,13 @@ virCgroupV2HasController(virCgroupPtr group,
> > > }
> > >
> > >
> > > +static int
> > > +virCgroupV2GetAnyController(virCgroupPtr group)
> > > +{
> > > + return ffs(group->unified.controllers) - 1;
> >
> > Ah, for ffs() bits are numbered from 1. Okay, it just took me a
> > while to
> > realize that. Because in C we don't usually index things from 1, do
> > we?
>
> I figured that out the hard way :) going through debug logs and
> investigating why the code is not working how it should. Reading
> man page would probably help me to realize that sooner.
If you feel like doing so, please, add a comment here because I'm
pretty sure someone else in the future will go through this code and
spend some time trying to understand that " The least significant bit
is position 1 and the most significant position is, for example, 32 or
64." (taken from their manpage).
>
> > > +}
> > > +
> > > +
> > > virCgroupBackend virCgroupV2Backend = {
> > > .type = VIR_CGROUP_BACKEND_TYPE_V2,
> > >
> > > @@ -319,6 +326,7 @@ virCgroupBackend virCgroupV2Backend = {
> > > .stealPlacement = virCgroupV2StealPlacement,
> > > .detectControllers = virCgroupV2DetectControllers,
> > > .hasController = virCgroupV2HasController,
> > > + .getAnyController = virCgroupV2GetAnyController,
> > > };
> > >
> > >
> > >
> >
> > ACK
> >
> > Michal
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list