From nobody Mon Feb 9 11:30:12 2026 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.zoho.com; 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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494013318345137.45623597433303; Fri, 5 May 2017 12:41:58 -0700 (PDT) Received: from localhost ([::1]:48701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6j6x-0007Kf-1L for importer@patchew.org; Fri, 05 May 2017 15:41:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6j3h-0004hA-Uq for qemu-devel@nongnu.org; Fri, 05 May 2017 15:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6j3e-0003wY-0w for qemu-devel@nongnu.org; Fri, 05 May 2017 15:38:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6j3d-0003vH-O3 for qemu-devel@nongnu.org; Fri, 05 May 2017 15:38:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB7B261B91; Fri, 5 May 2017 19:38:28 +0000 (UTC) Received: from red.redhat.com (ovpn-122-206.rdu2.redhat.com [10.10.122.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBB027981E; Fri, 5 May 2017 19:38:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AB7B261B91 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AB7B261B91 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 14:38:09 -0500 Message-Id: <20170505193810.2934-5-eblake@redhat.com> In-Reply-To: <20170505193810.2934-1-eblake@redhat.com> References: <20170505193810.2934-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 05 May 2017 19:38:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6 4/5] shutdown: Preserve shutdown cause through replay 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: Paolo Bonzini , armbru@redhat.com, Pavel Dovgalyuk , alistair.francis@xilinx.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With the recent addition of ShutdownCause, we want to be able to pass a cause through any shutdown request, and then faithfully replay that cause when later replaying the same sequence. The easiest way is to expand the reply event mechanism to track a series of values for EVENT_SHUTDOWN, one corresponding to each value of ShutdownCause. We are free to change the replay stream as needed, since there are already no guarantees about being able to use a replay stream by any other version of qemu than the one that generated it. Signed-off-by: Eric Blake --- v6: new patch --- include/sysemu/replay.h | 3 ++- include/sysemu/sysemu.h | 1 + replay/replay-internal.h | 3 ++- vl.c | 3 +-- replay/replay.c | 10 +++++----- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index f1c0712..fa14d0e 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -13,6 +13,7 @@ */ #include "qapi-types.h" +#include "sysemu.h" /* replay clock kinds */ enum ReplayClockKind { @@ -98,7 +99,7 @@ int64_t replay_read_clock(ReplayClockKind kind); /* Events */ /*! Called when qemu shutdown is requested. */ -void replay_shutdown_request(void); +void replay_shutdown_request(ShutdownCause cause); /*! Should be called at check points in the execution. These check points are skipped, if they were not met. Saves checkpoint in the SAVE mode and validates in the PLAY mode. diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 89d0e3e..e6d5e5f 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -50,6 +50,7 @@ enum ShutdownCause { turns that into a shutdown */ SHUTDOWN_CAUSE_GUEST_PANIC, /* Guest panicked, and command line turns that into a shutdown */ + SHUTDOWN_CAUSE__MAX, }; void vm_start(void); diff --git a/replay/replay-internal.h b/replay/replay-internal.h index ed66ed8..3ebb199 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -22,8 +22,9 @@ enum ReplayEvents { EVENT_EXCEPTION, /* for async events */ EVENT_ASYNC, - /* for shutdown request */ + /* for shutdown requests, range allows recovery of ShutdownCause */ EVENT_SHUTDOWN, + EVENT_SHUTDOWN_LAST =3D EVENT_SHUTDOWN + SHUTDOWN_CAUSE__MAX, /* for character device write event */ EVENT_CHAR_WRITE, /* for character device read all event */ diff --git a/vl.c b/vl.c index 9579d5f..0b73437 100644 --- a/vl.c +++ b/vl.c @@ -1821,8 +1821,7 @@ void qemu_system_killed(int signal, pid_t pid) void qemu_system_shutdown_request(ShutdownCause reason) { trace_qemu_system_shutdown_request(reason); - /* FIXME - add a parameter to let replay preserve reason */ - replay_shutdown_request(); + replay_shutdown_request(reason); shutdown_requested =3D reason; qemu_notify_event(); } diff --git a/replay/replay.c b/replay/replay.c index 604fa4f..ff58a5a 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -49,10 +49,10 @@ bool replay_next_event_is(int event) res =3D true; } switch (replay_state.data_kind) { - case EVENT_SHUTDOWN: + case EVENT_SHUTDOWN ... EVENT_SHUTDOWN_LAST: replay_finish_event(); - /* FIXME - store actual reason */ - qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); + qemu_system_shutdown_request(replay_state.data_kind - + EVENT_SHUTDOWN); break; default: /* clock, time_t, checkpoint and other events */ @@ -171,11 +171,11 @@ bool replay_has_interrupt(void) return res; } -void replay_shutdown_request(void) +void replay_shutdown_request(ShutdownCause cause) { if (replay_mode =3D=3D REPLAY_MODE_RECORD) { replay_mutex_lock(); - replay_put_event(EVENT_SHUTDOWN); + replay_put_event(EVENT_SHUTDOWN + cause); replay_mutex_unlock(); } } --=20 2.9.3