From nobody Thu May 2 20:41:30 2024 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 1488809210826920.2324429531751; Mon, 6 Mar 2017 06:06:50 -0800 (PST) Received: from localhost ([::1]:44070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cktHh-0001Ng-LQ for importer@patchew.org; Mon, 06 Mar 2017 09:06:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cktHA-0001NX-3C for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:06:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cktH5-0000Xf-BX for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:06:12 -0500 Received: from [45.249.212.187] (port=2995 helo=dggrg01-dlp.huawei.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cktH4-0000UG-Ga for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:06:07 -0500 Received: from 172.30.72.57 (EHLO DGGEML403-HUB.china.huawei.com) ([172.30.72.57]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AKI89318; Mon, 06 Mar 2017 22:05:54 +0800 (CST) Received: from localhost (10.177.23.7) by DGGEML403-HUB.china.huawei.com (10.3.17.33) with Microsoft SMTP Server id 14.3.301.0; Mon, 6 Mar 2017 22:05:42 +0800 From: hangaohuai To: Date: Mon, 6 Mar 2017 22:05:41 +0800 Message-ID: <20170306140541.10600-1-hangaohuai@huawei.com> X-Mailer: git-send-email 2.8.3.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.23.7] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.58BD6CC3.0136, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 47f7d4531a32c205ff835a44fd98302c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.187 Subject: [Qemu-devel] [PATCH] Fix the vm state after vm migration when vm panic 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: pbonzini@redhat.com, hangaohuai@huawei.com, arei.gonglei@huawei.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 Content-Type: text/plain; charset="utf-8" Bug steps: 1. windows VM with pvpanic device:in xml 2. inject the panic in windows, the vm state is paused (guest-panicked) 3. migrate the vm to other host, vm state is running Check the vmstate before runstate_set(RUN_STATE_RUNNING) Signed-off-by: hangaohuai --- cpus.c | 3 +++ include/sysemu/sysemu.h | 1 + vl.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/cpus.c b/cpus.c index c857ad2..37b93aa 100644 --- a/cpus.c +++ b/cpus.c @@ -1734,6 +1734,9 @@ int vm_prepare_start(void) if (runstate_is_running()) { qapi_event_send_stop(&error_abort); res =3D -1; + } else if (runstate_is_paniced()) { + qemu_system_guest_panicked(NULL); + res =3D -1; } else { replay_enable_events(); cpu_enable_ticks(); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 576c7ce..08015c7 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -23,6 +23,7 @@ extern bool qemu_uuid_set; bool runstate_check(RunState state); void runstate_set(RunState new_state); int runstate_is_running(void); +int runstate_is_paniced(void); bool runstate_needs_reset(void); bool runstate_store(char *str, size_t size); typedef struct vm_change_state_entry VMChangeStateEntry; diff --git a/vl.c b/vl.c index 16a3b5e..ea7e3f8 100644 --- a/vl.c +++ b/vl.c @@ -729,6 +729,11 @@ int runstate_is_running(void) return runstate_check(RUN_STATE_RUNNING); } =20 +int runstate_is_paniced(void) +{ + return runstate_check(RUN_STATE_GUEST_PANICKED); +} + bool runstate_needs_reset(void) { return runstate_check(RUN_STATE_INTERNAL_ERROR) || --=20 1.8.3.1