From nobody Tue Dec 16 07:07:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520983933238744.2987711981298; Tue, 13 Mar 2018 16:32:13 -0700 (PDT) Received: from localhost ([::1]:43525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtOq-0002HP-G5 for importer@patchew.org; Tue, 13 Mar 2018 19:32:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evsis-0006Wl-OY for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evsir-0004Gl-EZ for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:46 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:45033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evsir-0004Fr-5Z for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:45 -0400 Received: by mail-wr0-x242.google.com with SMTP id v65so2495065wrc.11 for ; Tue, 13 Mar 2018 15:48:45 -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.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 15:48:43 -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=0fLcL6Se/Dki1X8TEMGzoVU3A36vkkDwDLOh4ZB5lSg=; b=kB8TnampRwOG/yr7zFotIC5/UUyujTLb8Put9kV82Bwmb0lBpi9Oqix0rDpnEU1kID 8s0Aa1BBfk7Gu+NoHtRwp/tuFGZnXAeLz4Qky2gI3y1oe1HWbFk5TbYs192NBvfy8BrI S2DgQRc3RuSN5Kv9Rfu7/n18erdy9+vxkLYHsgbN1AESLmuQWl55JWBsAQkkOq79R2jL a9fhbci5uQZDHS+6Kd2dcPj0l6wOeX9I4F8cAC5dnRknJON4MSvKkfLoi3nezbj8utBF S16RrD+GRLXnor7sFrvkgouI4gXNmG4m8DQcJGQuLzWvXw3u7OJuzydVhO+ai04dDp+H PZvQ== 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=0fLcL6Se/Dki1X8TEMGzoVU3A36vkkDwDLOh4ZB5lSg=; b=Icr6CdaJOxUhAwoyupkyD4CRL8FoxebtLRBhlQ0nWJquhqAKU0v2g2SNXYXJ46rZe9 vLnYJboh8pWYZwX0NfHDiMeVkxBBZFbDybr6e1U8XnExlhFsKJmDdZcQmCwLdN++DYqk Ly1PCO2UnKkFbEIi5MkLybBbNznCaZV1qKNOZLsole4IciB78DcBKI7at99/e+prEVOC /t56AncyGF8L2sMFwCu0xzW0pKnH59SUBmcERIoopdcmfwwfWGUTYpFjbpWixCV8cPq0 qtuk95Xz4cPBMa4qVOyO72dWchcGSoLACgN/Dav97fZKY9qCsweBAGSKBGv+6oNlbtn9 6rgQ== X-Gm-Message-State: AElRT7Exzqgo7wIIDRNECSi5153pfiqucfVYf7wgget2PFukZ88ZBaE8 IY4c+KOKekE0JF3N6kQenKKmwsBN X-Google-Smtp-Source: AG47ELvKdAUcu7GoDp4QFml1g0oGkoMMss6VlktgXBpfMFuW3NbKw9GA8IAgwH3ak6zwXeWfz9wNsw== X-Received: by 10.223.161.195 with SMTP id v3mr1958153wrv.184.1520981323795; Tue, 13 Mar 2018 15:48:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 23:47:17 +0100 Message-Id: <20180313224719.4954-68-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::242 Subject: [Qemu-devel] [PULL 67/69] replay: save vmstate of the asynchronous events 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk This patch fixes saving and loading the snapshots in the replay mode. It is required for the snapshots created in the moment when the header of the asynchronous event is read. This information was not saved in the snapshot. After loading the vmstate replay continued with the file offs= et passed the event header. The event header is lost in this case and replay hangs. Signed-off-by: Pavel Dovgalyuk Message-Id: <20180227095322.1060.53929.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini --- replay/replay-events.c | 44 +++++++++++++++++++++----------------------- replay/replay-internal.h | 6 ++++++ replay/replay-snapshot.c | 3 +++ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/replay/replay-events.c b/replay/replay-events.c index 3d5fc8a479..707de3867b 100644 --- a/replay/replay-events.c +++ b/replay/replay-events.c @@ -27,10 +27,6 @@ typedef struct Event { } Event; =20 static QTAILQ_HEAD(, Event) events_list =3D QTAILQ_HEAD_INITIALIZER(events= _list); -static unsigned int read_event_kind =3D -1; -static uint64_t read_id =3D -1; -static int read_checkpoint =3D -1; - static bool events_enabled; =20 /* Functions */ @@ -218,58 +214,60 @@ void replay_save_events(int checkpoint) static Event *replay_read_event(int checkpoint) { Event *event; - if (read_event_kind =3D=3D -1) { - read_checkpoint =3D replay_get_byte(); - read_event_kind =3D replay_get_byte(); - read_id =3D -1; + if (replay_state.read_event_kind =3D=3D -1) { + replay_state.read_event_checkpoint =3D replay_get_byte(); + replay_state.read_event_kind =3D replay_get_byte(); + replay_state.read_event_id =3D -1; replay_check_error(); } =20 - if (checkpoint !=3D read_checkpoint) { + if (checkpoint !=3D replay_state.read_event_checkpoint) { return NULL; } =20 /* Events that has not to be in the queue */ - switch (read_event_kind) { + switch (replay_state.read_event_kind) { case REPLAY_ASYNC_EVENT_BH: - if (read_id =3D=3D -1) { - read_id =3D replay_get_qword(); + if (replay_state.read_event_id =3D=3D -1) { + replay_state.read_event_id =3D replay_get_qword(); } break; case REPLAY_ASYNC_EVENT_INPUT: event =3D g_malloc0(sizeof(Event)); - event->event_kind =3D read_event_kind; + event->event_kind =3D replay_state.read_event_kind; event->opaque =3D replay_read_input_event(); return event; case REPLAY_ASYNC_EVENT_INPUT_SYNC: event =3D g_malloc0(sizeof(Event)); - event->event_kind =3D read_event_kind; + event->event_kind =3D replay_state.read_event_kind; event->opaque =3D 0; return event; case REPLAY_ASYNC_EVENT_CHAR_READ: event =3D g_malloc0(sizeof(Event)); - event->event_kind =3D read_event_kind; + event->event_kind =3D replay_state.read_event_kind; event->opaque =3D replay_event_char_read_load(); return event; case REPLAY_ASYNC_EVENT_BLOCK: - if (read_id =3D=3D -1) { - read_id =3D replay_get_qword(); + if (replay_state.read_event_id =3D=3D -1) { + replay_state.read_event_id =3D replay_get_qword(); } break; case REPLAY_ASYNC_EVENT_NET: event =3D g_malloc0(sizeof(Event)); - event->event_kind =3D read_event_kind; + event->event_kind =3D replay_state.read_event_kind; event->opaque =3D replay_event_net_load(); return event; default: - error_report("Unknown ID %d of replay event", read_event_kind); + error_report("Unknown ID %d of replay event", + replay_state.read_event_kind); exit(1); break; } =20 QTAILQ_FOREACH(event, &events_list, events) { - if (event->event_kind =3D=3D read_event_kind - && (read_id =3D=3D -1 || read_id =3D=3D event->id)) { + if (event->event_kind =3D=3D replay_state.read_event_kind + && (replay_state.read_event_id =3D=3D -1 + || replay_state.read_event_id =3D=3D event->id)) { break; } } @@ -295,7 +293,7 @@ void replay_read_events(int checkpoint) break; } replay_finish_event(); - read_event_kind =3D -1; + replay_state.read_event_kind =3D -1; replay_run_event(event); =20 g_free(event); @@ -304,7 +302,7 @@ void replay_read_events(int checkpoint) =20 void replay_init_events(void) { - read_event_kind =3D -1; + replay_state.read_event_kind =3D -1; } =20 void replay_finish_events(void) diff --git a/replay/replay-internal.h b/replay/replay-internal.h index d4037058e4..ac4b27b674 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -80,6 +80,12 @@ typedef struct ReplayState { uint64_t block_request_id; /*! Prior value of the host clock */ uint64_t host_clock_last; + /*! Asynchronous event type read from the log */ + int32_t read_event_kind; + /*! Asynchronous event id read from the log */ + uint64_t read_event_id; + /*! Asynchronous event checkpoint id read from the log */ + int32_t read_event_checkpoint; } ReplayState; extern ReplayState replay_state; =20 diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c index e0b2204765..2ab85cfc60 100644 --- a/replay/replay-snapshot.c +++ b/replay/replay-snapshot.c @@ -57,6 +57,9 @@ static const VMStateDescription vmstate_replay =3D { VMSTATE_UINT64(file_offset, ReplayState), VMSTATE_UINT64(block_request_id, ReplayState), VMSTATE_UINT64(host_clock_last, ReplayState), + VMSTATE_INT32(read_event_kind, ReplayState), + VMSTATE_UINT64(read_event_id, ReplayState), + VMSTATE_INT32(read_event_checkpoint, ReplayState), VMSTATE_END_OF_LIST() }, }; --=20 2.14.3