replay: checkpoints

This patch introduces checkpoints that synchronize cpu thread and iothread.
When checkpoint is met in the code all asynchronous events from the queue
are executed.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Message-Id: <20150917162444.8676.52916.stgit@PASHA-ISP.def.inno>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
This commit is contained in:
Pavel Dovgalyuk 2015-09-17 19:24:44 +03:00 committed by Paolo Bonzini
parent efab87cf79
commit 8bd7f71d79
7 changed files with 134 additions and 12 deletions

29
vl.c
View file

@ -1642,15 +1642,21 @@ static void qemu_kill_report(void)
static int qemu_reset_requested(void)
{
int r = reset_requested;
reset_requested = 0;
return r;
if (r && replay_checkpoint(CHECKPOINT_RESET_REQUESTED)) {
reset_requested = 0;
return r;
}
return false;
}
static int qemu_suspend_requested(void)
{
int r = suspend_requested;
suspend_requested = 0;
return r;
if (r && replay_checkpoint(CHECKPOINT_SUSPEND_REQUESTED)) {
suspend_requested = 0;
return r;
}
return false;
}
static WakeupReason qemu_wakeup_requested(void)
@ -1798,7 +1804,12 @@ void qemu_system_killed(int signal, pid_t pid)
shutdown_signal = signal;
shutdown_pid = pid;
no_shutdown = 0;
qemu_system_shutdown_request();
/* Cannot call qemu_system_shutdown_request directly because
* we are in a signal handler.
*/
shutdown_requested = 1;
qemu_notify_event();
}
void qemu_system_shutdown_request(void)
@ -4483,6 +4494,10 @@ int main(int argc, char **argv, char **envp)
}
qemu_add_globals();
/* This checkpoint is required by replay to separate prior clock
reading from the other reads, because timer polling functions query
clock values from the log. */
replay_checkpoint(CHECKPOINT_INIT);
qdev_machine_init();
current_machine->ram_size = ram_size;
@ -4601,6 +4616,10 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
/* This checkpoint is required by replay to separate prior clock
reading from the other reads, because timer polling functions query
clock values from the log. */
replay_checkpoint(CHECKPOINT_RESET);
qemu_system_reset(VMRESET_SILENT);
register_global_state();
if (loadvm) {