replay: add BH oneshot event for block layer

Replay is capable of recording normal BH events, but sometimes
there are single use callbacks scheduled with aio_bh_schedule_oneshot
function. This patch enables recording and replaying such callbacks.
Block layer uses these events for calling the completion function.
Replaying these calls makes the execution deterministic.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Pavel Dovgalyuk
2019-09-17 14:58:19 +03:00
committed by Kevin Wolf
parent ae25dccb7d
commit e4ec5ad464
13 changed files with 59 additions and 16 deletions

View File

@ -36,6 +36,9 @@ static void replay_run_event(Event *event)
case REPLAY_ASYNC_EVENT_BH:
aio_bh_call(event->opaque);
break;
case REPLAY_ASYNC_EVENT_BH_ONESHOT:
((QEMUBHFunc *)event->opaque)(event->opaque2);
break;
case REPLAY_ASYNC_EVENT_INPUT:
qemu_input_event_send_impl(NULL, (InputEvent *)event->opaque);
qapi_free_InputEvent((InputEvent *)event->opaque);
@ -131,6 +134,17 @@ void replay_bh_schedule_event(QEMUBH *bh)
}
}
void replay_bh_schedule_oneshot_event(AioContext *ctx,
QEMUBHFunc *cb, void *opaque)
{
if (events_enabled) {
uint64_t id = replay_get_current_icount();
replay_add_event(REPLAY_ASYNC_EVENT_BH_ONESHOT, cb, opaque, id);
} else {
aio_bh_schedule_oneshot(ctx, cb, opaque);
}
}
void replay_add_input_event(struct InputEvent *event)
{
replay_add_event(REPLAY_ASYNC_EVENT_INPUT, event, NULL, 0);
@ -161,6 +175,7 @@ static void replay_save_event(Event *event, int checkpoint)
/* save event-specific data */
switch (event->event_kind) {
case REPLAY_ASYNC_EVENT_BH:
case REPLAY_ASYNC_EVENT_BH_ONESHOT:
replay_put_qword(event->id);
break;
case REPLAY_ASYNC_EVENT_INPUT:
@ -216,6 +231,7 @@ static Event *replay_read_event(int checkpoint)
/* Events that has not to be in the queue */
switch (replay_state.read_event_kind) {
case REPLAY_ASYNC_EVENT_BH:
case REPLAY_ASYNC_EVENT_BH_ONESHOT:
if (replay_state.read_event_id == -1) {
replay_state.read_event_id = replay_get_qword();
}