[libvirt] [PATCH v3] Introduce --without-pm-utils to get rid of pm-is-supported dependency

Daniel P. Berrange berrange at redhat.com
Wed Apr 2 14:06:25 UTC 2014


On Wed, Apr 02, 2014 at 03:57:44PM +0200, Cedric Bosdonnat wrote:
> On Wed, 2014-04-02 at 15:52 +0200, Daniel P. Berrange wrote:
> > On Wed, Apr 02, 2014 at 03:35:51PM +0200, Cédric Bosdonnat wrote:
> > > This uses the dbus api of systemd to check the power management
> > > capabilities of the node.
> > > ---
> > >  Diff with v2:
> > >    * Fixed a few dbus call problems
> > > 
> > >  configure.ac              | 11 +++++++++
> > >  libvirt.spec.in           |  9 ++++++++
> > >  src/libvirt_private.syms  |  3 +++
> > >  src/util/virnodesuspend.c | 32 +++++++++++++++++++++++++
> > >  src/util/virsystemd.c     | 59 +++++++++++++++++++++++++++++++++++++++++++++++
> > >  src/util/virsystemd.h     |  6 +++++
> > >  6 files changed, 120 insertions(+)
> > 
> > Could you also add a test to  tests/virsystemdtest.c to exercuse
> > these hekper APIs.
> 
> Will do it.
> 
> > > diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
> > > index 8088931..ba4a338 100644
> > > --- a/src/util/virnodesuspend.c
> > > +++ b/src/util/virnodesuspend.c
> > > @@ -22,6 +22,9 @@
> > >  #include <config.h>
> > >  #include "virnodesuspend.h"
> > >  
> > > +#ifndef WITH_PM_UTILS
> > > +# include "virsystemd.h"
> > > +#endif
> > >  #include "vircommand.h"
> > >  #include "virthread.h"
> > >  #include "datatypes.h"
> > > @@ -260,6 +263,7 @@ int nodeSuspendForDuration(unsigned int target,
> > >   *
> > >   * Returns 0 if the query was successful, -1 on failure.
> > >   */
> > > +#ifdef WITH_PM_UTILS
> > >  static int
> > >  virNodeSuspendSupportsTarget(unsigned int target, bool *supported)
> > >  {
> > > @@ -300,6 +304,34 @@ virNodeSuspendSupportsTarget(unsigned int target, bool *supported)
> > >      virCommandFree(cmd);
> > >      return ret;
> > >  }
> > > +#else /* ! WITH_PM_UTILS */
> > > +static int
> > > +virNodeSuspendSupportsTarget(unsigned int target, bool *supported)
> > > +{
> > > +    int ret = -1;
> > > +
> > > +    if (virNodeSuspendInitialize() < 0)
> > > +        return -1;
> > > +
> > > +    *supported = false;
> > > +
> > > +    switch (target) {
> > > +    case VIR_NODE_SUSPEND_TARGET_MEM:
> > > +        ret = virSystemdCanSuspend(supported);
> > > +        break;
> > > +    case VIR_NODE_SUSPEND_TARGET_DISK:
> > > +        ret = virSystemdCanHibernate(supported);
> > > +        break;
> > > +    case VIR_NODE_SUSPEND_TARGET_HYBRID:
> > > +        ret = virSystemdCanHybridSleep(supported);
> > > +        break;
> > > +    default:
> > > +        return ret;
> > > +    }
> > > +
> > > +    return ret;
> > > +}
> > > +#endif /* WITH_PM_UTILS */
> > 
> > Rather than having a hardcoded choice of pm-utils vs systemd
> > I think we should check if the systemd service is running and
> > if so use it, otherwise fallback to pm-utils. That way if 
> > someone has systemd installed, but is not running it as their
> > init, things would still work
> 
> The idea is also to be able to drop the Requires: pm-utils in the spec
> file... so a runtime check wouldn't help this.

Oh, i mean you can still have WITH_PM_UTILS conditional in the RPM
spec / configure check. Downstream user can thus have the option to
have both enabled at build time, or to disable pm-utils and only rely
on systemd.  ie we'd default to everything enabled and fully dynamic
at runtime, but we'd set the RPM builds to disable pm-utils on
Fedora >= 20

Regards,
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 :|




More information about the libvir-list mailing list