From nobody Tue Sep 30 03:46:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561107242; cv=none; d=zoho.com; s=zohoarc; b=ghw8AFjSG8fn8CfM4htL26qXYAds/PXwsSpErqiBVO2gBjj4fD9KCvoCYwWwmueov5mfhYQKJNRVz2P71c+WQYURJR4VOeSOcoVRJcpPmS+4VCyAEOagfTNjUfHONsZKws/K9i17YSy9idfyGlgL79WbmbFWK+1N8PtfHlxpsno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561107242; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kePnnXJ3/7sBB5+ePYEMA6YymK/SmarhgKfn9hSoVBQ=; b=gl3IdqYILmyZRDjHchbdaw1TYTgjrdWCV19BvFNSzzUUOJ48XMRGz42AKXC4IquObhD33CKOk0kr9DzuL5vZfKDAI2yaCq55NRUqto2Hxz181//3WrdFRBLPhPZmiipBPAspHLgzuaWAieYBDoWrSlrngzqUvTVvanpV/XygwYY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561107242178259.4949179388535; Fri, 21 Jun 2019 01:54:02 -0700 (PDT) Received: from localhost ([::1]:55594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heFJ1-0008UJ-6N for importer@patchew.org; Fri, 21 Jun 2019 04:53:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58714) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heEzd-0004U0-SI for qemu-devel@nongnu.org; Fri, 21 Jun 2019 04:33:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1heEnD-0000EA-RU for qemu-devel@nongnu.org; Fri, 21 Jun 2019 04:21:08 -0400 Received: from mail.ispras.ru ([83.149.199.45]:41318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1heEnD-0000Du-HP for qemu-devel@nongnu.org; Fri, 21 Jun 2019 04:21:07 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id AD9DE54008C; Fri, 21 Jun 2019 11:21:06 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Fri, 21 Jun 2019 11:21:06 +0300 Message-ID: <156110526652.25431.1704646168245762049.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156110523748.25431.9310430853468653085.stgit@pasha-Precision-3630-Tower> References: <156110523748.25431.9310430853468653085.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH for-4.1 05/24] replay: don't drain/flush bdrv queue while RR is working X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk In record/replay mode bdrv queue is controlled by replay mechanism. It does not allow saving or loading the snapshots when bdrv queue is not empty. Stopping the VM is not blocked by nonempty queue, but flushing the queue is still impossible there, because it may cause deadlocks in replay mode. This patch disables bdrv_drain_all and bdrv_flush_all in record/replay mode. Stopping the machine when the IO requests are not finished is needed for the debugging. E.g., breakpoint may be set at the specified step, and forcing the IO requests to finish may break the determinism of the execution. Signed-off-by: Pavel Dovgalyuk Acked-by: Kevin Wolf --- block/io.c | 28 ++++++++++++++++++++++++++++ cpus.c | 2 -- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 9ba1bada36..607abc04b0 100644 --- a/block/io.c +++ b/block/io.c @@ -32,6 +32,7 @@ #include "qemu/cutils.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "sysemu/replay.h" =20 #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progr= ess */ =20 @@ -539,6 +540,15 @@ void bdrv_drain_all_begin(void) return; } =20 + /* + * bdrv queue is managed by record/replay, + * waiting for finishing the I/O requests may + * be infinite + */ + if (replay_events_enabled()) { + return; + } + /* AIO_WAIT_WHILE() with a NULL context can only be called from the ma= in * loop AioContext, so make sure we're in the main context. */ assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); @@ -567,6 +577,15 @@ void bdrv_drain_all_end(void) { BlockDriverState *bs =3D NULL; =20 + /* + * bdrv queue is managed by record/replay, + * waiting for finishing the I/O requests may + * be endless + */ + if (replay_events_enabled()) { + return; + } + while ((bs =3D bdrv_next_all_states(bs))) { AioContext *aio_context =3D bdrv_get_aio_context(bs); =20 @@ -1934,6 +1953,15 @@ int bdrv_flush_all(void) BlockDriverState *bs =3D NULL; int result =3D 0; =20 + /* + * bdrv queue is managed by record/replay, + * creating new flush request for stopping + * the VM may break the determinism + */ + if (replay_events_enabled()) { + return result; + } + for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { AioContext *aio_context =3D bdrv_get_aio_context(bs); int ret; diff --git a/cpus.c b/cpus.c index dde3b7b981..0a44253523 100644 --- a/cpus.c +++ b/cpus.c @@ -1083,7 +1083,6 @@ static int do_vm_stop(RunState state, bool send_stop) } =20 bdrv_drain_all(); - replay_disable_events(); ret =3D bdrv_flush_all(); =20 return ret; @@ -2163,7 +2162,6 @@ int vm_prepare_start(void) /* We are sending this now, but the CPUs will be resumed shortly later= */ qapi_event_send_resume(); =20 - replay_enable_events(); cpu_enable_ticks(); runstate_set(RUN_STATE_RUNNING); vm_state_notify(1, RUN_STATE_RUNNING);