From nobody Tue Dec 16 05:37:34 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 15209835908781002.7581436280348; Tue, 13 Mar 2018 16:26:30 -0700 (PDT) Received: from localhost ([::1]:43495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtJO-0000Qu-2B for importer@patchew.org; Tue, 13 Mar 2018 19:26:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evsig-0006KH-6U 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 1evsic-00045f-JP for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:34 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:33477) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evsic-00045E-D9 for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:30 -0400 Received: by mail-wr0-x242.google.com with SMTP id r8so2595534wrg.0 for ; Tue, 13 Mar 2018 15:48:30 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 15:48:28 -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=pDGrlfPmR48s1TMPOVmA89rhSwylmN027JVypkJyjcE=; b=L31JhuGJAYz0qJVnRV3be4JwLYRp9lXaIlMs51lQr9sdvs7KngPhXGSGLrwMnJYhNl n1EILn63tMyigagNXGxUpXJFHuqj5EPIVr9g043uMlMi71tpUPOqMU4DNXCUtqstRwS4 MhI3rIrUfi9tU3cpla+Mvu0Biw4AMjNsvGCYRYVCIehqc+8K8tN6cZe3NjycDL4nG3cq F+5XjXPKot8Mg3ohmlsJq6r8hUS2fxyxdpiVjnc+TkplFtY3AXRqXC3wE7SltqBuG74p SLrf6bSyOGfFyPpGybiP4EwVmnZKIlv0Kkv+AjW0C+nwU2GeiFxBdPMdqPzzhRUwvrKr 31eA== 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=pDGrlfPmR48s1TMPOVmA89rhSwylmN027JVypkJyjcE=; b=XHhOE9WwpPcKrOSrROIgvHgb4htL8BkLsYs7Qwz+7xfM1RDKvAUQlVS0w/AKpkX7lM QpIwzsbxhm/i2yO1N12y6hi3dNhFrXb6R74CpWUnKQ3TyRAQB1FQrW2EetY9TluNZ4MJ ZePa72829Nih1C/s3PYojFVNMN7jisBe93ldg8iSFgNq5jPKpnqd9hrorVQbjH73jbSK IGJdKMGE89ItJJrDSeSlCaZnm5fjg/lsIw1bYyyPTXrYyLisoi9Wqgnnm58SjYOjyXyb 49naYlOA3S4WBEskB6jSQKvXZCSBehujAvS65N7leWaZgh3qK1oILve0Dx3bf8y+BKhk qZHQ== X-Gm-Message-State: AElRT7FjxAtR+V2GudPGz7TmULh50cQVi0EwJ7tvgURjxmlRXPiCRtSW ihMquj3YMTXLHHfdTkN/f+VmGoST X-Google-Smtp-Source: AG47ELsX7rGuEAqBR6GAyLYqxa9LnKLT0fqL0uLMZ0DwST/Kpo+rfvqfuqP4B/nq46P5OnlKDn0StA== X-Received: by 10.223.208.132 with SMTP id y4mr1812624wrh.185.1520981308963; Tue, 13 Mar 2018 15:48:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 23:47:05 +0100 Message-Id: <20180313224719.4954-56-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 55/69] replay: fix save/load vm for non-empty queue 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 does not allows saving/loading vmstate when replay events queue is not empty. There is no reliable way to save events queue, because it describes internal coroutine state. Therefore saving and loading operations should be deferred to another record/replay step. Signed-off-by: Pavel Dovgalyuk Message-Id: <20180227095214.1060.32939.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini Signed-off-by: Pavel Dovgalyuk --- include/sysemu/replay.h | 3 +++ migration/savevm.c | 13 +++++++++++++ replay/replay-snapshot.c | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index c0204e641c..401de12130 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -166,5 +166,8 @@ void replay_audio_in(int *recorded, void *samples, int = *wpos, int size); /*! Called at the start of execution. Loads or saves initial vmstate depending on execution mode. */ void replay_vmstate_init(void); +/*! Called to ensure that replay state is consistent and VM snapshot + can be created */ +bool replay_can_snapshot(void); =20 #endif diff --git a/migration/savevm.c b/migration/savevm.c index 358c5b51e2..fbeac658c1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -54,6 +54,7 @@ #include "qemu/cutils.h" #include "io/channel-buffer.h" #include "io/channel-file.h" +#include "sysemu/replay.h" =20 #ifndef ETH_P_RARP #define ETH_P_RARP 0x8035 @@ -2197,6 +2198,12 @@ int save_snapshot(const char *name, Error **errp) struct tm tm; AioContext *aio_context; =20 + if (!replay_can_snapshot()) { + error_report("Record/replay does not allow making snapshot " + "right now. Try once more later."); + return ret; + } + if (!bdrv_all_can_snapshot(&bs)) { error_setg(errp, "Device '%s' is writable but does not support " "snapshots", bdrv_get_device_name(bs)); @@ -2388,6 +2395,12 @@ int load_snapshot(const char *name, Error **errp) AioContext *aio_context; MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 + if (!replay_can_snapshot()) { + error_report("Record/replay does not allow loading snapshot " + "right now. Try once more later."); + return -EINVAL; + } + if (!bdrv_all_can_snapshot(&bs)) { error_setg(errp, "Device '%s' is writable but does not support snapshots= ", diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c index b2e10769a6..7075986ab5 100644 --- a/replay/replay-snapshot.c +++ b/replay/replay-snapshot.c @@ -83,3 +83,9 @@ void replay_vmstate_init(void) } } } + +bool replay_can_snapshot(void) +{ + return replay_mode =3D=3D REPLAY_MODE_NONE + || !replay_has_events(); +} --=20 2.14.3