qubes-issues icon indicating copy to clipboard operation
qubes-issues copied to clipboard

Qubes does not reliably suspend at 10% power level (even if told so in System Tools -> Power Manager -> System)

Open rwiesbach opened this issue 3 years ago • 7 comments

How to file a helpful issue

Qubes OS release

4.1.1

Brief summary

Qubes does not reliably suspend at 10% power level (even if told so in System Tools -> Power Manager -> System). Sometimes it actually does suspend at 10%, but often (maybe mostly) it does not. Even if this is set I experience (sudden) power outages during usage. I have to admit that I usually miss the notifications in the upper right corner that would report a power warning.

This should either be fixed or at least the warning should be more obvious. As you probably know Windows has a full screen warning for low battery situations - you cannot miss such a warning, but easily miss the notifications.

Steps to reproduce

Expected behavior

Suspend on critical power level

Actual behavior

nothing

rwiesbach avatar Sep 28 '22 12:09 rwiesbach

Is there any update regarding this? It just happened to me again and happens about once every two weeks. It is so annoying having to bootup all VMs again, opening all tools and files/websites ans and sometimes even have to rework unsafed states, just because Qubes/Xen/Xfce cannot manage to suspend at 10% or at least give a proper warning that you do not miss when working and therefore being focused on your work. Thank you.

rwiesbach avatar Dec 11 '22 12:12 rwiesbach

Issue persists under 4.2, please adjust "affects-4.2"

For me (at least in 4.1, not experienced yet under 4.2 as just updated yesterday) I get corrupted VM templates ("private/root already available" error messages) which is a real pain to fix... I hoped 4.2 would solve it, but even now my battery was down to 5% and I just barely got the laptop to shut down

MichaelAnders avatar Feb 26 '24 09:02 MichaelAnders

Can't reproduce on my system (NV41; critical level set at 8%; ~10 or so incidents so far where it went to stand-by every time). So this issue is probably hardware related.

Suggestion

As a side note might I suggest checking for the following system files:

/sys/class/power_supply/BAT0/charge_control_start_threshold
/sys/class/power_supply/BAT0/charge_control_end_threshold

If they are present, you can set the value using e.g.

sudo su -c 'echo '"$CAPACITY"' > /sys/class/power_supply/BAT0/charge_control_end_threshold'

where CAPACITY can be your current charge level or whatever end-of-charge level you prefer (e.g. 76). Can be automated with a script called by a keyboard shortcut:

#!/bin/bash
# reads the capacity value (current charge percentage) first and then sets the start and end values to prevent charging when AC power is subsequently plugged in
if [ -z $1 ];then
	CAPACITY=$(($(cat /sys/class/power_supply/BAT0/capacity) - 5))
else
	CAPACITY=76
fi
sleep 1
sudo su -c 'echo '"$CAPACITY"' > /sys/class/power_supply/BAT0/charge_control_end_threshold'
sleep 1
sudo su -c 'echo '"$(($CAPACITY - 5))"' > /sys/class/power_supply/BAT0/charge_control_start_threshold'
sleep 1
END_THRES=$(cat /sys/class/power_supply/BAT0/charge_control_end_threshold)
notify-send "Limited battery threshold" "end: $END_THRES"

This way, if you have AC power available, you can press the keyboard shortcut that calls the above script and then plug in your AC power cable. If the files are present and the firmware works correctly then it should just switch to AC without charging the battery.

UndeadDevel avatar Feb 26 '24 10:02 UndeadDevel

@MichaelAnders What kind of hardware do you use? Mine is a Lenovo T490, i5-8365U CPU and Intel UHD Graphics 620 rev 02.

rwiesbach avatar Feb 26 '24 11:02 rwiesbach

Lenovo L15 Gen 2a, model 20X7003TUK, Ryzen 7 Pro 5850U (incl. Radeon GPU) BIOS Setting for "Sleep state" is set to Linux instead of Windows

/sys/class/power_supply/BAT0/charge_control_start_threshold = 0 /sys/class/power_supply/BAT0/charge_control_end_threshold = 100 (setting to <= 80% might indeed make sense regarding battery life)

MichaelAnders avatar Feb 26 '24 13:02 MichaelAnders

I've seen some systems have a setting to wake up the system when battery is low (supposedly to go from "suspend to ram" to "suspend to disk"). Maybe you can have an option like this in your firmware setup?

marmarek avatar Feb 26 '24 13:02 marmarek

I've seen some systems have a setting to wake up the system when battery is low (supposedly to go from "suspend to ram" to "suspend to disk"). Maybe you can have an option like this in your firmware setup?

Unfortunately, no. The BIOS options on the Lenovo L15 are very less. Unrelated, but: it does go into standby perfectly though when I close the lid - that's nice!

Do you know any way to e.g. view a log / increase a log level or something so that I could see if some error is being logged to take it from there?

MichaelAnders avatar Feb 29 '24 13:02 MichaelAnders