mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
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:
committed by
Kevin Wolf
parent
ae25dccb7d
commit
e4ec5ad464
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user