event: Add source information to SHUTDOWN
Subsystems (2)
PATCH v4 3/4 shutdown: Add source information to SHUTDOWN and RESET
In reply to Eric BlakeLibvirt 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
@@ -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
@@ -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
foo.c new file +121 -0
121 lines not on this page · raw message
bar new file binary +0 -0
bar.src new file binary +0 -0
file new file binary +0 -0
file2 new file binary +0 -0
file3 new file binary +0 -0
foo new file binary +0 -0
tests/test-hmp new file binary +0 -0
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.
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
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
@@ -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
PATCH v4 2/4 shutdown: Prepare for use of an enum in reset/shutdown_request
In reply to Eric BlakeWe 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v4 3/4 shutdown: Add source information to SHUTDOWN and RESET
In reply to Eric BlakeLibvirt 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
@@ -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
@@ -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
foo.c new file +121 -0
121 lines not on this page · raw message
bar new file binary +0 -0
bar.src new file binary +0 -0
file new file binary +0 -0
file2 new file binary +0 -0
file3 new file binary +0 -0
foo new file binary +0 -0
tests/test-hmp new file binary +0 -0
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.
PATCH v4 4/4 RFC: shutdown: Expose full ShutdownCause across QMP
In reply to Eric BlakeSince 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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.htmlSince then:
- s/ShutdownType/ShutdownCause/ to avoid conflict with mingw header pollution
- fix long lineEric Blake (4):
shutdown: Simplifyshutdown_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