From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 57490@debbugs.gnu.org
Subject: bug#57490: UPower ignores ‘critical-power-action’
Date: Sun, 02 Oct 2022 17:27:25 +0200 [thread overview]
Message-ID: <87wn9i9rfm.fsf@gnu.org> (raw)
In-Reply-To: <16fe99ab-4fa2-bcb1-e70b-b52bbc70c7f5@telenet.be> (Maxime Devos's message of "Mon, 5 Sep 2022 22:01:01 +0200")
Hi!
Maxime Devos <maximedevos@telenet.be> skribis:
> On 05-09-2022 14:56, Ludovic Courtès wrote:
>> I’d like to test whether UPower invokes the intended critical action,
>> but I’m not sure how to simulate a low battery level. Thoughts?
>
> I've found a 'Virtual Battery Driver': https://lwn.net/Articles/440097/
>
> The gmane links are dead, but the linux source tree as a
> drivers/power/supply/test_power.c that seems to be about the same
> thing.
I was able to give that a try. Since the default ‘percentage-action’ in
<upower-configuration> is 2, I did this (I configured syslogd to log to
/dev/console):
--8<---------------cut here---------------start------------->8---
root@antelope ~# modprobe test-power ac_online=off usb_online=off battery_capacity=2 battery_status=discharging
modprobe test-power ac_online=off usb_online=off battery_capacity=2 battery_status=discharging
Oct 2 17:00:20 localhost vmunix: [ 44.294530] __power_supply_register: Expected proper parent device for 'test_ac'
Oct 2 17:00:20 localhost vmunix: [ 44.295049] __power_supply_register: Expected proper parent device for 'test_battery'
Oct 2 17:00:20 localhost vmunix: [ 44.295147] __power_supply_register: Expected proper parent device for 'test_usb'
root@antelope ~# Oct 2 17:00:20 localhost shepherd[1]: [upowerd]
Oct 2 17:00:20 localhost shepherd[1]: [upowerd] (upowerd:186): UPower-Linux-WARNING **: 17:00:20.457: no valid voltage value found for device /sys/devices/virtual/power_supply/test_battery, assuming 10V
Oct 2 17:00:20 localhost shepherd[1]: [upowerd]
Oct 2 17:00:20 localhost shepherd[1]: [upowerd] (upowerd:186): UPower-Linux-WARNING **: 17:00:20.473: USB power supply /sys/devices/virtual/power_supply/test_usb without usb_type property, please report
root@antelope ~# Oct 2 17:00:41 localhost elogind[185]: System is powering down..
Oct 2 17:00:41 localhost elogind[185]: System is powering down..
Oct 2 17:00:41 localhost shepherd[1]: Exiting shepherd...
Oct 2 17:00:41 localhost shepherd[1]: Service ntpd has been stopped.
Oct 2 17:00:41 localhost ntpd[184]: ntpd exiting on signal 15 (Terminated)
Oct 2 17:00:41 localhost avahi-daemon[191]: Got SIGTERM, quitting.
Oct 2 17:00:41 localhost avahi-daemon[191]: Leaving mDNS multicast group on interface ens3.IPv6 with address fec0::e35c:509d:d937:2087.
Oct 2 17:00:41 localhost avahi-daemon[191]: Leaving mDNS multicast group on interface ens3.IPv4 with address 10.0.2.15.
Oct 2 17:00:41 localhost shepherd[1]: Service avahi-daemon has been stopped.
Oct 2 17:00:41 localhost NetworkManager[183]: <info> [1664722841.2220] caught SIGTERM, shutting down normally.
Oct 2 17:00:41 localhost shepherd[1]: Service networking has been stopped.
Oct 2 17:00:41 localhost shepherd[1]: Service console-font-tty6 has been stopped.
Oct 2 17:00:41 localhost shepherd[1]: Service term-tty6 has been stopped.
Oct 2 17:00:41 localhost NetworkManager[183]: <info> [1664722841.2318] dhcp4 (ens3): canceled DHCP transaction
Oct 2 17:00:41 localhost NetworkManager[183]: <info> [1664722841.2318] dhcp4 (ens3): activation: beginning transaction (timeout in 45 seconds)
Oct 2 17:00:41 localhost NetworkManager[183]: <info> [1664722841.2318] dhcp4 (ens3): state changed no lease
Oct 2 17:00:41 localhost NetworkManager[183]: <info> [1664722841.2326] manager: NetworkManager state is now CONNECTED_SITE
Oct 2 17:00:41 localhost NetworkManager[183]: <info> [1664722841.2335] exiting (success)
Oct 2 17:00:41 localhost avahi-daemon[191]: Leaving mDNS multicast group on interface lo.IPv6 with address ::1.
Oct 2 17:00:41 localhost syslogd: exiting on signal 15
[ 70.670560] reboot: Power down
--8<---------------cut here---------------end--------------->8---
So 20s after a battery at 2% got plugged in, UPower told elogind to
turn off the VM, which told shepherd to do that—exactly as expected.
It’s kinda disappointing to debug something just to find out it’s
working as advertised. I think the conclusion is that 2% is too low a
threshold, at least for my laptop, or maybe the charge estimate is
slightly off on my laptop. I’ll raise that threshold and see if it
works correctly next time I run out of battery…
If someone has better ideas, I’d love to hear them!
Ludo’.
next prev parent reply other threads:[~2022-10-02 15:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 15:59 bug#57490: UPower ignores ‘critical-power-action’ Ludovic Courtès
2022-08-30 16:22 ` Ludovic Courtès
2022-08-30 21:56 ` Ludovic Courtès
2022-08-31 14:46 ` Ludovic Courtès
2022-09-05 12:56 ` Ludovic Courtès
2022-09-05 20:01 ` Maxime Devos
2022-10-02 15:27 ` Ludovic Courtès [this message]
2022-09-20 10:05 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wn9i9rfm.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=57490@debbugs.gnu.org \
--cc=maximedevos@telenet.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.