From ee312992a323530ea2cda8680f3a34746c72db8f Mon Sep 17 00:00:00 2001 From: Pavel Dovgalyuk Date: Thu, 17 Sep 2015 19:25:24 +0300 Subject: replay: recording of the user input This records user input (keyboard and mouse events) in record mode and replays these input events in replay mode. Signed-off-by: Pavel Dovgalyuk Message-Id: <20150917162524.8676.11696.stgit@PASHA-ISP.def.inno> Signed-off-by: Paolo Bonzini Signed-off-by: Pavel Dovgalyuk --- replay/replay-events.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'replay/replay-events.c') diff --git a/replay/replay-events.c b/replay/replay-events.c index 8db2c7a..402f644 100644 --- a/replay/replay-events.c +++ b/replay/replay-events.c @@ -14,6 +14,7 @@ #include "sysemu/replay.h" #include "replay-internal.h" #include "block/aio.h" +#include "ui/input.h" typedef struct Event { ReplayAsyncEventKind event_kind; @@ -39,6 +40,13 @@ static void replay_run_event(Event *event) case REPLAY_ASYNC_EVENT_BH: aio_bh_call(event->opaque); break; + case REPLAY_ASYNC_EVENT_INPUT: + qemu_input_event_send_impl(NULL, (InputEvent *)event->opaque); + qapi_free_InputEvent((InputEvent *)event->opaque); + break; + case REPLAY_ASYNC_EVENT_INPUT_SYNC: + qemu_input_event_sync_impl(); + break; default: error_report("Replay: invalid async event ID (%d) in the queue", event->event_kind); @@ -131,6 +139,16 @@ void replay_bh_schedule_event(QEMUBH *bh) } } +void replay_add_input_event(struct InputEvent *event) +{ + replay_add_event(REPLAY_ASYNC_EVENT_INPUT, event, NULL, 0); +} + +void replay_add_input_sync_event(void) +{ + replay_add_event(REPLAY_ASYNC_EVENT_INPUT_SYNC, NULL, NULL, 0); +} + static void replay_save_event(Event *event, int checkpoint) { if (replay_mode != REPLAY_MODE_PLAY) { @@ -144,6 +162,11 @@ static void replay_save_event(Event *event, int checkpoint) case REPLAY_ASYNC_EVENT_BH: replay_put_qword(event->id); break; + case REPLAY_ASYNC_EVENT_INPUT: + replay_save_input_event(event->opaque); + break; + case REPLAY_ASYNC_EVENT_INPUT_SYNC: + break; default: error_report("Unknown ID %d of replay event", read_event_kind); exit(1); @@ -187,6 +210,16 @@ static Event *replay_read_event(int checkpoint) read_id = replay_get_qword(); } break; + case REPLAY_ASYNC_EVENT_INPUT: + event = g_malloc0(sizeof(Event)); + event->event_kind = read_event_kind; + event->opaque = replay_read_input_event(); + return event; + case REPLAY_ASYNC_EVENT_INPUT_SYNC: + event = g_malloc0(sizeof(Event)); + event->event_kind = read_event_kind; + event->opaque = 0; + return event; default: error_report("Unknown ID %d of replay event", read_event_kind); exit(1); -- cgit v1.1