[libvirt] [PATCH 13/53] vircgroup: introduce virCgroupV2PathOfController

Pavel Hrdina phrdina at redhat.com
Thu Oct 4 11:39:43 UTC 2018


On Thu, Oct 04, 2018 at 01:18:12PM +0200, Michal Privoznik wrote:
> On 10/02/2018 10:43 AM, Pavel Hrdina wrote:
> > Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> > ---
> >  src/util/vircgroupv2.c | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> > 
> > diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
> > index 57be0b92c9..3ca463e4c2 100644
> > --- a/src/util/vircgroupv2.c
> > +++ b/src/util/vircgroupv2.c
> > @@ -313,6 +313,29 @@ virCgroupV2GetAnyController(virCgroupPtr group)
> >  }
> >  
> >  
> > +static int
> > +virCgroupV2PathOfController(virCgroupPtr group,
> > +                            int controller,
> > +                            const char *key,
> > +                            char **path)
> > +{
> > +    if (!virCgroupV2HasController(group, controller)) {
> > +        virReportError(VIR_ERR_INTERNAL_ERROR,
> > +                       _("v2 controller '%s' is not available"),
> > +                       virCgroupV2ControllerTypeToString(controller));
> > +        return -1;
> > +    }
> 
> 
> Looks like this check ^^ can be moved to the caller:
> 
> virCgroupPathOfController() {
>   if (!virCgroupHasController()) error();
> 
>   group->backend->pathOfController();
> }
> 
> But feel free to save that for a follow up patch.

Technically yes, but once hybrid support is enabled using the backend
specific function in each backend will save some cycles to figure out
which backend to use.  Originally I had it like that but I realized that
moving it to backend I can use the backend specific *HasController.

> 
> > +
> > +    if (virAsprintf(path, "%s%s/%s",
> > +                    group->unified.mountPoint,
> > +                    group->unified.placement,
> > +                    key ? key : "") < 0)
> > +        return -1;
> > +
> > +    return 0;
> > +}
> > +
> > +
> >  virCgroupBackend virCgroupV2Backend = {
> >      .type = VIR_CGROUP_BACKEND_TYPE_V2,
> >  
> > @@ -327,6 +350,7 @@ virCgroupBackend virCgroupV2Backend = {
> >      .detectControllers = virCgroupV2DetectControllers,
> >      .hasController = virCgroupV2HasController,
> >      .getAnyController = virCgroupV2GetAnyController,
> > +    .pathOfController = virCgroupV2PathOfController,
> >  };
> >  
> >  
> > 
> 
> 
> ACK
> 
> Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20181004/053ed5fa/attachment-0001.sig>


More information about the libvir-list mailing list