By now, all devices of QEMU do not have much more power management consideration, for example, if system do suspend, it will call all registered notifiers, this was loosely required, and the code to do power management state transition seems just do 'ugly emulation', rather than be conscious with whole system devices, same condition with reset(it has been embedded in DeviceClass, good!), shutdown, in real world, commonly all devices' power are controlled by a power chip, then all power sequence can be done just issue commands to this chip. so, I come across an idea to implement qdev'ed power device, and make all qdev struct of devices aware of self power management(add on/off/wakeup/suspend ... filed for DeviceClass), this will bring tidy power management, and the emulation will more like what happened in real world.
Of course, it's only a patch-set for RFC, I'd like to ask all developers to help correct this idea, if it's worth to implement, I'll go head to refactor more. Li Guang (14) gitignore: ignore more files qdev: add power management method qdev: remove redundant abort() qdev: add power on/off/suspend/wakeup handler power: add power chip emulation sysemu: remove PowerReason in sysemu.h acpi: refactor acpi wakeup function ich9: make lpc's reset also do pm_reset ich9: do lpc's power on by reset function piix4: refactor piix4's power callbacks pckbd: refactor pckbd's power callbacks ps2: call ps2_{kbd,mouse}_reset in kbd_reset parallel: refactor parallel_reset function uhci: refactor uhci's power callbacks .gitignore | 3 +++ Makefile.objs | 1 + hw/acpi.c | 20 +++++++++----------- hw/acpi.h | 3 ++- hw/acpi_ich9.c | 4 ++-- hw/ich9.h | 1 + hw/lpc_ich9.c | 12 ++++++++++- hw/parallel.c | 10 ++++++---- hw/pckbd.c | 25 ++++++++++++---------- hw/piix4.c | 14 ++++++++++++-- hw/ps2.c | 8 ++++---- hw/ps2.h | 2 ++ hw/qdev-core.h | 15 ++++++ hw/qdev.c | 99 +-- hw/usb/hcd-uhci.c | 10 ++++++++++ include/sysemu/sysemu.h | 7 +------ power.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ power.h | 41 +++++++++++++++++ 18 files changed, 365 insertions(+), 43 deletions(-) create mode 100644 power.c create mode 100644 power.h