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

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

 



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.

> 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


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

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