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. -- Cedric -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list