Re: [PATCH] Drop dependency on pm-is-supported

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

 



On 03/28/2014 10:32 AM, Cédric Bosdonnat wrote:
> From: Cédric Bosdonnat <cedric.bosdonnat@xxxxxxx>
> 
> 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

Attachment: signature.asc
Description: OpenPGP digital signature

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