Re: [PATCH 1/5] Introduce a more convenient virCgroupNewDetectMachine

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

 



On Thu, Jul 25, 2013 at 11:37:12AM -0600, Eric Blake wrote:
> On 07/25/2013 06:20 AM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> > 
> > Instead of requiring drivers to use a combination of calls
> > to virCgroupNewDetect and virCgroupIsValidMachine, combine
> > the two into virCgroupNewDetectMachine
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> > ---
> >  src/libvirt_private.syms |  1 +
> >  src/lxc/lxc_process.c    | 20 ++++++++------------
> >  src/qemu/qemu_cgroup.c   | 16 ++++------------
> >  src/util/vircgroup.c     | 22 ++++++++++++++++++++++
> >  src/util/vircgroup.h     |  5 +++++
> >  5 files changed, 40 insertions(+), 24 deletions(-)
> 
> > @@ -1575,6 +1575,28 @@ int virCgroupNewDetect(pid_t pid ATTRIBUTE_UNUSED,
> >  }
> >  #endif
> >  
> > +/*
> > + * Returns 0 on success, -1 on fatal error, -2 on no valid cgroup
> > + */
> > +int virCgroupNewDetectMachine(const char *name,
> > +                              const char *drivername,
> > +                              pid_t pid,
> > +                              virCgroupPtr *group)
> > +{
> > +    if (virCgroupNewDetect(pid, group) < 0) {
> > +        if (virCgroupNewIgnoreError())
> > +            return 0;
> > +        return -1;
> > +    }
> > +
> > +    if (!virCgroupIsValidMachineGroup(*group, name, drivername)) {
> > +        virCgroupFree(group);
> > +        return 0;
> 
> Huh? This says you are returning success.  Also, none of the lxc or qemu
> callers checked for a -2 return; do you really need the differentiated
> return type?

Opps the comment is wrong. I originally had it returning -2, but I
removed that and just useed '0' and let the caller check if 'group != NULL'
instead.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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