From patchwork Tue Mar 13 22:47:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 10281231 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 779AF601A0 for ; Tue, 13 Mar 2018 23:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 698B9285BE for ; Tue, 13 Mar 2018 23:36:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CC7F285CC; Tue, 13 Mar 2018 23:36:47 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 CD51F285BE for ; Tue, 13 Mar 2018 23:36:46 +0000 (UTC) Received: from localhost ([::1]:43553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtTK-0006No-1z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Mar 2018 19:36:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evsig-0006KG-5y for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evsid-00046M-QY for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:34 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:44650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evsid-00045p-Gm for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:31 -0400 Received: by mail-wr0-x22b.google.com with SMTP id v65so2494678wrc.11 for ; Tue, 13 Mar 2018 15:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=EQF+H36ScYIVOmEU9qBqaxbZ5C+Pe2vaWehlGZhjI94=; b=p/xs8ORtHooIV0BW67Hvr+8KFGzJpBJJId+rGtXf/VdZrNm3wv5HuRtxjtnkB/km5H PtPsVSQlh2zm0ZwBDVQU1mxaIpOzkBJJvgWvA2QKwNynsx/+4Y+QGdeh3YqSyOZ4x4pW m33WMexNwj6+LjNid1xqXcACis7B+BqynSVLCVKKO88zfCkfCJRLzNTVjHSkPP8ROWex /YURP3ShlLSvlB1bqk7HQHzW9PsN2RYakR8wF3DTC1CNxlCyqEXIiZo1y9iLRFCmMwMz j6Cg9HydSc6PuLlo7hysmmGcAf/gvBWLv2Iozyk0Iyw4kRzHyvyicrOWFSr6l2e1td/S kspw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=EQF+H36ScYIVOmEU9qBqaxbZ5C+Pe2vaWehlGZhjI94=; b=pMr17kTEQs2qQAbY2Bd+cYD8qlGR+IxIkRZJSNcyUjTj0X8yakdghho8refJDfXbvL We1MvrL0QGv4RhzQpgaZv19vDrrcMOnVCJjXz9Hxap50NoxX+1bvFscbpqgfN04E8bUC C5pcVwJYERiX9MoQY39Nu3Cavm0kbzK6i0Z2LItVp2zhbSj+o8qYqTDifqi8FL0fsags /mn2UW3DzaOi4+9Jg0OFVyKEj+bESzhaWKx9hHrQlOPfDBowjoAq2QN4mk+L2IT9dyb5 i8kRZ3bxsYgV1dpRz5cr85Sf1punNWRg/IxLcSl9tHpzhIld2rZh86nIiigeQEWs1CSE utWQ== X-Gm-Message-State: AElRT7GgbPVKWCbxO6m24AnLS4opkCi+MXw5IoA+nXIYOTbl85ZFILaK FScaHi1uolC4+pIVNzGsOK9Ak60A X-Google-Smtp-Source: AG47ELv8K9snPvlum6DOein41UYXNVBqSSPXK6RQ4FPSooQ3gt9mG4WPkOTWEgAG76jVphMmgl31Rw== X-Received: by 10.223.157.24 with SMTP id k24mr1922113wre.273.1520981309970; Tue, 13 Mar 2018 15:48:29 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id x107sm1557951wrb.97.2018.03.13.15.48.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 15:48:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 23:47:06 +0100 Message-Id: <20180313224719.4954-57-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313224719.4954-1-pbonzini@redhat.com> References: <20180313224719.4954-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PULL 56/69] replay: added replay log format description 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: Pavel Dovgalyuk Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Pavel Dovgalyuk This patch adds description of the replay log file format into the docs/replay.txt. Signed-off-by: Pavel Dovgalyuk Acked-by: Paolo Bonzini Message-Id: <20180227095220.1060.58759.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini --- docs/replay.txt | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/docs/replay.txt b/docs/replay.txt index 486c1e0e9d..c52407fe23 100644 --- a/docs/replay.txt +++ b/docs/replay.txt @@ -232,3 +232,72 @@ Audio devices Audio data is recorded and replay automatically. The command line for recording and replaying must contain identical specifications of audio hardware, e.g.: -soundhw ac97 + +Replay log format +----------------- + +Record/replay log consits of the header and the sequence of execution +events. The header includes 4-byte replay version id and 8-byte reserved +field. Version is updated every time replay log format changes to prevent +using replay log created by another build of qemu. + +The sequence of the events describes virtual machine state changes. +It includes all non-deterministic inputs of VM, synchronization marks and +instruction counts used to correctly inject inputs at replay. + +Synchronization marks (checkpoints) are used for synchronizing qemu threads +that perform operations with virtual hardware. These operations may change +system's state (e.g., change some register or generate interrupt) and +therefore should execute synchronously with CPU thread. + +Every event in the log includes 1-byte event id and optional arguments. +When argument is an array, it is stored as 4-byte array length +and corresponding number of bytes with data. +Here is the list of events that are written into the log: + + - EVENT_INSTRUCTION. Instructions executed since last event. + Argument: 4-byte number of executed instructions. + - EVENT_INTERRUPT. Used to synchronize interrupt processing. + - EVENT_EXCEPTION. Used to synchronize exception handling. + - EVENT_ASYNC. This is a group of events. They are always processed + together with checkpoints. When such an event is generated, it is + stored in the queue and processed only when checkpoint occurs. + Every such event is followed by 1-byte checkpoint id and 1-byte + async event id from the following list: + - REPLAY_ASYNC_EVENT_BH. Bottom-half callback. This event synchronizes + callbacks that affect virtual machine state, but normally called + asyncronously. + Argument: 8-byte operation id. + - REPLAY_ASYNC_EVENT_INPUT. Input device event. Contains + parameters of keyboard and mouse input operations + (key press/release, mouse pointer movement). + Arguments: 9-16 bytes depending of input event. + - REPLAY_ASYNC_EVENT_INPUT_SYNC. Internal input synchronization event. + - REPLAY_ASYNC_EVENT_CHAR_READ. Character (e.g., serial port) device input + initiated by the sender. + Arguments: 1-byte character device id. + Array with bytes were read. + - REPLAY_ASYNC_EVENT_BLOCK. Block device operation. Used to synchronize + operations with disk and flash drives with CPU. + Argument: 8-byte operation id. + - REPLAY_ASYNC_EVENT_NET. Incoming network packet. + Arguments: 1-byte network adapter id. + 4-byte packet flags. + Array with packet bytes. + - EVENT_SHUTDOWN. Occurs when user sends shutdown event to qemu, + e.g., by closing the window. + - EVENT_CHAR_WRITE. Used to synchronize character output operations. + Arguments: 4-byte output function return value. + 4-byte offset in the output array. + - EVENT_CHAR_READ_ALL. Used to synchronize character input operations, + initiated by qemu. + Argument: Array with bytes that were read. + - EVENT_CHAR_READ_ALL_ERROR. Unsuccessful character input operation, + initiated by qemu. + Argument: 4-byte error code. + - EVENT_CLOCK + clock_id. Group of events for host clock read operations. + Argument: 8-byte clock value. + - EVENT_CHECKPOINT + checkpoint_id. Checkpoint for synchronization of + CPU, internal threads, and asynchronous input events. May be followed + by one or more EVENT_ASYNC events. + - EVENT_END. Last event in the log.