From patchwork Thu Sep 15 09:01:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 9332977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D1E736077F for ; Thu, 15 Sep 2016 09:06:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD9CE2943B for ; Thu, 15 Sep 2016 09:06:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B22292943E; Thu, 15 Sep 2016 09:06:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4B6192943B for ; Thu, 15 Sep 2016 09:06:17 +0000 (UTC) Received: from localhost ([::1]:32851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkSca-0001By-EA for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Sep 2016 05:06:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkSXv-0006GX-N8 for qemu-devel@nongnu.org; Thu, 15 Sep 2016 05:01:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkSXq-0001ro-S3 for qemu-devel@nongnu.org; Thu, 15 Sep 2016 05:01:26 -0400 Received: from mail.ispras.ru ([83.149.199.45]:38944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkSXq-0001qG-Kt for qemu-devel@nongnu.org; Thu, 15 Sep 2016 05:01:22 -0400 Received: from [10.10.150.35] (unknown [85.142.117.224]) by mail.ispras.ru (Postfix) with ESMTPSA id E61B154006F; Thu, 15 Sep 2016 12:01:10 +0300 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Thu, 15 Sep 2016 12:01:05 +0300 Message-ID: <20160915090105.6440.95131.stgit@PASHA-ISP> In-Reply-To: <20160915090042.6440.22516.stgit@PASHA-ISP> References: <20160915090042.6440.22516.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v2 04/10] replay: save/load initial state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, quintela@redhat.com, jasowang@redhat.com, mst@redhat.com, agraf@suse.de, pbonzini@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch implements initial vmstate creation or loading at the start of record/replay. It is needed for rewinding the execution in the replay mode. Signed-off-by: Pavel Dovgalyuk --- include/sysemu/replay.h | 6 ++++++ replay/Makefile.objs | 1 + replay/replay-snapshot.c | 31 +++++++++++++++++++++++++++++++ vl.c | 2 ++ 4 files changed, 40 insertions(+) create mode 100644 replay/replay-snapshot.c diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index a408633..aa378ce 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -145,4 +145,10 @@ void replay_unregister_net(ReplayNetState *rns); void replay_net_packet_event(ReplayNetState *rns, unsigned flags, const struct iovec *iov, int iovcnt); +/* VM state operations */ + +/*! Called at the start of execution. + Loads or saves initial vmstate depending on execution mode. */ +void replay_vmstate_init(void); + #endif diff --git a/replay/Makefile.objs b/replay/Makefile.objs index f55a6b5..4600d74 100644 --- a/replay/Makefile.objs +++ b/replay/Makefile.objs @@ -5,3 +5,4 @@ common-obj-y += replay-time.o common-obj-y += replay-input.o common-obj-y += replay-char.o common-obj-y += replay-net.o +common-obj-y += replay-snapshot.o diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c new file mode 100644 index 0000000..a48c6fc --- /dev/null +++ b/replay/replay-snapshot.c @@ -0,0 +1,31 @@ +/* + * replay-snapshot.c + * + * Copyright (c) 2010-2016 Institute for System Programming + * of the Russian Academy of Sciences. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "sysemu/replay.h" +#include "replay-internal.h" +#include "sysemu/sysemu.h" +#include "monitor/monitor.h" +#include "qapi/qmp/qstring.h" + +void replay_vmstate_init(void) +{ + if (replay_mode == REPLAY_MODE_RECORD) { + QDict *opts = qdict_new(); + qdict_put(opts, "name", qstring_from_str("replay_init")); + hmp_savevm(cur_mon, opts); + QDECREF(opts); + } else if (replay_mode == REPLAY_MODE_PLAY) { + load_vmstate("replay_init"); + } +} diff --git a/vl.c b/vl.c index 1c68779..6698d88 100644 --- a/vl.c +++ b/vl.c @@ -4593,6 +4593,8 @@ int main(int argc, char **argv, char **envp) if (load_vmstate(loadvm) < 0) { autostart = 0; } + } else { + replay_vmstate_init(); } qdev_prop_check_globals();