Shutdown requests are normally hardware dependent. By extending pvpanic to also handle shutdown requests, guests can submit such requests with an easily implementable and cross-platform mechanism. The background is the usage of minimal Linux kernels with different architectures for testing purposes. Poweroff support varies highly per architecture and requires a bunch of code to be compiled to work. pvpanic on the other hand is very small and uniform. Patch 1 is a fix for scripts/update-linux-headers.sh Patch 2 updates the bundled linux headers to Linux v6.10-rc1. Patch 3 and 4 are general cleanups, which seem useful even without this proposal being implemented. They should also be ready to be picked up from the series on their own. The remaining patches implement the new functionality and update the docs. The matching driver for Linux is part of Linux v6.10-rc1. To: Michael S. Tsirkin <mst@xxxxxxxxxx> To: Cornelia Huck <cohuck@xxxxxxxxxx> To: Paolo Bonzini <pbonzini@xxxxxxxxxx> To: Thomas Huth <thuth@xxxxxxxxxx> To: Laurent Vivier <lvivier@xxxxxxxxxx> To: Eric Blake <eblake@xxxxxxxxxx> To: Markus Armbruster <armbru@xxxxxxxxxx> Cc: qemu-devel@xxxxxxxxxx Cc: Alejandro Jimenez <alejandro.j.jimenez@xxxxxxxxxx> Cc: kvm@xxxxxxxxxxxxxxx Signed-off-by: Thomas Weißschuh <thomas@xxxxxxxx> Changes in v8: - Import linux headers from v6.10-rc1 (and update series subject) - Use PVPANIC_SHUTDOWN from new linux headers - Update Since: tag in QAPI to 9.1 - Link to v7: https://lore.kernel.org/r/20240323-pvpanic-shutdown-v7-0-4ac1fd546d6f@xxxxxxxx Changes in v7: - Keep standard-header/pvpanic.h - Predefine PVPANIC_SHUTDOWN in include/hw/misc/pvpanic.h - Fix alignment in QAPI to comply with newly enforced layout - Update Since: tag in QAPI to 9.0 - Drop note from pvpanic spec about missing implementation - Link to v6: https://lore.kernel.org/r/20240208-pvpanic-shutdown-v6-0-965580ac057b@xxxxxxxx Changes in v6: - Replace magic constant "4" in tests with PVPANIC_SHUTDOWN - Link to v5: https://lore.kernel.org/r/20240129-pvpanic-shutdown-v5-0-f5a060b87c74@xxxxxxxx Changes in v5: - Add patch from Alejandro to emit a QMP event. - Update cover letter. - Add tests. - Link to v4: https://lore.kernel.org/r/20240107-pvpanic-shutdown-v4-0-81500a7e4081@xxxxxxxx Changes in v4: - Rebase on 8.2 master - Resend after tree reopened and holidays - Link to v3: https://lore.kernel.org/r/20231129-pvpanic-shutdown-v3-0-c9a2892fc523@xxxxxxxx Changes in v3: - Drop from Linux imported pvpanic header as discussed with Cornelia and requested by Greg - Link to v2: https://lore.kernel.org/r/20231128-pvpanic-shutdown-v2-0-830393b45cb6@xxxxxxxx Changes in v2: - Remove RFC status - Add Ack from Thomas to 2nd patch - Fix typo in title of 2nd patch - Link to v1: https://lore.kernel.org/r/20231104-pvpanic-shutdown-v1-0-02353157891b@xxxxxxxx --- Alejandro Jimenez (1): pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal Thomas Weißschuh (7): scripts/update-linux-headers: Copy setup_data.h to correct directory linux-headers: update to 6.10-rc1 hw/misc/pvpanic: centralize definition of supported events tests/qtest/pvpanic: use centralized definition of supported events hw/misc/pvpanic: add support for normal shutdowns tests/qtest/pvpanic: add tests for pvshutdown event Revert "docs/specs/pvpanic: mark shutdown event as not implemented" docs/specs/pvpanic.rst | 2 +- hw/misc/pvpanic-isa.c | 3 +- hw/misc/pvpanic-pci.c | 3 +- hw/misc/pvpanic.c | 8 +- include/hw/misc/pvpanic.h | 4 + include/standard-headers/linux/ethtool.h | 55 +++++++++++ include/standard-headers/linux/pci_regs.h | 6 ++ include/standard-headers/linux/pvpanic.h | 7 +- include/standard-headers/linux/virtio_bt.h | 1 - include/standard-headers/linux/virtio_mem.h | 2 + include/standard-headers/linux/virtio_net.h | 143 ++++++++++++++++++++++++++++ include/sysemu/runstate.h | 1 + linux-headers/asm-generic/unistd.h | 5 +- linux-headers/asm-loongarch/kvm.h | 4 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 4 +- linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 2 + linux-headers/linux/kvm.h | 4 +- linux-headers/linux/stddef.h | 8 ++ linux-headers/linux/vhost.h | 15 +-- qapi/run-state.json | 14 +++ scripts/update-linux-headers.sh | 2 +- system/runstate.c | 6 ++ tests/qtest/pvpanic-pci-test.c | 44 ++++++++- tests/qtest/pvpanic-test.c | 34 ++++++- 34 files changed, 361 insertions(+), 26 deletions(-) --- base-commit: 60b54b67c63d8f076152e0f7dccf39854dfc6a77 change-id: 20231104-pvpanic-shutdown-02e4b4cb4949 Best regards, -- Thomas Weißschuh <thomas@xxxxxxxx>