[libvirt] [PATCH] Drop dependency on pm-is-supported

Eric Blake eblake at redhat.com
Fri Mar 28 20:07:36 UTC 2014


On 03/28/2014 10:32 AM, Cédric Bosdonnat wrote:
> From: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
> 
> pm-is-supported is the only thing needed in pm-utils, better get rid of
> it since systemd is heavily used for libvirt.
> ---
>  src/util/virnodesuspend.c | 34 ++++++++++++++++++++--------------
>  1 file changed, 20 insertions(+), 14 deletions(-)

You also need to modify libvirt.spec.in to drop the dependency.

> 
>  
> +    if (virFileReadAll("/sys/power/state", 1024, &buf) < 0)
> +        goto cleanup;
> +
> +    states = virStringSplit(buf, " ", 0);
> +
> +    canSuspend = (virStringArrayHasString(states, "mem") ||
> +                  virStringArrayHasString(states, "standby"));
> +    canHibernate = virStringArrayHasString(states, "disk");

pm-is-supported checks a bit more than what your replacement checks.

For suspend, it declares yes if any of these succeed:
	grep -q mem /sys/power/state
	[ -c /dev/pmu ] && pm-pmu --check
	grep -q standby /sys/power/state

For hibernate, it requires that BOTH of these succeed:
	[ -f /sys/power/disk ]
	grep -q disk /sys/power/state

For hybrid, it requires that all three succeed:
	[ -f /sys/power/disk ] && \
	grep -q disk /sys/power/state && \
	grep -q suspend /sys/power/disk

as well as having fallback code to fake a hybrid sleep by joining the
other two states.


> +
>      switch (target) {
>      case VIR_NODE_SUSPEND_TARGET_MEM:
> -        cmd = virCommandNewArgList("pm-is-supported", "--suspend", NULL);
> +        *supported = canSuspend;
>          break;
>      case VIR_NODE_SUSPEND_TARGET_DISK:
> -        cmd = virCommandNewArgList("pm-is-supported", "--hibernate", NULL);
> +        *supported = canHibernate;
>          break;
>      case VIR_NODE_SUSPEND_TARGET_HYBRID:
> -        cmd = virCommandNewArgList("pm-is-supported", "--suspend-hybrid", NULL);
> +        *supported = canSuspend && canHibernate;

I'm not sure if your simpler checks will cause us to declare an action
unsupported on systems where it was previously declared supported by
pm-is-supported.  I think the idea makes sense, but I'd like a second
opinion that we aren't hurting ourselves by doing fewer checks than what
we are replacing.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140328/c4700604/attachment-0001.sig>


More information about the libvir-list mailing list