summary refs log tree commit diff stats
path: root/replay
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2017-05-15 16:41:12 -0500
committerMarkus Armbruster <armbru@redhat.com>2017-05-23 13:28:17 +0200
commit802f045a5f61b781df55e4492d896b4d20503ba7 (patch)
tree69a69ba0835eb19dfa9d4f06944ed09def8d2e20 /replay
parentaedbe19297907143f17b733a7ff0e0534377bed1 (diff)
downloadfocaccia-qemu-802f045a5f61b781df55e4492d896b4d20503ba7.tar.gz
focaccia-qemu-802f045a5f61b781df55e4492d896b4d20503ba7.zip
shutdown: Preserve shutdown cause through replay
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>
Diffstat (limited to 'replay')
-rw-r--r--replay/replay-internal.h3
-rw-r--r--replay/replay.c7
2 files changed, 6 insertions, 4 deletions
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index ed66ed803c..3ebb19912a 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 f810628cac..bf94e81261 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();
     }
 }