Allows guests to be powered off via an ACPI power button event which can be triggered e.g. through the GTK GUI.
Signed-off-by: Bernhard Beschow <shen...@gmail.com> --- hw/isa/vt82c686.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 7b44ad9485..e8ec63dea9 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -33,8 +33,10 @@ #include "qapi/error.h" #include "qemu/log.h" #include "qemu/module.h" +#include "qemu/notify.h" #include "qemu/range.h" #include "qemu/timer.h" +#include "sysemu/runstate.h" #include "trace.h" #define TYPE_VIA_PM "via-pm" @@ -52,6 +54,8 @@ struct ViaPMState { APMState apm; PMSMBus smb; + Notifier powerdown_notifier; + qemu_irq sci_irq; }; @@ -172,6 +176,13 @@ static void via_pm_reset(DeviceState *d) smb_io_space_update(s); } +static void via_pm_powerdown_req(Notifier *n, void *opaque) +{ + ViaPMState *s = container_of(n, ViaPMState, powerdown_notifier); + + acpi_pm1_evt_power_down(&s->ar); +} + static void via_pm_realize(PCIDevice *dev, Error **errp) { ViaPMState *s = VIA_PM(dev); @@ -193,6 +204,9 @@ static void via_pm_realize(PCIDevice *dev, Error **errp) acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io); acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2, false); acpi_gpe_init(&s->ar, VIA_PM_GPE_LEN); + + s->powerdown_notifier.notify = via_pm_powerdown_req; + qemu_register_powerdown_notifier(&s->powerdown_notifier); } static void via_pm_init(Object *obj) -- 2.42.0