First, I must apologize for the extremely long delay since v1 - it has been nearly 4 years, which is unacceptable. Life circumstances intervened.
This series introduces three ACPI devices that are particularly useful for laptop/mobile virtualization: * Battery * AC adapter * Laptop lid button Changes in v2: -------------- Based on the feedback from Philippe Mathieu-Daudé and Michael S. Tsirkin: * Complete redesign with dual-mode operation: - QMP control mode (default): Devices are controlled via QMP commands, providing deterministic behavior essential for migration and CI/testing - Host mirroring mode (opt-in): Original sysfs/procfs monitoring behavior, now disabled by default * Migrated to modern QEMU ACPI architecture: - Devices now implement ACPI_DEV_AML_IF interface - AML generation moved from centralized acpi-build.c to device files * Added a QMP interface: - battery-set-state/query-battery - ac-adapter-set-state/query-ac-adapter - lid-button-set-state/query-lid-button * Documentation improvements: - Converted to .rst format - Added examples for both QMP and "fake" sysfs/procfs testing The dual-mode design ensures these devices are migration-safe and deterministic by default, while still allowing host state mirroring when explicitly requested for desktop use cases. Use cases: ---------- 1. Testing: CI systems can programmatically control power states 2. Cloud: Expose virtual battery for usage-based resource limiting 3. Desktop virtualization: Mirror host laptop state to guest (opt-in) 4. Development: Test power management without physical hardware Example usage: -------------- # Default QMP-controlled battery qemu-system-x86_64 -device battery # Mirror host battery qemu-system-x86_64 -device battery,use-qmp=false,enable-sysfs=true # Control via QMP {"execute": "battery-set-state", "arguments": {"state": {"present": true, "charging": false, "discharging": true, "charge-percent": 42, "rate": 500}}} The series has been tested with Windows and Linux guests, correctly showing battery status, AC adapter state, and lid button events in guest UIs and triggering appropriate power management actions. Thanks again for your patience and feedback. Leonid. Leonid Bloch (4): hw/acpi: Increase the number of possible ACPI interrupts hw/acpi: Introduce the QEMU Battery hw/acpi: Introduce the QEMU AC adapter hw/acpi: Introduce the QEMU lid button MAINTAINERS | 18 + docs/specs/acad.rst | 195 +++++++ docs/specs/battery.rst | 225 ++++++++ docs/specs/button.rst | 189 +++++++ docs/specs/index.rst | 3 + hw/acpi/Kconfig | 12 + hw/acpi/acad.c | 447 ++++++++++++++++ hw/acpi/battery.c | 735 +++++++++++++++++++++++++++ hw/acpi/button.c | 438 ++++++++++++++++ hw/acpi/core.c | 17 +- hw/acpi/meson.build | 3 + hw/acpi/trace-events | 15 + hw/i386/Kconfig | 3 + hw/i386/acpi-build.c | 1 + include/hw/acpi/acad.h | 27 + include/hw/acpi/acpi_dev_interface.h | 3 + include/hw/acpi/battery.h | 33 ++ include/hw/acpi/button.h | 25 + qapi/acpi.json | 171 +++++++ 19 files changed, 2558 insertions(+), 2 deletions(-) create mode 100644 docs/specs/acad.rst create mode 100644 docs/specs/battery.rst create mode 100644 docs/specs/button.rst create mode 100644 hw/acpi/acad.c create mode 100644 hw/acpi/battery.c create mode 100644 hw/acpi/button.c create mode 100644 include/hw/acpi/acad.h create mode 100644 include/hw/acpi/battery.h create mode 100644 include/hw/acpi/button.h -- 2.50.1