From patchwork Fri May 5 19:38:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9714319 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 35DC7602B9 for ; Fri, 5 May 2017 19:41:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25D11286B3 for ; Fri, 5 May 2017 19:41:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A5FA286B8; Fri, 5 May 2017 19:41:37 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 AF96D286B3 for ; Fri, 5 May 2017 19:41:36 +0000 (UTC) Received: from localhost ([::1]:48687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6j6d-0006TU-Te for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 May 2017 15:41:35 -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) 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 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) 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 = 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 = 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 = 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 == REPLAY_MODE_RECORD) { replay_mutex_lock(); - replay_put_event(EVENT_SHUTDOWN); + replay_put_event(EVENT_SHUTDOWN + cause); replay_mutex_unlock(); } }