Re: [PATCH 03/47] vircgroup: extract virCgroupV1Available

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

 



On Thu, Sep 20, 2018 at 08:28:53AM +0200, Fabiano Fidêncio wrote:
> On Tue, Sep 18, 2018 at 5:45 PM, Pavel Hrdina <phrdina@xxxxxxxxxx> wrote:
> 
> > Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
> > ---
> >  src/util/vircgroup.c        | 28 +++++++++-------------------
> >  src/util/vircgroupbackend.h |  7 +++++++
> >  src/util/vircgroupv1.c      | 35 +++++++++++++++++++++++++++++++++++
> >  3 files changed, 51 insertions(+), 19 deletions(-)
> >
> > diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> > index e85e0bde24..a5478a3fa4 100644
> > --- a/src/util/vircgroup.c
> > +++ b/src/util/vircgroup.c
> > @@ -51,6 +51,7 @@
> >
> >  #include "virutil.h"
> >  #include "viralloc.h"
> > +#include "vircgroupbackend.h"
> >  #include "virerror.h"
> >  #include "virlog.h"
> >  #include "virfile.h"
> > @@ -64,8 +65,6 @@
> >
> >  VIR_LOG_INIT("util.cgroup");
> >
> > -#define CGROUP_MAX_VAL 512
> > -
> >  #define VIR_FROM_THIS VIR_FROM_CGROUP
> >
> >  #define CGROUP_NB_TOTAL_CPU_STAT_PARAM 3
> > @@ -132,29 +131,20 @@ virCgroupGetDevicePermsString(int perms)
> >  bool
> >  virCgroupAvailable(void)
> >  {
> > -    bool ret = false;
> > -    FILE *mounts = NULL;
> > -    struct mntent entry;
> > -    char buf[CGROUP_MAX_VAL];
> > +    size_t i;
> > +    virCgroupBackendPtr *backends = virCgroupBackendGetAll();
> >
> > -    if (!virFileExists("/proc/cgroups"))
> > +    if (!backends)
> >          return false;
> >
> > -    if (!(mounts = fopen("/proc/mounts", "r")))
> > -        return false;
> > -
> > -    while (getmntent_r(mounts, &entry, buf, sizeof(buf)) != NULL) {
> > -        /* We're looking for at least one 'cgroup' fs mount,
> > -         * which is *not* a named mount. */
> > -        if (STREQ(entry.mnt_type, "cgroup") &&
> > -            !strstr(entry.mnt_opts, "name=")) {
> > -            ret = true;
> > -            break;
> > +    for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
> > +        if (backends[i] && backends[i]->available &&
> > +            backends[i]->available()) {
> >
> 
> A little bit down in this patch I see the following comment about the
> "available" callback:
> /* Mandatory callbacks that need to be implemented for every backend. */
> 
> Considering this is part of the mandatory ones, do we really need to do the
> `backends[i]->available` check?

Correct, I'll fix that before pushing.

Pavel

Attachment: signature.asc
Description: PGP signature

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

  Powered by Linux