qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN
@ 2017-04-27 21:31 Eric Blake
  2017-04-27 21:31 ` [Qemu-devel] [PATCH v4 1/4] shutdown: Simplify shutdown_signal Eric Blake
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Eric Blake @ 2017-04-27 21:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, berrange, alistair.francis

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

-- 
2.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v4 1/4] shutdown: Simplify shutdown_signal
  2017-04-27 21:31 [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake
@ 2017-04-27 21:31 ` Eric Blake
  2017-04-27 21:32 ` [Qemu-devel] [PATCH v4 2/4] shutdown: Prepare for use of an enum in reset/shutdown_request Eric Blake
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2017-04-27 21:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, berrange, alistair.francis, Paolo Bonzini

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.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>

---
v3: new patch
---
 vl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vl.c b/vl.c
index f46e070..879786a 100644
--- a/vl.c
+++ b/vl.c
@@ -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;
     }
 }

-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v4 2/4] shutdown: Prepare for use of an enum in reset/shutdown_request
  2017-04-27 21:31 [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake
  2017-04-27 21:31 ` [Qemu-devel] [PATCH v4 1/4] shutdown: Simplify shutdown_signal Eric Blake
@ 2017-04-27 21:32 ` Eric Blake
  2017-04-27 21:32 ` [Qemu-devel] [PATCH v4 4/4] RFC: shutdown: Expose full ShutdownCause across QMP Eric Blake
  2017-04-27 22:37 ` [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2017-04-27 21:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, berrange, alistair.francis, Stefano Stabellini,
	Anthony Perard, Paolo Bonzini, Richard Henderson, Eduardo Habkost,
	Michael S. Tsirkin, zhanghailiang, Juan Quintela,
	Dr. David Alan Gilbert, open list:X86

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.

Signed-off-by: Eric Blake <eblake@redhat.com>

---
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(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 01b087f..a4ebdd1 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -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.
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 16175f7..00a907f 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -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);

diff --git a/vl.c b/vl.c
index 879786a..2b95b7f 100644
--- a/vl.c
+++ b/vl.c
@@ -1597,8 +1597,8 @@ void vm_state_notify(int running, RunState state)
     }
 }

-static int reset_requested;
-static int shutdown_requested, shutdown_signal;
+static int reset_requested = -1;
+static int shutdown_requested = -1, shutdown_signal;
 static pid_t shutdown_pid;
 static int powerdown_requested;
 static int debug_requested;
@@ -1624,7 +1624,7 @@ int qemu_reset_requested_get(void)

 static int qemu_shutdown_requested(void)
 {
-    return atomic_xchg(&shutdown_requested, 0);
+    return atomic_xchg(&shutdown_requested, -1);
 }

 static void qemu_kill_report(void)
@@ -1650,11 +1650,11 @@ static void qemu_kill_report(void)
 static int qemu_reset_requested(void)
 {
     int r = reset_requested;
-    if (r && replay_checkpoint(CHECKPOINT_RESET_REQUESTED)) {
-        reset_requested = 0;
+    if (r >= 0 && replay_checkpoint(CHECKPOINT_RESET_REQUESTED)) {
+        reset_requested = -1;
         return r;
     }
-    return false;
+    return -1;
 }

 static int qemu_suspend_requested(void)
@@ -1686,7 +1686,12 @@ static int qemu_debug_requested(void)
     return r;
 }

-void qemu_system_reset(bool report)
+/*
+ * Reset the VM. If @report is VMRESET_REPORT, issue an event, using
+ * the @reason interpreted as ShutdownType for details.  Otherwise,
+ * @report is VMRESET_SILENT and @reason is ignored.
+ */
+void qemu_system_reset(bool report, int reason)
 {
     MachineClass *mc;

@@ -1700,6 +1705,7 @@ void qemu_system_reset(bool report)
         qemu_devices_reset();
     }
     if (report) {
+        assert(reason >= 0);
         qapi_event_send_reset(&error_abort);
     }
     cpu_synchronize_all_post_reset();
@@ -1738,9 +1744,10 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
 void qemu_system_reset_request(void)
 {
     if (no_reboot) {
-        shutdown_requested = 1;
+        /* FIXME - add a parameter to allow callers to specify reason */
+        shutdown_requested = SHUTDOWN_CAUSE_GUEST_RESET;
     } else {
-        reset_requested = 1;
+        reset_requested = SHUTDOWN_CAUSE_GUEST_RESET;
     }
     cpu_stop_current();
     qemu_notify_event();
@@ -1807,7 +1814,7 @@ void qemu_system_killed(int signal, pid_t pid)
     /* Cannot call qemu_system_shutdown_request directly because
      * we are in a signal handler.
      */
-    shutdown_requested = 1;
+    shutdown_requested = SHUTDOWN_CAUSE_HOST_SIGNAL;
     qemu_notify_event();
 }

@@ -1815,7 +1822,8 @@ void qemu_system_shutdown_request(void)
 {
     trace_qemu_system_shutdown_request();
     replay_shutdown_request();
-    shutdown_requested = 1;
+    /* FIXME - add a parameter to allow callers to specify reason */
+    shutdown_requested = SHUTDOWN_CAUSE_GUEST_SHUTDOWN;
     qemu_notify_event();
 }

@@ -1846,13 +1854,16 @@ void qemu_system_debug_request(void)
 static bool main_loop_should_exit(void)
 {
     RunState r;
+    int request;
+
     if (qemu_debug_requested()) {
         vm_stop(RUN_STATE_DEBUG);
     }
     if (qemu_suspend_requested()) {
         qemu_system_suspend();
     }
-    if (qemu_shutdown_requested()) {
+    request = qemu_shutdown_requested();
+    if (request >= 0) {
         qemu_kill_report();
         qapi_event_send_shutdown(&error_abort);
         if (no_shutdown) {
@@ -1861,9 +1872,10 @@ static bool main_loop_should_exit(void)
             return true;
         }
     }
-    if (qemu_reset_requested()) {
+    request = qemu_reset_requested();
+    if (request >= 0) {
         pause_all_vcpus();
-        qemu_system_reset(VMRESET_REPORT);
+        qemu_system_reset(VMRESET_REPORT, request);
         resume_all_vcpus();
         if (!runstate_check(RUN_STATE_RUNNING) &&
                 !runstate_check(RUN_STATE_INMIGRATE)) {
@@ -1872,7 +1884,7 @@ static bool main_loop_should_exit(void)
     }
     if (qemu_wakeup_requested()) {
         pause_all_vcpus();
-        qemu_system_reset(VMRESET_SILENT);
+        qemu_system_reset(VMRESET_SILENT, -1);
         notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
         wakeup_reason = QEMU_WAKEUP_REASON_NONE;
         resume_all_vcpus();
@@ -4684,7 +4696,7 @@ int main(int argc, char **argv, char **envp)
        reading from the other reads, because timer polling functions query
        clock values from the log. */
     replay_checkpoint(CHECKPOINT_RESET);
-    qemu_system_reset(VMRESET_SILENT);
+    qemu_system_reset(VMRESET_SILENT, -1);
     register_global_state();
     if (replay_mode != REPLAY_MODE_NONE) {
         replay_vmstate_init();
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index b1c05ff..3a6484c 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -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);
             }
         }
diff --git a/migration/colo.c b/migration/colo.c
index c19eb3f..17a5482 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -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");
diff --git a/migration/savevm.c b/migration/savevm.c
index 03ae1bd..dcbaf00 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -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);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v4 4/4] RFC: shutdown: Expose full ShutdownCause across QMP
  2017-04-27 21:31 [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake
  2017-04-27 21:31 ` [Qemu-devel] [PATCH v4 1/4] shutdown: Simplify shutdown_signal Eric Blake
  2017-04-27 21:32 ` [Qemu-devel] [PATCH v4 2/4] shutdown: Prepare for use of an enum in reset/shutdown_request Eric Blake
@ 2017-04-27 21:32 ` Eric Blake
  2017-04-27 22:37 ` [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2017-04-27 21:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, berrange, alistair.francis, Kevin Wolf, Max Reitz,
	Paolo Bonzini, open list:Block layer core

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.

Signed-off-by: Eric Blake <eblake@redhat.com>

---
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(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index a4ebdd1..f699f04 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -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
diff --git a/qapi/event.json b/qapi/event.json
index 6d22b02..48648ac 100644
--- a/qapi/event.json
+++ b/qapi/event.json
@@ -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:
diff --git a/vl.c b/vl.c
index 0a933ba..e226a59 100644
--- a/vl.c
+++ b/vl.c
@@ -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 {
diff --git a/tests/qemu-iotests/071.out b/tests/qemu-iotests/071.out
index 1d5e28d..aa6edc2 100644
--- a/tests/qemu-iotests/071.out
+++ b/tests/qemu-iotests/071.out
@@ -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

diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
index 2533c31..ed79421 100644
--- a/tests/qemu-iotests/081.out
+++ b/tests/qemu-iotests/081.out
@@ -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 ==
diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out
index 59c5208..a494659 100644
--- a/tests/qemu-iotests/087.out
+++ b/tests/qemu-iotests/087.out
@@ -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
diff --git a/tests/qemu-iotests/094.out b/tests/qemu-iotests/094.out
index f52baff..6059f20 100644
--- a/tests/qemu-iotests/094.out
+++ b/tests/qemu-iotests/094.out
@@ -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
diff --git a/tests/qemu-iotests/117.out b/tests/qemu-iotests/117.out
index 851e214..d325f64 100644
--- a/tests/qemu-iotests/117.out
+++ b/tests/qemu-iotests/117.out
@@ -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)
diff --git a/tests/qemu-iotests/119.out b/tests/qemu-iotests/119.out
index a8743b8..80d2750 100644
--- a/tests/qemu-iotests/119.out
+++ b/tests/qemu-iotests/119.out
@@ -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
diff --git a/tests/qemu-iotests/120.out b/tests/qemu-iotests/120.out
index 1af1aeb..fe717f0 100644
--- a/tests/qemu-iotests/120.out
+++ b/tests/qemu-iotests/120.out
@@ -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
diff --git a/tests/qemu-iotests/140.out b/tests/qemu-iotests/140.out
index 0689b2b..2da1c0a 100644
--- a/tests/qemu-iotests/140.out
+++ b/tests/qemu-iotests/140.out
@@ -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
diff --git a/tests/qemu-iotests/143.out b/tests/qemu-iotests/143.out
index 0978b89..efec8a0 100644
--- a/tests/qemu-iotests/143.out
+++ b/tests/qemu-iotests/143.out
@@ -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
diff --git a/tests/qemu-iotests/156.out b/tests/qemu-iotests/156.out
index f96a564..cfa7665 100644
--- a/tests/qemu-iotests/156.out
+++ b/tests/qemu-iotests/156.out
@@ -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)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN
  2017-04-27 21:31 [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake
                   ` (2 preceding siblings ...)
  2017-04-27 21:32 ` [Qemu-devel] [PATCH v4 4/4] RFC: shutdown: Expose full ShutdownCause across QMP Eric Blake
@ 2017-04-27 22:37 ` Eric Blake
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2017-04-27 22:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, alistair.francis

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

On 04/27/2017 04:31 PM, Eric Blake wrote:
> 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 ++++++++++++++++++++++++++++++++++++++++++

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


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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-27 22:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-27 21:31 [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake
2017-04-27 21:31 ` [Qemu-devel] [PATCH v4 1/4] shutdown: Simplify shutdown_signal Eric Blake
2017-04-27 21:32 ` [Qemu-devel] [PATCH v4 2/4] shutdown: Prepare for use of an enum in reset/shutdown_request Eric Blake
2017-04-27 21:32 ` [Qemu-devel] [PATCH v4 4/4] RFC: shutdown: Expose full ShutdownCause across QMP Eric Blake
2017-04-27 22:37 ` [Qemu-devel] [PATCH v4 0/4] event: Add source information to SHUTDOWN Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).