Skip to contentSkip to conversation

event: Add source information to SHUTDOWN

PATCH Superseded Eric Blake 1 participant 7 messages Apr 27, 2017

Subsystems (2)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
author
#3 lore raw

PATCH v4 3/4 shutdown: Add source information to SHUTDOWN and RESET

In reply to Eric Blake

Libvirt would like to be able to distinguish between a SHUTDOWN event triggered solely by guest request and one triggered by a SIGTERM or other action on the host. While qemu_kill_report() is already able to tell whether a shutdown was triggered by a host signal (but NOT by a host UI event, such as clicking the X on the window), that information was then lost after being printed to stderr. The previous patch prepped things to use an enum internally; now it's time to wire it up through all callers, and to extend the SHUTDOWN and RESET events to report the details.

Enhance the shutdown request path to take a parameter of which way it is being triggered, and update ALL callers. It would have been less churn to keep the common case with no arguments as meaning guest-triggered, and only modified the host-triggered code paths, via a wrapper function, but then we'd still have to audit that I didn't miss any host-triggered spots; changing the signature forces us to double-check that I correctly categorized all callers.

Since command line options can change whether a guest reset request causes an actual reset vs. a shutdown, it's easy to also add the information to the RESET event, even though libvirt has not yet expressed a need to know that.

For the moment, we keep the enum ShutdownCause for internal use only, and merely expose a single boolean of 'guest':true|false to the QMP client; this is because we don't yet have evidence that the further distinctions will be useful, or whether the addition of new enum members would cause problems to clients coded to an older version of the enum.

Update expected iotest outputs to match the new data.

Here is output from 'virsh qemu-monitor-event --loop' with the patch installed:

event SHUTDOWN at 1492639680.731251 for domain fedora_13: {"guest":true} event STOP at 1492639680.732116 for domain fedora_13: <null> event SHUTDOWN at 1492639680.732830 for domain fedora_13: {"guest":false}

Note that libvirt runs qemu with -no-quit: the first SHUTDOWN event was triggered by an action I took directly in the guest (shutdown -h), at which point qemu stops the vcpus and waits for libvirt to do any final cleanups; the second SHUTDOWN event is the result of libvirt sending SIGTERM now that it has completed cleanup.

The replay driver needs a followup patch if we want to be able to faithfully replay the difference between a host- and guest-initiated shutdown (for now, the replayed event is always attributed to host).

See also https://bugzilla.redhat.com/1384007

---
v4: s/ShutdownType/ShutdownCause/, no thanks to mingw header pollution
v3: retitle again, fix qemu-iotests, use enum rather than raw bool in all callers
v2: retitle (was "event: Add signal information to SHUTDOWN"), completely rework to post bool based on whether it is guest-initiated
v1: initial submission, exposing just Unix signals from host

---
 qapi/event.json             |    17 +-
 include/sysemu/sysemu.h     |     4 +-
 trace/generated-tracers.h   | 18523 ++++++++++++++++++++++++++++++++++++++++++
 vl.c                        |    22 +-
 foo.c                       |   121 +
 hw/acpi/core.c              |     4 +-
 hw/arm/highbank.c           |     4 +-
 hw/arm/integratorcp.c       |     2 +-
 hw/arm/musicpal.c           |     2 +-
 hw/arm/omap1.c              |    10 +-
 hw/arm/omap2.c              |     2 +-
 hw/arm/spitz.c              |     2 +-
 hw/arm/stellaris.c          |     2 +-
 hw/arm/tosa.c               |     2 +-
 hw/i386/pc.c                |     2 +-
 hw/i386/xen/xen-hvm.c       |     2 +-
 hw/input/pckbd.c            |     4 +-
 hw/ipmi/ipmi.c              |     4 +-
 hw/isa/lpc_ich9.c           |     2 +-
 hw/mips/boston.c            |     2 +-
 hw/mips/mips_malta.c        |     2 +-
 hw/mips/mips_r4k.c          |     4 +-
 hw/misc/arm_sysctl.c        |     8 +-
 hw/misc/cbus.c              |     2 +-
 hw/misc/macio/cuda.c        |     4 +-
 hw/misc/slavio_misc.c       |     4 +-
 hw/misc/zynq_slcr.c         |     2 +-
 hw/pci-host/apb.c           |     4 +-
 hw/pci-host/bonito.c        |     2 +-
 hw/pci-host/piix.c          |     2 +-
 hw/ppc/e500.c               |     2 +-
 hw/ppc/mpc8544_guts.c       |     2 +-
 hw/ppc/ppc.c                |     2 +-
 hw/ppc/ppc405_uc.c          |     2 +-
 hw/ppc/spapr_hcall.c        |     2 +-
 hw/ppc/spapr_rtas.c         |     4 +-
 hw/s390x/ipl.c              |     2 +-
 hw/sh4/r2d.c                |     2 +-
 hw/timer/etraxfs_timer.c    |     2 +-
 hw/timer/m48t59.c           |     4 +-
 hw/timer/milkymist-sysctl.c |     4 +-
 hw/timer/pxa2xx_timer.c     |     2 +-
 hw/watchdog/watchdog.c      |     2 +-
 hw/xenpv/xen_domainbuild.c  |     2 +-
 hw/xtensa/xtfpga.c          |     2 +-
 kvm-all.c                   |     6 +-
 os-win32.c                  |     2 +-
 qmp.c                       |     4 +-
 replay/replay.c             |     5 +-
 target/alpha/sys_helper.c   |     4 +-
 target/arm/psci.c           |     4 +-
 target/i386/excp_helper.c   |     2 +-
 target/i386/hax-all.c       |     6 +-
 target/i386/helper.c        |     2 +-
 target/i386/kvm.c           |     2 +-
 target/s390x/helper.c       |     2 +-
 target/s390x/kvm.c          |     4 +-
 target/s390x/misc_helper.c  |     4 +-
 target/sparc/int32_helper.c |     2 +-
 ui/sdl.c                    |     2 +-
 ui/sdl2.c                   |     4 +-
 bar                         |   Bin 0 -> 67108864 bytes
 bar.src                     |   Bin 0 -> 560 bytes
 file                        |   Bin 0 -> 1900544 bytes
 file2                       |   Bin 0 -> 10485760 bytes
 file3                       |   Bin 0 -> 15728640 bytes
 foo                         |   Bin 0 -> 13344 bytes
 tests/qemu-iotests/071.out  |     4 +-
 tests/qemu-iotests/081.out  |     2 +-
 tests/qemu-iotests/087.out  |    12 +-
 tests/qemu-iotests/094.out  |     2 +-
 tests/qemu-iotests/117.out  |     2 +-
 tests/qemu-iotests/119.out  |     2 +-
 tests/qemu-iotests/120.out  |     2 +-
 tests/qemu-iotests/140.out  |     2 +-
 tests/qemu-iotests/143.out  |     2 +-
 tests/qemu-iotests/156.out  |     2 +-
 tests/test-hmp              |   Bin 0 -> 603288 bytes
 trace-events                |     2 +-
 ui/cocoa.m                  |     2 +-
 80 files changed, 18776 insertions(+), 118 deletions(-)
 create mode 100644 trace/generated-tracers.h
 create mode 100644 foo.c
 create mode 100644 bar
 create mode 100644 bar.src
 create mode 100644 file
 create mode 100644 file2
 create mode 100644 file3
 create mode 100755 foo
 create mode 100755 tests/test-hmp
qapi/event.json +13 -4
index e80f3f4..6d22b02 100644
@@ -10,6 +10,10 @@
 # Emitted when the virtual machine has shut down, indicating that qemu is
 # about to exit.
 #
+# @guest: If true, the shutdown was triggered by a guest request (such as
+# a guest-initiated ACPI shutdown request or other hardware-specific action)
+# rather than a host request (such as sending qemu a SIGINT). (since 2.10)
+#
 # Note: If the command-line option "-no-shutdown" has been specified, qemu will
 # not exit, and a STOP event will eventually follow the SHUTDOWN event
 #
@@ -17,11 +21,11 @@
 #
 # Example:
 #
-# <- { "event": "SHUTDOWN",
+# <- { "event": "SHUTDOWN", "data": { "guest": true },
 #      "timestamp": { "seconds": 1267040730, "microseconds": 682951 } }
 #
 ##
-{ 'event': 'SHUTDOWN' }
+{ 'event': 'SHUTDOWN', 'data': { 'guest': 'bool' } }
 
 ##
 # @POWERDOWN:
@@ -44,15 +48,20 @@
 #
 # Emitted when the virtual machine is reset
 #
+# @guest: If true, the reset was triggered by a guest request (such as
+# a guest-initiated ACPI reboot request or other hardware-specific action)
+# rather than a host request (such as the QMP command system_reset).
+# (since 2.10)
+#
 # Since: 0.12.0
 #
 # Example:
 #
-# <- { "event": "RESET",
+# <- { "event": "RESET", "data": { "guest": false },
 #      "timestamp": { "seconds": 1267041653, "microseconds": 9518 } }
 #
 ##
-{ 'event': 'RESET' }
+{ 'event': 'RESET', 'data': { 'guest': 'bool' } }
 
 ##
 # @STOP:
include/sysemu/sysemu.h +2 -2
index 00a907f..ffbf9ac 100644
@@ -49,13 +49,13 @@ typedef enum WakeupReason {
     QEMU_WAKEUP_REASON_OTHER,
 } WakeupReason;
 
-void qemu_system_reset_request(void);
+void qemu_system_reset_request(ShutdownCause reason);
 void qemu_system_suspend_request(void);
 void qemu_register_suspend_notifier(Notifier *notifier);
 void qemu_system_wakeup_request(WakeupReason reason);
 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
 void qemu_register_wakeup_notifier(Notifier *notifier);
-void qemu_system_shutdown_request(void);
+void qemu_system_shutdown_request(ShutdownCause reason);
 void qemu_system_powerdown_request(void);
 void qemu_register_powerdown_notifier(Notifier *notifier);
 void qemu_system_debug_request(void);
trace/generated-tracers.h new file +18523 -0

2,940 lines not on this page · raw message

vl.c +11 -11
index 2b95b7f..0a933ba 100644

Lines of this file are not shown. View the raw message.

foo.c new file +121 -0

121 lines not on this page · raw message

hw/acpi/core.c +2 -2
index e890a5d..95fcac9 100644

Lines of this file are not shown. View the raw message.

hw/arm/highbank.c +2 -2
index 0a4508c..d209b97 100644

Lines of this file are not shown. View the raw message.

hw/arm/integratorcp.c +1 -1
index 5610ffc..ca3eca1 100644

Lines of this file are not shown. View the raw message.

hw/arm/musicpal.c +1 -1
index cbbca4e..9c710f7 100644

Lines of this file are not shown. View the raw message.

hw/arm/omap1.c +6 -4
index b3cf0ec..54582bd 100644

Lines of this file are not shown. View the raw message.

hw/arm/omap2.c +1 -1
index cf1b4ba..8afb854 100644

Lines of this file are not shown. View the raw message.

hw/arm/spitz.c +1 -1
index fe2d5a7..7e9f579 100644

Lines of this file are not shown. View the raw message.

hw/arm/stellaris.c +1 -1
index ea7a809..cf6e7be 100644

Lines of this file are not shown. View the raw message.

hw/arm/tosa.c +1 -1
index 9f58a23..2421b81 100644

Lines of this file are not shown. View the raw message.

hw/i386/pc.c +1 -1
index f3b372a..427f123 100644

Lines of this file are not shown. View the raw message.

hw/i386/xen/xen-hvm.c +1 -1
index 3a6484c..70a1c1e 100644

Lines of this file are not shown. View the raw message.

hw/input/pckbd.c +2 -2
index d414288..c479f82 100644

Lines of this file are not shown. View the raw message.

hw/ipmi/ipmi.c +2 -2
index 5cf1caa..afafe14 100644

Lines of this file are not shown. View the raw message.

hw/isa/lpc_ich9.c +1 -1
index a0866c3..2b09354 100644

Lines of this file are not shown. View the raw message.

hw/mips/boston.c +1 -1
index 83f7b82..53d1e0c 100644

Lines of this file are not shown. View the raw message.

hw/mips/mips_malta.c +1 -1
index 5dd177e..7814c39 100644

Lines of this file are not shown. View the raw message.

hw/mips/mips_r4k.c +2 -2
index 748586e..f4de9fc 100644

Lines of this file are not shown. View the raw message.

hw/misc/arm_sysctl.c +4 -4
index 8524008..b20b44e 100644

Lines of this file are not shown. View the raw message.

hw/misc/cbus.c +1 -1
index 0c207e3..677274c 100644

Lines of this file are not shown. View the raw message.

hw/misc/macio/cuda.c +2 -2
index 05c02fb..008d8bd 100644

Lines of this file are not shown. View the raw message.

hw/misc/slavio_misc.c +2 -2
index edd5de0..18ff677 100644

Lines of this file are not shown. View the raw message.

hw/misc/zynq_slcr.c +1 -1
index 7891219..44304d4 100644

Lines of this file are not shown. View the raw message.

hw/pci-host/apb.c +2 -2
index 653e711..83fc6a9 100644

Lines of this file are not shown. View the raw message.

hw/pci-host/bonito.c +1 -1
index 1999ece..b1d41d0 100644

Lines of this file are not shown. View the raw message.

hw/pci-host/piix.c +1 -1
index f9218aa..c1d6a85 100644

Lines of this file are not shown. View the raw message.

hw/ppc/e500.c +1 -1
index f7df238..62f1857 100644

Lines of this file are not shown. View the raw message.

hw/ppc/mpc8544_guts.c +1 -1
index ba69178..ce1254b 100644

Lines of this file are not shown. View the raw message.

hw/ppc/ppc.c +1 -1
index 5f93083..224184d 100644

Lines of this file are not shown. View the raw message.

hw/ppc/ppc405_uc.c +1 -1
index d5df94a..fc32e96 100644

Lines of this file are not shown. View the raw message.

hw/ppc/spapr_hcall.c +1 -1
index 9f18f75..2735fe9 100644

Lines of this file are not shown. View the raw message.

hw/ppc/spapr_rtas.c +2 -2
index 619f32c..128d993 100644

Lines of this file are not shown. View the raw message.

hw/s390x/ipl.c +1 -1
index 7978c7d..e5ab0ad 100644

Lines of this file are not shown. View the raw message.

hw/sh4/r2d.c +1 -1
index 8f520ce..e6fc74e 100644

Lines of this file are not shown. View the raw message.

hw/timer/etraxfs_timer.c +1 -1
index 8e18236..d13bc30 100644

Lines of this file are not shown. View the raw message.

hw/timer/m48t59.c +2 -2
index 474981a..4a064fb 100644

Lines of this file are not shown. View the raw message.

hw/timer/milkymist-sysctl.c +2 -2
index 4488590..93bc6e17 100644

Lines of this file are not shown. View the raw message.

hw/timer/pxa2xx_timer.c +1 -1
index 59002b4..68ba5a7 100644

Lines of this file are not shown. View the raw message.

hw/watchdog/watchdog.c +1 -1
index 2aeaf1f..0c5c9cd 100644

Lines of this file are not shown. View the raw message.

hw/xenpv/xen_domainbuild.c +1 -1
index 457a897..c89ced2 100644

Lines of this file are not shown. View the raw message.

hw/xtensa/xtfpga.c +1 -1
index 11176e2..4636f8e 100644

Lines of this file are not shown. View the raw message.

kvm-all.c +3 -3
index 90b8573..7df27c8 100644

Lines of this file are not shown. View the raw message.

os-win32.c +1 -1
index ae98574..586a7c7 100644

Lines of this file are not shown. View the raw message.

qmp.c +2 -2
index ab74cd7..95949d0 100644

Lines of this file are not shown. View the raw message.

replay/replay.c +4 -1
index f810628..55e82d9 100644

Lines of this file are not shown. View the raw message.

target/alpha/sys_helper.c +2 -2
index 652195d..ac22323 100644

Lines of this file are not shown. View the raw message.

target/arm/psci.c +2 -2
index ade9fe2..fc34b26 100644

Lines of this file are not shown. View the raw message.

target/i386/excp_helper.c +1 -1
index ee596c6..b769772 100644

Lines of this file are not shown. View the raw message.

target/i386/hax-all.c +3 -3
index ef13015..7346931 100644

Lines of this file are not shown. View the raw message.

target/i386/helper.c +1 -1
index f11cac6..ee7eff2 100644

Lines of this file are not shown. View the raw message.

target/i386/kvm.c +1 -1
index 55865db..cfd7695 100644

Lines of this file are not shown. View the raw message.

target/s390x/helper.c +1 -1
index 68bd2f9..d2bb9aa 100644

Lines of this file are not shown. View the raw message.

target/s390x/kvm.c +2 -2
index 1a249d8..284f5ef 100644

Lines of this file are not shown. View the raw message.

target/s390x/misc_helper.c +2 -2
index eca8244..768043e 100644

Lines of this file are not shown. View the raw message.

target/sparc/int32_helper.c +1 -1
index 09afe13..eec9a4d 100644

Lines of this file are not shown. View the raw message.

ui/sdl.c +1 -1
index 37c21a0..bd51ffd 100644

Lines of this file are not shown. View the raw message.

ui/sdl2.c +2 -2
index faf9bdf..e092636 100644

Lines of this file are not shown. View the raw message.

bar new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..51c513d36451ab389b5b3e9bca9b478b84a2e2ce
GIT binary patch
bar.src new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ea4a9759cc90ef5ec3be3c46d34caf2287dc1eb3
GIT binary patch
file new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..68d7e673b1492242a9193c865c7141d30e005d95
GIT binary patch
file2 new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6c5d4031e03408e34ae476c5053ee497a91ac37b
GIT binary patch
file3 new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4b4af36f7811b30b888bbc3b36086b6bdd49094d
GIT binary patch
foo new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..dd4c0d22e454cffde46fef81fb846136ed83b3a0
GIT binary patch
tests/qemu-iotests/071.out +2 -2
index dd879f1..1d5e28d 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/081.out +1 -1
index 97df69d..2533c31 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/087.out +6 -6
index dc6baf9..59c5208 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/094.out +1 -1
index b66dc07..f52baff 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/117.out +1 -1
index f52dc1a..851e214 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/119.out +1 -1
index 58e7114..a8743b8 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/120.out +1 -1
index 9131b1b..1af1aeb 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/140.out +1 -1
index 6c04456..0689b2b 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/143.out +1 -1
index d24ad20..0978b89 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/156.out +1 -1
index 3af82ae..f96a564 100644

Lines of this file are not shown. View the raw message.

tests/test-hmp new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..5e9929dbc1ec3c50a9b2f78c58db899b7bc11f26
GIT binary patch
trace-events +1 -1
index e582d63..433865f 100644

Lines of this file are not shown. View the raw message.

ui/cocoa.m +1 -1
index 207555e..f89f686 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.9.3

Part of the diff is not shown here. View the raw message.

Eric Blake

author
#0 lore raw

v4 cover event: Add source information to SHUTDOWN

v2 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03185.html
v3 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg05515.html

Since then:
- s/ShutdownType/ShutdownCause/ to avoid conflict with mingw header pollution
- fix long line

Eric Blake (4):
shutdown: Simplify shutdown_signal
shutdown: Prepare for use of an enum in reset/shutdown_request
shutdown: Add source information to SHUTDOWN and RESET
RFC: shutdown: Expose full ShutdownCause across QMP

 qapi-schema.json            |    26 +
 qapi/event.json             |    12 +-
 include/sysemu/sysemu.h     |     6 +-
 trace/generated-tracers.h   | 18523 ++++++++++++++++++++++++++++++++++++++++++
 vl.c                        |    58 +-
 foo.c                       |   121 +
 hw/acpi/core.c              |     4 +-
 hw/arm/highbank.c           |     4 +-
 hw/arm/integratorcp.c       |     2 +-
 hw/arm/musicpal.c           |     2 +-
 hw/arm/omap1.c              |    10 +-
 hw/arm/omap2.c              |     2 +-
 hw/arm/spitz.c              |     2 +-
 hw/arm/stellaris.c          |     2 +-
 hw/arm/tosa.c               |     2 +-
 hw/i386/pc.c                |     2 +-
 hw/i386/xen/xen-hvm.c       |    11 +-
 hw/input/pckbd.c            |     4 +-
 hw/ipmi/ipmi.c              |     4 +-
 hw/isa/lpc_ich9.c           |     2 +-
 hw/mips/boston.c            |     2 +-
 hw/mips/mips_malta.c        |     2 +-
 hw/mips/mips_r4k.c          |     4 +-
 hw/misc/arm_sysctl.c        |     8 +-
 hw/misc/cbus.c              |     2 +-
 hw/misc/macio/cuda.c        |     4 +-
 hw/misc/slavio_misc.c       |     4 +-
 hw/misc/zynq_slcr.c         |     2 +-
 hw/pci-host/apb.c           |     4 +-
 hw/pci-host/bonito.c        |     2 +-
 hw/pci-host/piix.c          |     2 +-
 hw/ppc/e500.c               |     2 +-
 hw/ppc/mpc8544_guts.c       |     2 +-
 hw/ppc/ppc.c                |     2 +-
 hw/ppc/ppc405_uc.c          |     2 +-
 hw/ppc/spapr_hcall.c        |     2 +-
 hw/ppc/spapr_rtas.c         |     4 +-
 hw/s390x/ipl.c              |     2 +-
 hw/sh4/r2d.c                |     2 +-
 hw/timer/etraxfs_timer.c    |     2 +-
 hw/timer/m48t59.c           |     4 +-
 hw/timer/milkymist-sysctl.c |     4 +-
 hw/timer/pxa2xx_timer.c     |     2 +-
 hw/watchdog/watchdog.c      |     2 +-
 hw/xenpv/xen_domainbuild.c  |     2 +-
 hw/xtensa/xtfpga.c          |     2 +-
 kvm-all.c                   |     6 +-
 migration/colo.c            |     2 +-
 migration/savevm.c          |     2 +-
 os-win32.c                  |     2 +-
 qmp.c                       |     4 +-
 replay/replay.c             |     5 +-
 target/alpha/sys_helper.c   |     4 +-
 target/arm/psci.c           |     4 +-
 target/i386/excp_helper.c   |     2 +-
 target/i386/hax-all.c       |     6 +-
 target/i386/helper.c        |     2 +-
 target/i386/kvm.c           |     2 +-
 target/s390x/helper.c       |     2 +-
 target/s390x/kvm.c          |     4 +-
 target/s390x/misc_helper.c  |     4 +-
 target/sparc/int32_helper.c |     2 +-
 ui/sdl.c                    |     2 +-
 ui/sdl2.c                   |     4 +-
 bar                         |   Bin 0 -> 67108864 bytes
 bar.src                     |   Bin 0 -> 560 bytes
 file                        |   Bin 0 -> 1900544 bytes
 file2                       |   Bin 0 -> 10485760 bytes
 file3                       |   Bin 0 -> 15728640 bytes
 foo                         |   Bin 0 -> 13344 bytes
 tests/qemu-iotests/071.out  |     4 +-
 tests/qemu-iotests/081.out  |     2 +-
 tests/qemu-iotests/087.out  |    12 +-
 tests/qemu-iotests/094.out  |     2 +-
 tests/qemu-iotests/117.out  |     2 +-
 tests/qemu-iotests/119.out  |     2 +-
 tests/qemu-iotests/120.out  |     2 +-
 tests/qemu-iotests/140.out  |     2 +-
 tests/qemu-iotests/143.out  |     2 +-
 tests/qemu-iotests/156.out  |     2 +-
 tests/test-hmp              |   Bin 0 -> 603288 bytes
 trace-events                |     2 +-
 ui/cocoa.m                  |     2 +-
 83 files changed, 18829 insertions(+), 137 deletions(-)
 create mode 100644 trace/generated-tracers.h
 create mode 100644 foo.c
 create mode 100644 bar
 create mode 100644 bar.src
 create mode 100644 file
 create mode 100644 file2
 create mode 100644 file3
 create mode 100755 foo
 create mode 100755 tests/test-hmp
Signature · 1 line
2.9.3
author
#1 lore raw

PATCH v4 1/4 shutdown: Simplify shutdown_signal

There is no signal 0 (kill(pid, 0) has special semantics to probe whether a process is alive), rather than actually sending a signal 0). So we can use the simpler 0, instead of -1, for our sentinel of whether a shutdown request due to a signal has happened.

---
v3: new patch

---
 vl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
vl.c +3 -3
index f46e070..879786a 100644
@@ -1598,7 +1598,7 @@ void vm_state_notify(int running, RunState state)
 }
 
 static int reset_requested;
-static int shutdown_requested, shutdown_signal = -1;
+static int shutdown_requested, shutdown_signal;
 static pid_t shutdown_pid;
 static int powerdown_requested;
 static int debug_requested;
@@ -1629,7 +1629,7 @@ static int qemu_shutdown_requested(void)
 
 static void qemu_kill_report(void)
 {
-    if (!qtest_driver() && shutdown_signal != -1) {
+    if (!qtest_driver() && shutdown_signal) {
         if (shutdown_pid == 0) {
             /* This happens for eg ^C at the terminal, so it's worth
              * avoiding printing an odd message in that case.
@@ -1643,7 +1643,7 @@ static void qemu_kill_report(void)
                          shutdown_cmd ? shutdown_cmd : "<unknown process>");
             g_free(shutdown_cmd);
         }
-        shutdown_signal = -1;
+        shutdown_signal = 0;
     }
 }
 
Signature · 1 line
2.9.3
author
#2 lore raw

PATCH v4 2/4 shutdown: Prepare for use of an enum in reset/shutdown_request

In reply to Eric Blake

We want to track why a guest was shutdown; in particular, being able to tell the difference between a guest request (such as ACPI request) and host request (such as SIGINT) will prove useful to libvirt. Since all requests eventually end up changing shutdown_requested in vl.c, the logical change is to make that value track the reason, rather than its current 0/1 contents.

Since command-line options control whether a reset request is turned into a shutdown request instead, the same treatment is given to reset_requested.

This patch adds a QAPI enum ShutdownCause that describes reasons that a shutdown can be requested, and changes qemu_system_reset() to pass the reason through, although for now it is not reported. The next patch will actually wire things up to modify events to report data based on the reason, and to pass the correct enum value in from various call-sites that can trigger a reset/shutdown. Since QAPI generates enums starting at 0, it's easier if we use a different number as our sentinel that no request has happened yet. Most of the changes are in vl.c, but xen was using things externally.

---
v4: s/ShutdownType/ShutdownCause/, no thanks to mingw header pollution
v3: new patch

---
 qapi-schema.json        | 23 +++++++++++++++++++++++
 include/sysemu/sysemu.h |  2 +-
 vl.c                    | 44 ++++++++++++++++++++++++++++----------------
 hw/i386/xen/xen-hvm.c   |  9 ++++++---
 migration/colo.c        |  2 +-
 migration/savevm.c      |  2 +-
 6 files changed, 60 insertions(+), 22 deletions(-)
qapi-schema.json +23 -0
index 01b087f..a4ebdd1 100644
@@ -2304,6 +2304,29 @@
 { 'command': 'system_powerdown' }
 
 ##
+# @ShutdownCause:
+#
+# Enumeration of various causes for shutdown.
+#
+# @host-qmp: Reaction to a QMP command, such as 'quit'
+# @host-signal: Reaction to a signal, such as SIGINT
+# @host-ui: Reaction to a UI event, such as closing the window
+# @host-replay: The host is replaying an earlier shutdown event
+# @host-error: Qemu encountered an error that prevents further use of the guest
+# @guest-shutdown: The guest requested a shutdown, such as via ACPI or
+#                  other hardware-specific action
+# @guest-reset: The guest requested a reset, and the command line
+#               response to a reset is to instead trigger a shutdown
+# @guest-panic: The guest panicked, and the command line response to
+#               a panic is to trigger a shutdown
+#
+# Since: 2.10
+##
+{ 'enum': 'ShutdownCause',
+  'data': [ 'host-qmp', 'host-signal', 'host-ui', 'host-replay', 'host-error',
+            'guest-shutdown', 'guest-reset', 'guest-panic' ] }
+
+##
 # @cpu:
 #
 # This command is a nop that is only provided for the purposes of compatibility.
include/sysemu/sysemu.h +1 -1
index 16175f7..00a907f 100644
@@ -65,7 +65,7 @@ bool qemu_vmstop_requested(RunState *r);
 int qemu_shutdown_requested_get(void);
 int qemu_reset_requested_get(void);
 void qemu_system_killed(int signal, pid_t pid);
-void qemu_system_reset(bool report);
+void qemu_system_reset(bool report, int reason);
 void qemu_system_guest_panicked(GuestPanicInformation *info);
 size_t qemu_target_page_size(void);
 
vl.c +28 -16

126 lines not on this page · raw message

hw/i386/xen/xen-hvm.c +6 -3
index b1c05ff..3a6484c 100644
@@ -1089,11 +1089,14 @@ static void cpu_handle_ioreq(void *opaque)
          * causes Xen to powerdown the domain.
          */
         if (runstate_is_running()) {
-            if (qemu_shutdown_requested_get()) {
+            int request;
+
+            if (qemu_shutdown_requested_get() >= 0) {
                 destroy_hvm_domain(false);
             }
-            if (qemu_reset_requested_get()) {
-                qemu_system_reset(VMRESET_REPORT);
+            request = qemu_reset_requested_get();
+            if (request >= 0) {
+                qemu_system_reset(VMRESET_REPORT, request);
                 destroy_hvm_domain(true);
             }
         }
migration/colo.c +1 -1
index c19eb3f..17a5482 100644
@@ -611,7 +611,7 @@ void *colo_process_incoming_thread(void *opaque)
         }
 
         qemu_mutex_lock_iothread();
-        qemu_system_reset(VMRESET_SILENT);
+        qemu_system_reset(VMRESET_SILENT, -1);
         vmstate_loading = true;
         if (qemu_loadvm_state(fb) < 0) {
             error_report("COLO: loadvm failed");
migration/savevm.c +1 -1
index 03ae1bd..dcbaf00 100644
@@ -2292,7 +2292,7 @@ int load_vmstate(const char *name)
         return -EINVAL;
     }
 
-    qemu_system_reset(VMRESET_SILENT);
+    qemu_system_reset(VMRESET_SILENT, -1);
     mis->from_src_file = f;
 
     aio_context_acquire(aio_context);
Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#4 lore raw

PATCH v4 3/4 shutdown: Add source information to SHUTDOWN and RESET

In reply to Eric Blake

Libvirt would like to be able to distinguish between a SHUTDOWN event triggered solely by guest request and one triggered by a SIGTERM or other action on the host. While qemu_kill_report() is already able to tell whether a shutdown was triggered by a host signal (but NOT by a host UI event, such as clicking the X on the window), that information was then lost after being printed to stderr. The previous patch prepped things to use an enum internally; now it's time to wire it up through all callers, and to extend the SHUTDOWN and RESET events to report the details.

Enhance the shutdown request path to take a parameter of which way it is being triggered, and update ALL callers. It would have been less churn to keep the common case with no arguments as meaning guest-triggered, and only modified the host-triggered code paths, via a wrapper function, but then we'd still have to audit that I didn't miss any host-triggered spots; changing the signature forces us to double-check that I correctly categorized all callers.

Since command line options can change whether a guest reset request causes an actual reset vs. a shutdown, it's easy to also add the information to the RESET event, even though libvirt has not yet expressed a need to know that.

For the moment, we keep the enum ShutdownCause for internal use only, and merely expose a single boolean of 'guest':true|false to the QMP client; this is because we don't yet have evidence that the further distinctions will be useful, or whether the addition of new enum members would cause problems to clients coded to an older version of the enum.

Update expected iotest outputs to match the new data.

Here is output from 'virsh qemu-monitor-event --loop' with the patch installed:

event SHUTDOWN at 1492639680.731251 for domain fedora_13: {"guest":true} event STOP at 1492639680.732116 for domain fedora_13: <null> event SHUTDOWN at 1492639680.732830 for domain fedora_13: {"guest":false}

Note that libvirt runs qemu with -no-quit: the first SHUTDOWN event was triggered by an action I took directly in the guest (shutdown -h), at which point qemu stops the vcpus and waits for libvirt to do any final cleanups; the second SHUTDOWN event is the result of libvirt sending SIGTERM now that it has completed cleanup.

The replay driver needs a followup patch if we want to be able to faithfully replay the difference between a host- and guest-initiated shutdown (for now, the replayed event is always attributed to host).

See also https://bugzilla.redhat.com/1384007

---
v4: s/ShutdownType/ShutdownCause/, no thanks to mingw header pollution
v3: retitle again, fix qemu-iotests, use enum rather than raw bool in all callers
v2: retitle (was "event: Add signal information to SHUTDOWN"), completely rework to post bool based on whether it is guest-initiated
v1: initial submission, exposing just Unix signals from host

---
 qapi/event.json             |    17 +-
 include/sysemu/sysemu.h     |     4 +-
 trace/generated-tracers.h   | 18523 ++++++++++++++++++++++++++++++++++++++++++
 vl.c                        |    22 +-
 foo.c                       |   121 +
 hw/acpi/core.c              |     4 +-
 hw/arm/highbank.c           |     4 +-
 hw/arm/integratorcp.c       |     2 +-
 hw/arm/musicpal.c           |     2 +-
 hw/arm/omap1.c              |    10 +-
 hw/arm/omap2.c              |     2 +-
 hw/arm/spitz.c              |     2 +-
 hw/arm/stellaris.c          |     2 +-
 hw/arm/tosa.c               |     2 +-
 hw/i386/pc.c                |     2 +-
 hw/i386/xen/xen-hvm.c       |     2 +-
 hw/input/pckbd.c            |     4 +-
 hw/ipmi/ipmi.c              |     4 +-
 hw/isa/lpc_ich9.c           |     2 +-
 hw/mips/boston.c            |     2 +-
 hw/mips/mips_malta.c        |     2 +-
 hw/mips/mips_r4k.c          |     4 +-
 hw/misc/arm_sysctl.c        |     8 +-
 hw/misc/cbus.c              |     2 +-
 hw/misc/macio/cuda.c        |     4 +-
 hw/misc/slavio_misc.c       |     4 +-
 hw/misc/zynq_slcr.c         |     2 +-
 hw/pci-host/apb.c           |     4 +-
 hw/pci-host/bonito.c        |     2 +-
 hw/pci-host/piix.c          |     2 +-
 hw/ppc/e500.c               |     2 +-
 hw/ppc/mpc8544_guts.c       |     2 +-
 hw/ppc/ppc.c                |     2 +-
 hw/ppc/ppc405_uc.c          |     2 +-
 hw/ppc/spapr_hcall.c        |     2 +-
 hw/ppc/spapr_rtas.c         |     4 +-
 hw/s390x/ipl.c              |     2 +-
 hw/sh4/r2d.c                |     2 +-
 hw/timer/etraxfs_timer.c    |     2 +-
 hw/timer/m48t59.c           |     4 +-
 hw/timer/milkymist-sysctl.c |     4 +-
 hw/timer/pxa2xx_timer.c     |     2 +-
 hw/watchdog/watchdog.c      |     2 +-
 hw/xenpv/xen_domainbuild.c  |     2 +-
 hw/xtensa/xtfpga.c          |     2 +-
 kvm-all.c                   |     6 +-
 os-win32.c                  |     2 +-
 qmp.c                       |     4 +-
 replay/replay.c             |     5 +-
 target/alpha/sys_helper.c   |     4 +-
 target/arm/psci.c           |     4 +-
 target/i386/excp_helper.c   |     2 +-
 target/i386/hax-all.c       |     6 +-
 target/i386/helper.c        |     2 +-
 target/i386/kvm.c           |     2 +-
 target/s390x/helper.c       |     2 +-
 target/s390x/kvm.c          |     4 +-
 target/s390x/misc_helper.c  |     4 +-
 target/sparc/int32_helper.c |     2 +-
 ui/sdl.c                    |     2 +-
 ui/sdl2.c                   |     4 +-
 bar                         |   Bin 0 -> 67108864 bytes
 bar.src                     |   Bin 0 -> 560 bytes
 file                        |   Bin 0 -> 1900544 bytes
 file2                       |   Bin 0 -> 10485760 bytes
 file3                       |   Bin 0 -> 15728640 bytes
 foo                         |   Bin 0 -> 13344 bytes
 tests/qemu-iotests/071.out  |     4 +-
 tests/qemu-iotests/081.out  |     2 +-
 tests/qemu-iotests/087.out  |    12 +-
 tests/qemu-iotests/094.out  |     2 +-
 tests/qemu-iotests/117.out  |     2 +-
 tests/qemu-iotests/119.out  |     2 +-
 tests/qemu-iotests/120.out  |     2 +-
 tests/qemu-iotests/140.out  |     2 +-
 tests/qemu-iotests/143.out  |     2 +-
 tests/qemu-iotests/156.out  |     2 +-
 tests/test-hmp              |   Bin 0 -> 603288 bytes
 trace-events                |     2 +-
 ui/cocoa.m                  |     2 +-
 80 files changed, 18776 insertions(+), 118 deletions(-)
 create mode 100644 trace/generated-tracers.h
 create mode 100644 foo.c
 create mode 100644 bar
 create mode 100644 bar.src
 create mode 100644 file
 create mode 100644 file2
 create mode 100644 file3
 create mode 100755 foo
 create mode 100755 tests/test-hmp
qapi/event.json +13 -4
index e80f3f4..6d22b02 100644
@@ -10,6 +10,10 @@
 # Emitted when the virtual machine has shut down, indicating that qemu is
 # about to exit.
 #
+# @guest: If true, the shutdown was triggered by a guest request (such as
+# a guest-initiated ACPI shutdown request or other hardware-specific action)
+# rather than a host request (such as sending qemu a SIGINT). (since 2.10)
+#
 # Note: If the command-line option "-no-shutdown" has been specified, qemu will
 # not exit, and a STOP event will eventually follow the SHUTDOWN event
 #
@@ -17,11 +21,11 @@
 #
 # Example:
 #
-# <- { "event": "SHUTDOWN",
+# <- { "event": "SHUTDOWN", "data": { "guest": true },
 #      "timestamp": { "seconds": 1267040730, "microseconds": 682951 } }
 #
 ##
-{ 'event': 'SHUTDOWN' }
+{ 'event': 'SHUTDOWN', 'data': { 'guest': 'bool' } }
 
 ##
 # @POWERDOWN:
@@ -44,15 +48,20 @@
 #
 # Emitted when the virtual machine is reset
 #
+# @guest: If true, the reset was triggered by a guest request (such as
+# a guest-initiated ACPI reboot request or other hardware-specific action)
+# rather than a host request (such as the QMP command system_reset).
+# (since 2.10)
+#
 # Since: 0.12.0
 #
 # Example:
 #
-# <- { "event": "RESET",
+# <- { "event": "RESET", "data": { "guest": false },
 #      "timestamp": { "seconds": 1267041653, "microseconds": 9518 } }
 #
 ##
-{ 'event': 'RESET' }
+{ 'event': 'RESET', 'data': { 'guest': 'bool' } }
 
 ##
 # @STOP:
include/sysemu/sysemu.h +2 -2
index 00a907f..ffbf9ac 100644
@@ -49,13 +49,13 @@ typedef enum WakeupReason {
     QEMU_WAKEUP_REASON_OTHER,
 } WakeupReason;
 
-void qemu_system_reset_request(void);
+void qemu_system_reset_request(ShutdownCause reason);
 void qemu_system_suspend_request(void);
 void qemu_register_suspend_notifier(Notifier *notifier);
 void qemu_system_wakeup_request(WakeupReason reason);
 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
 void qemu_register_wakeup_notifier(Notifier *notifier);
-void qemu_system_shutdown_request(void);
+void qemu_system_shutdown_request(ShutdownCause reason);
 void qemu_system_powerdown_request(void);
 void qemu_register_powerdown_notifier(Notifier *notifier);
 void qemu_system_debug_request(void);
trace/generated-tracers.h new file +18523 -0

2,940 lines not on this page · raw message

vl.c +11 -11
index 2b95b7f..0a933ba 100644

Lines of this file are not shown. View the raw message.

foo.c new file +121 -0

121 lines not on this page · raw message

hw/acpi/core.c +2 -2
index e890a5d..95fcac9 100644

Lines of this file are not shown. View the raw message.

hw/arm/highbank.c +2 -2
index 0a4508c..d209b97 100644

Lines of this file are not shown. View the raw message.

hw/arm/integratorcp.c +1 -1
index 5610ffc..ca3eca1 100644

Lines of this file are not shown. View the raw message.

hw/arm/musicpal.c +1 -1
index cbbca4e..9c710f7 100644

Lines of this file are not shown. View the raw message.

hw/arm/omap1.c +6 -4
index b3cf0ec..54582bd 100644

Lines of this file are not shown. View the raw message.

hw/arm/omap2.c +1 -1
index cf1b4ba..8afb854 100644

Lines of this file are not shown. View the raw message.

hw/arm/spitz.c +1 -1
index fe2d5a7..7e9f579 100644

Lines of this file are not shown. View the raw message.

hw/arm/stellaris.c +1 -1
index ea7a809..cf6e7be 100644

Lines of this file are not shown. View the raw message.

hw/arm/tosa.c +1 -1
index 9f58a23..2421b81 100644

Lines of this file are not shown. View the raw message.

hw/i386/pc.c +1 -1
index f3b372a..427f123 100644

Lines of this file are not shown. View the raw message.

hw/i386/xen/xen-hvm.c +1 -1
index 3a6484c..70a1c1e 100644

Lines of this file are not shown. View the raw message.

hw/input/pckbd.c +2 -2
index d414288..c479f82 100644

Lines of this file are not shown. View the raw message.

hw/ipmi/ipmi.c +2 -2
index 5cf1caa..afafe14 100644

Lines of this file are not shown. View the raw message.

hw/isa/lpc_ich9.c +1 -1
index a0866c3..2b09354 100644

Lines of this file are not shown. View the raw message.

hw/mips/boston.c +1 -1
index 83f7b82..53d1e0c 100644

Lines of this file are not shown. View the raw message.

hw/mips/mips_malta.c +1 -1
index 5dd177e..7814c39 100644

Lines of this file are not shown. View the raw message.

hw/mips/mips_r4k.c +2 -2
index 748586e..f4de9fc 100644

Lines of this file are not shown. View the raw message.

hw/misc/arm_sysctl.c +4 -4
index 8524008..b20b44e 100644

Lines of this file are not shown. View the raw message.

hw/misc/cbus.c +1 -1
index 0c207e3..677274c 100644

Lines of this file are not shown. View the raw message.

hw/misc/macio/cuda.c +2 -2
index 05c02fb..008d8bd 100644

Lines of this file are not shown. View the raw message.

hw/misc/slavio_misc.c +2 -2
index edd5de0..18ff677 100644

Lines of this file are not shown. View the raw message.

hw/misc/zynq_slcr.c +1 -1
index 7891219..44304d4 100644

Lines of this file are not shown. View the raw message.

hw/pci-host/apb.c +2 -2
index 653e711..83fc6a9 100644

Lines of this file are not shown. View the raw message.

hw/pci-host/bonito.c +1 -1
index 1999ece..b1d41d0 100644

Lines of this file are not shown. View the raw message.

hw/pci-host/piix.c +1 -1
index f9218aa..c1d6a85 100644

Lines of this file are not shown. View the raw message.

hw/ppc/e500.c +1 -1
index f7df238..62f1857 100644

Lines of this file are not shown. View the raw message.

hw/ppc/mpc8544_guts.c +1 -1
index ba69178..ce1254b 100644

Lines of this file are not shown. View the raw message.

hw/ppc/ppc.c +1 -1
index 5f93083..224184d 100644

Lines of this file are not shown. View the raw message.

hw/ppc/ppc405_uc.c +1 -1
index d5df94a..fc32e96 100644

Lines of this file are not shown. View the raw message.

hw/ppc/spapr_hcall.c +1 -1
index 9f18f75..2735fe9 100644

Lines of this file are not shown. View the raw message.

hw/ppc/spapr_rtas.c +2 -2
index 619f32c..128d993 100644

Lines of this file are not shown. View the raw message.

hw/s390x/ipl.c +1 -1
index 7978c7d..e5ab0ad 100644

Lines of this file are not shown. View the raw message.

hw/sh4/r2d.c +1 -1
index 8f520ce..e6fc74e 100644

Lines of this file are not shown. View the raw message.

hw/timer/etraxfs_timer.c +1 -1
index 8e18236..d13bc30 100644

Lines of this file are not shown. View the raw message.

hw/timer/m48t59.c +2 -2
index 474981a..4a064fb 100644

Lines of this file are not shown. View the raw message.

hw/timer/milkymist-sysctl.c +2 -2
index 4488590..93bc6e17 100644

Lines of this file are not shown. View the raw message.

hw/timer/pxa2xx_timer.c +1 -1
index 59002b4..68ba5a7 100644

Lines of this file are not shown. View the raw message.

hw/watchdog/watchdog.c +1 -1
index 2aeaf1f..0c5c9cd 100644

Lines of this file are not shown. View the raw message.

hw/xenpv/xen_domainbuild.c +1 -1
index 457a897..c89ced2 100644

Lines of this file are not shown. View the raw message.

hw/xtensa/xtfpga.c +1 -1
index 11176e2..4636f8e 100644

Lines of this file are not shown. View the raw message.

kvm-all.c +3 -3
index 90b8573..7df27c8 100644

Lines of this file are not shown. View the raw message.

os-win32.c +1 -1
index ae98574..586a7c7 100644

Lines of this file are not shown. View the raw message.

qmp.c +2 -2
index ab74cd7..95949d0 100644

Lines of this file are not shown. View the raw message.

replay/replay.c +4 -1
index f810628..55e82d9 100644

Lines of this file are not shown. View the raw message.

target/alpha/sys_helper.c +2 -2
index 652195d..ac22323 100644

Lines of this file are not shown. View the raw message.

target/arm/psci.c +2 -2
index ade9fe2..fc34b26 100644

Lines of this file are not shown. View the raw message.

target/i386/excp_helper.c +1 -1
index ee596c6..b769772 100644

Lines of this file are not shown. View the raw message.

target/i386/hax-all.c +3 -3
index ef13015..7346931 100644

Lines of this file are not shown. View the raw message.

target/i386/helper.c +1 -1
index f11cac6..ee7eff2 100644

Lines of this file are not shown. View the raw message.

target/i386/kvm.c +1 -1
index 55865db..cfd7695 100644

Lines of this file are not shown. View the raw message.

target/s390x/helper.c +1 -1
index 68bd2f9..d2bb9aa 100644

Lines of this file are not shown. View the raw message.

target/s390x/kvm.c +2 -2
index 1a249d8..284f5ef 100644

Lines of this file are not shown. View the raw message.

target/s390x/misc_helper.c +2 -2
index eca8244..768043e 100644

Lines of this file are not shown. View the raw message.

target/sparc/int32_helper.c +1 -1
index 09afe13..eec9a4d 100644

Lines of this file are not shown. View the raw message.

ui/sdl.c +1 -1
index 37c21a0..bd51ffd 100644

Lines of this file are not shown. View the raw message.

ui/sdl2.c +2 -2
index faf9bdf..e092636 100644

Lines of this file are not shown. View the raw message.

bar new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..51c513d36451ab389b5b3e9bca9b478b84a2e2ce
GIT binary patch
bar.src new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ea4a9759cc90ef5ec3be3c46d34caf2287dc1eb3
GIT binary patch
file new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..68d7e673b1492242a9193c865c7141d30e005d95
GIT binary patch
file2 new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6c5d4031e03408e34ae476c5053ee497a91ac37b
GIT binary patch
file3 new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4b4af36f7811b30b888bbc3b36086b6bdd49094d
GIT binary patch
foo new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..dd4c0d22e454cffde46fef81fb846136ed83b3a0
GIT binary patch
tests/qemu-iotests/071.out +2 -2
index dd879f1..1d5e28d 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/081.out +1 -1
index 97df69d..2533c31 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/087.out +6 -6
index dc6baf9..59c5208 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/094.out +1 -1
index b66dc07..f52baff 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/117.out +1 -1
index f52dc1a..851e214 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/119.out +1 -1
index 58e7114..a8743b8 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/120.out +1 -1
index 9131b1b..1af1aeb 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/140.out +1 -1
index 6c04456..0689b2b 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/143.out +1 -1
index d24ad20..0978b89 100644

Lines of this file are not shown. View the raw message.

tests/qemu-iotests/156.out +1 -1
index 3af82ae..f96a564 100644

Lines of this file are not shown. View the raw message.

tests/test-hmp new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..5e9929dbc1ec3c50a9b2f78c58db899b7bc11f26
GIT binary patch
trace-events +1 -1
index e582d63..433865f 100644

Lines of this file are not shown. View the raw message.

ui/cocoa.m +1 -1
index 207555e..f89f686 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Part of the diff is not shown here. View the raw message.

author
#5 lore raw

PATCH v4 4/4 RFC: shutdown: Expose full ShutdownCause across QMP

In reply to Eric Blake

Since all reset/shutdown requests have been associated with a reason, we can expose the full reason rather than a simple bool to the guest. Document that any future additions to the enum type will still use a 'host-' or 'guest-' prefix.

---
v4: s/ShutdownType/ShutdownCause/, no thanks to mingw header pollution
v3: new patch. If we like this approach better than just the 'guest':'bool' of the previous, then I will squash the two patches together and tweak the commit message for a v4 posting.

---
 qapi-schema.json           |  5 ++++-
 qapi/event.json            | 17 ++++++-----------
 vl.c                       |  6 ++----
 tests/qemu-iotests/071.out |  4 ++--
 tests/qemu-iotests/081.out |  2 +-
 tests/qemu-iotests/087.out | 12 ++++++------
 tests/qemu-iotests/094.out |  2 +-
 tests/qemu-iotests/117.out |  2 +-
 tests/qemu-iotests/119.out |  2 +-
 tests/qemu-iotests/120.out |  2 +-
 tests/qemu-iotests/140.out |  2 +-
 tests/qemu-iotests/143.out |  2 +-
 tests/qemu-iotests/156.out |  2 +-
 13 files changed, 28 insertions(+), 32 deletions(-)
qapi-schema.json +4 -1
index a4ebdd1..f699f04 100644
@@ -2306,7 +2306,10 @@
 ##
 # @ShutdownCause:
 #
-# Enumeration of various causes for shutdown.
+# Enumeration of various causes for shutdown, used in SHUTDOWN and RESET
+# events.  It is anticipated that if any new reasons are added, the prefix
+# will still make it possible to distinguish whether it was the guest or
+# the host that requested the change in state.
 #
 # @host-qmp: Reaction to a QMP command, such as 'quit'
 # @host-signal: Reaction to a signal, such as SIGINT
qapi/event.json +6 -11
index 6d22b02..48648ac 100644
@@ -10,9 +10,7 @@
 # Emitted when the virtual machine has shut down, indicating that qemu is
 # about to exit.
 #
-# @guest: If true, the shutdown was triggered by a guest request (such as
-# a guest-initiated ACPI shutdown request or other hardware-specific action)
-# rather than a host request (such as sending qemu a SIGINT). (since 2.10)
+# @reason: What triggered the reset. (since 2.10)
 #
 # Note: If the command-line option "-no-shutdown" has been specified, qemu will
 # not exit, and a STOP event will eventually follow the SHUTDOWN event
@@ -21,11 +19,11 @@
 #
 # Example:
 #
-# <- { "event": "SHUTDOWN", "data": { "guest": true },
+# <- { "event": "SHUTDOWN", "data": { "reason": "guest-shutdown" },
 #      "timestamp": { "seconds": 1267040730, "microseconds": 682951 } }
 #
 ##
-{ 'event': 'SHUTDOWN', 'data': { 'guest': 'bool' } }
+{ 'event': 'SHUTDOWN', 'data': { 'reason': 'ShutdownCause' } }
 
 ##
 # @POWERDOWN:
@@ -48,20 +46,17 @@
 #
 # Emitted when the virtual machine is reset
 #
-# @guest: If true, the reset was triggered by a guest request (such as
-# a guest-initiated ACPI reboot request or other hardware-specific action)
-# rather than a host request (such as the QMP command system_reset).
-# (since 2.10)
+# @reason: What triggered the reset. (since 2.10)
 #
 # Since: 0.12.0
 #
 # Example:
 #
-# <- { "event": "RESET", "data": { "guest": false },
+# <- { "event": "RESET", "data": { "reason": "host-qmp" },
 #      "timestamp": { "seconds": 1267041653, "microseconds": 9518 } }
 #
 ##
-{ 'event': 'RESET', 'data': { 'guest': 'bool' } }
+{ 'event': 'RESET', 'data': { 'reason': 'ShutdownCause' } }
 
 ##
 # @STOP:
vl.c +2 -4
index 0a933ba..e226a59 100644
@@ -1706,8 +1706,7 @@ void qemu_system_reset(bool report, int reason)
     }
     if (report) {
         assert(reason >= 0);
-        qapi_event_send_reset(reason >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN,
-                              &error_abort);
+        qapi_event_send_reset(reason, &error_abort);
     }
     cpu_synchronize_all_post_reset();
 }
@@ -1864,8 +1863,7 @@ static bool main_loop_should_exit(void)
     request = qemu_shutdown_requested();
     if (request >= 0) {
         qemu_kill_report();
-        qapi_event_send_shutdown(request >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN,
-                                 &error_abort);
+        qapi_event_send_shutdown(request, &error_abort);
         if (no_shutdown) {
             vm_stop(RUN_STATE_SHUTDOWN);
         } else {
tests/qemu-iotests/071.out +2 -2
index 1d5e28d..aa6edc2 100644
@@ -46,7 +46,7 @@ QMP_VERSION
 read failed: Input/output error
 {"return": ""}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 
 === Testing blkverify on existing block device ===
@@ -85,7 +85,7 @@ wrote 512/512 bytes at offset 0
 read failed: Input/output error
 {"return": ""}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 QEMU_PROG: Failed to flush the L2 table cache: Input/output error
 QEMU_PROG: Failed to flush the refcount block cache: Input/output error
 
tests/qemu-iotests/081.out +1 -1
index 2533c31..ed79421 100644
@@ -36,7 +36,7 @@ read 10485760/10485760 bytes at offset 0
 10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 {"return": ""}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 
 == using quorum rewrite corrupted mode ==
tests/qemu-iotests/087.out +6 -6
index 59c5208..a494659 100644
@@ -8,7 +8,7 @@ QMP_VERSION
 {"return": {}}
 {"error": {"class": "GenericError", "desc": "'node-name' must be specified for the root node"}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 
 === Duplicate ID ===
@@ -19,7 +19,7 @@ QMP_VERSION
 {"error": {"class": "GenericError", "desc": "node-name=disk is conflicting with a device id"}}
 {"error": {"class": "GenericError", "desc": "Duplicate node name"}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 
 === aio=native without O_DIRECT ===
@@ -29,7 +29,7 @@ QMP_VERSION
 {"return": {}}
 {"error": {"class": "GenericError", "desc": "aio=native was specified, but it requires cache.direct=on, which was not specified."}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 
 === Encrypted image ===
@@ -40,14 +40,14 @@ QMP_VERSION
 {"return": {}}
 {"error": {"class": "GenericError", "desc": "Use of AES-CBC encrypted IMGFMT images is no longer supported in system emulators"}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 Testing:
 QMP_VERSION
 {"return": {}}
 {"error": {"class": "GenericError", "desc": "Use of AES-CBC encrypted IMGFMT images is no longer supported in system emulators"}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 
 === Missing driver ===
@@ -58,6 +58,6 @@ QMP_VERSION
 {"return": {}}
 {"error": {"class": "GenericError", "desc": "Parameter 'driver' is missing"}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 *** done
tests/qemu-iotests/094.out +1 -1
index f52baff..6059f20 100644
@@ -7,5 +7,5 @@ Formatting 'TEST_DIR/source.IMGFMT', fmt=IMGFMT size=67108864
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 67108864, "offset": 67108864, "speed": 0, "type": "mirror"}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 *** done
tests/qemu-iotests/117.out +1 -1
index 851e214..d325f64 100644
@@ -7,7 +7,7 @@ wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 {"return": ""}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 No errors were found on the image.
 read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
tests/qemu-iotests/119.out +1 -1
index a8743b8..80d2750 100644
@@ -6,6 +6,6 @@ read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 {"return": ""}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 *** done
tests/qemu-iotests/120.out +1 -1
index 1af1aeb..fe717f0 100644
@@ -6,7 +6,7 @@ wrote 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 {"return": ""}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 65536/65536 bytes at offset 0
tests/qemu-iotests/140.out +1 -1
index 0689b2b..2da1c0a 100644
@@ -10,5 +10,5 @@ read 65536/65536 bytes at offset 0
 {"return": {}}
 can't open device nbd+unix:///drv?socket=TEST_DIR/nbd: No export with name 'drv' available
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 *** done
tests/qemu-iotests/143.out +1 -1
index 0978b89..efec8a0 100644
@@ -3,5 +3,5 @@ QA output created by 143
 {"return": {}}
 can't open device nbd+unix:///no_such_export?socket=TEST_DIR/nbd: No export with name 'no_such_export' available
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 *** done
tests/qemu-iotests/156.out +1 -1
index f96a564..cfa7665 100644
@@ -34,7 +34,7 @@ read 65536/65536 bytes at offset 196608
 {"return": ""}
 
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"reason": "host-qmp"}}
 
 read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
Signature · 1 line
2.9.3
author
#6 lore raw
In reply to Eric Blake
Quoted 15 lines · Eric Blake

v2 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03185.html
v3 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg05515.html

Since then:
- s/ShutdownType/ShutdownCause/ to avoid conflict with mingw header pollution
- fix long line

Eric Blake (4):
shutdown: Simplify shutdown_signal
shutdown: Prepare for use of an enum in reset/shutdown_request
shutdown: Add source information to SHUTDOWN and RESET
RFC: shutdown: Expose full ShutdownCause across QMP

Quoted 4 lines
 qapi-schema.json            |    26 +
 qapi/event.json             |    12 +-
 include/sysemu/sysemu.h     |     6 +-
 trace/generated-tracers.h   | 18523 ++++++++++++++++++++++++++++++++++++++++++

Bleargh. I 'git add'ed too much. Apologies for the spam. v5 coming up.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org