[Feature Request] Battery Status / Virtual Battery

Bug #1502613 reported by Wolfgang Andreas
46
This bug affects 7 people
Affects Status Importance Assigned to Milestone
QEMU
Invalid
Wishlist
Unassigned

Bug Description

When using virtualization on notebooks heavily then virtual machines do not realize that they're running on a notebook device causing high power consumption because they're not switching into a optimized "laptop mode". This leads to the circumstance that they are trying to do things like defragmentation / virtus scan / etc. while the host is still running on batteries.

So it would be great if QEMU / KVM would have support for emulating "Virtual Batteries" to guests causing them to enable power-saving options like disabling specific services / devices / file operations automatically by OS.

Optionally a great feature would be to set virtual battery's status manually. For example: Current charge rate / charging / discharging / ...

Revision history for this message
Naftaly Avadiaev (naftaly-avadiaev) wrote :

I'm trying to add virtual battery to QEMU. More specifically, if the HOST is running on battery power [laptop] I want to pass this knowledge to GUEST.

I have looked at ACPI folder within QEMU source code, however was unable to find the specific place where I can add this functionality.

Can someone provide me with general roadmap of what should I do and where I should start? I suspect that changing the QEMU source code will not be enough and I will also have to implement a driver for the GUEST.

Thomas Huth (th-huth)
Changed in qemu:
importance: Undecided → Wishlist
Revision history for this message
Sergey Nizovtsev (snizovtsev) wrote :

I've started working on this issue and have some progress. Fedora 31 guest is already able to see a battery device but its state currently hardcoded. I think i will finish this in a few weeks.

Changed in qemu:
assignee: nobody → Sergey Nizovtsev (snizovtsev)
status: New → In Progress
Revision history for this message
mizz (kranebrain) wrote :

Has there been any progress? I'm using KVM for ubuntu 20.04 and would love to have this feature.

Revision history for this message
Philippe Mathieu-Daudé (philmd) wrote :

The implementation could be similar to the temperature sensor interface proposed here:
https://<email address hidden>/msg65192.html

Revision history for this message
Sergey Nizovtsev (snizovtsev) wrote :

mizz,

I'm worked on it and got a working draft on pre-5.0 codebase. It can react on QMP property changes to trigger ACPI events on x86 and arm-virt.

However i've stuck on frontend/backend split. Keep calm, i'm still working on the task and will complete this soon.

Philippe, thanks for advice!

Revision history for this message
Nahuel Pastorale (npastorale) wrote :

I just wanted to add that this would (probably) help solve the error 43 on mobile Nvidia GPU passthrough scenarios. While facing this myself I was able to get it working by simulating a battery and attaching it via an ACPI table.
Your work is greatly appreciated Sergey.
Thank you very much!

Changed in qemu:
assignee: Sergey Nizovtsev (snizovtsev) → nobody
status: In Progress → New
Revision history for this message
Philippe Mathieu-Daudé (philmd) wrote : Moved bug report

This is an automated cleanup. This bug report has been moved to QEMU's
new bug tracker on gitlab.com and thus gets marked as 'invalid' now.
Please continue with the discussion here:

 https://gitlab.com/qemu-project/qemu/-/issues/242

Changed in qemu:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.