From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 5/9] shutdown: Preserve shutdown cause through replay
Date: Tue, 23 May 2017 14:30:34 +0200 [thread overview]
Message-ID: <1495542638-12335-6-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1495542638-12335-1-git-send-email-armbru@redhat.com>
From: Eric Blake <eblake@redhat.com>
With the recent addition of ShutdownCause, we want to be able to pass
a cause through any shutdown request, and then faithfully replay that
cause when later replaying the same sequence. The easiest way is to
expand the reply event mechanism to track a series of values for
EVENT_SHUTDOWN, one corresponding to each value of ShutdownCause.
We are free to change the replay stream as needed, since there are
already no guarantees about being able to use a replay stream by
any other version of qemu than the one that generated it.
The cause is not actually fed back until the next patch changes the
signature for requesting a shutdown; a TODO marks that upcoming change.
Yes, this uses the gcc/clang extension of a ranged case label,
but this is not the first time we've used non-C99 constructs.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Message-Id: <20170515214114.15442-4-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
include/sysemu/replay.h | 3 ++-
replay/replay-internal.h | 3 ++-
replay/replay.c | 7 ++++---
vl.c | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index f1c0712..fa14d0e 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/replay.h
@@ -13,6 +13,7 @@
*/
#include "qapi-types.h"
+#include "sysemu.h"
/* replay clock kinds */
enum ReplayClockKind {
@@ -98,7 +99,7 @@ int64_t replay_read_clock(ReplayClockKind kind);
/* Events */
/*! Called when qemu shutdown is requested. */
-void replay_shutdown_request(void);
+void replay_shutdown_request(ShutdownCause cause);
/*! Should be called at check points in the execution.
These check points are skipped, if they were not met.
Saves checkpoint in the SAVE mode and validates in the PLAY mode.
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index ed66ed8..3ebb199 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -22,8 +22,9 @@ enum ReplayEvents {
EVENT_EXCEPTION,
/* for async events */
EVENT_ASYNC,
- /* for shutdown request */
+ /* for shutdown requests, range allows recovery of ShutdownCause */
EVENT_SHUTDOWN,
+ EVENT_SHUTDOWN_LAST = EVENT_SHUTDOWN + SHUTDOWN_CAUSE__MAX,
/* for character device write event */
EVENT_CHAR_WRITE,
/* for character device read all event */
diff --git a/replay/replay.c b/replay/replay.c
index f810628..bf94e81 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -49,8 +49,9 @@ bool replay_next_event_is(int event)
res = true;
}
switch (replay_state.data_kind) {
- case EVENT_SHUTDOWN:
+ case EVENT_SHUTDOWN ... EVENT_SHUTDOWN_LAST:
replay_finish_event();
+ /* TODO - pass replay_state.data_kind - EVENT_SHUTDOWN as cause */
qemu_system_shutdown_request();
break;
default:
@@ -170,11 +171,11 @@ bool replay_has_interrupt(void)
return res;
}
-void replay_shutdown_request(void)
+void replay_shutdown_request(ShutdownCause cause)
{
if (replay_mode == REPLAY_MODE_RECORD) {
replay_mutex_lock();
- replay_put_event(EVENT_SHUTDOWN);
+ replay_put_event(EVENT_SHUTDOWN + cause);
replay_mutex_unlock();
}
}
diff --git a/vl.c b/vl.c
index d90ae3f..909519f 100644
--- a/vl.c
+++ b/vl.c
@@ -1821,8 +1821,8 @@ void qemu_system_killed(int signal, pid_t pid)
void qemu_system_shutdown_request(void)
{
trace_qemu_system_shutdown_request();
- replay_shutdown_request();
/* TODO - add a parameter to allow callers to specify reason */
+ replay_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR);
shutdown_requested = SHUTDOWN_CAUSE_HOST_ERROR;
qemu_notify_event();
}
--
2.7.4
next prev parent reply other threads:[~2017-05-23 12:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 12:30 [Qemu-devel] [PULL 0/9] QAPI patches for 2017-05-23 Markus Armbruster
2017-05-23 12:30 ` [Qemu-devel] [PULL 1/9] scripts/qmp/qom-set: fix the value argument passed to srv.command() Markus Armbruster
2017-05-23 12:30 ` [Qemu-devel] [PULL 2/9] sockets: Plug memory leak in socket_address_flatten() Markus Armbruster
2017-05-23 12:30 ` [Qemu-devel] [PULL 3/9] shutdown: Simplify shutdown_signal Markus Armbruster
2017-05-23 12:30 ` [Qemu-devel] [PULL 4/9] shutdown: Prepare for use of an enum in reset/shutdown_request Markus Armbruster
2017-05-23 12:30 ` Markus Armbruster [this message]
2017-05-23 12:30 ` [Qemu-devel] [PULL 6/9] shutdown: Add source information to SHUTDOWN and RESET Markus Armbruster
2017-05-23 12:30 ` [Qemu-devel] [PULL 7/9] shutdown: Expose bool cause in SHUTDOWN and RESET events Markus Armbruster
2017-05-23 12:30 ` [Qemu-devel] [PULL 8/9] block: Use QDict helpers for --force-share Markus Armbruster
2017-05-23 12:30 ` [Qemu-devel] [PULL 9/9] qapi-schema: Remove obsolete note from ObjectTypeInfo Markus Armbruster
2017-05-30 8:37 ` [Qemu-devel] [PULL 0/9] QAPI patches for 2017-05-23 Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1495542638-12335-6-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).