Hi Leonid, Marcel, On 1/20/21 9:54 PM, Leonid Bloch wrote: > This series introduces the following ACPI devices: > > * Battery > * AC adapter > * Laptop lid button > > When running QEMU on a laptop, these paravirtualized devices reflect the > state of these physical devices onto the guest. This functionality is > relevant not only for laptops, but also for any other device which has e.g. > a battery. This even allows to insert a ``fake'' battery to the > guest, in a form of a file which emulates the behavior of the actual > battery in sysfs. A possible use case for such a ``fake'' battery can be > limiting the budget of VM usage to a subscriber, in a naturally-visible way.
Your series looks good. Now for this feature to be even more useful for the community, it would be better to 1/ Have a generic (kind of abstract QDev) battery model. Your model would be the ISA implementation. But we could add LPC, SPI or I2C implementations for example. 2/ Make it a model backend accepting various kind of frontends: - host Linux sysfs mirroring is a particular frontend implementation - mirroring on Windows would be another - any connection (TCP) to battery simulator (Octave, ...) Meanwhile 2/ is not available, it would be useful to have QMP commands to set the battery charge and state (also max capacity). Ditto QMP command to set the LID/AC adapter state. > But of course, the main purpose here is addressing the desktop users. > > This series was tested with Windows and (desktop) Linux guests, on which > indeed the battery icon appears in the corresponding state (full, > charging, discharging, time remaining to empty, etc.) and the AC adapter > plugging/unplugging behaves as expected. So is the laptop lid button. [...] In patch #2 you comment 'if a "fake" host battery is to be provided, a 'sysfs_path' property allows to override the default one.'. Eventually you'd provide a such fake file as example, ideally used by a QTest. Another question. If the battery is disconnected, is there an event propagated to the guest? Thanks for contributing these patches :) Phil.