From patchwork Tue Nov 3 06:58:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xulei (Stone, Euler)" X-Patchwork-Id: 539453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6463214090A for ; Wed, 4 Nov 2015 01:55:41 +1100 (AEDT) Received: from localhost ([::1]:49186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztczr-0005Vm-Ey for incoming@patchwork.ozlabs.org; Tue, 03 Nov 2015 09:55:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtVY6-0001xp-VC for qemu-devel@nongnu.org; Tue, 03 Nov 2015 01:58:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtVY2-0005EP-47 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 01:58:30 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:33670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtVY1-0005D0-3l for qemu-devel@nongnu.org; Tue, 03 Nov 2015 01:58:26 -0500 Received: from 172.24.1.48 (EHLO SZXEMI404-HUB.china.huawei.com) ([172.24.1.48]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CYK24990; Tue, 03 Nov 2015 14:58:16 +0800 (CST) Received: from SZXEMI504-MBS.china.huawei.com ([169.254.1.13]) by SZXEMI404-HUB.china.huawei.com ([10.82.75.40]) with mapi id 14.03.0235.001; Tue, 3 Nov 2015 14:58:08 +0800 From: "Xulei (Stone, Euler)" To: qemu-devel Thread-Topic: [Qemu-devel][PATCH] SeaBios: Fix reset procedure reentrancy problem on qemu-kvm platform Thread-Index: AdEWBNxFmMBl7ljrSPytxKd+2kCYHA== Date: Tue, 3 Nov 2015 06:58:07 +0000 Message-ID: <8E78D212B8C25246BE4CE7EA0E645FE5291A08@SZXEMI504-MBS.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.254.96] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.56385B09.0069,ss=1,re=0.000,fgs=0, ip=169.254.1.13, so=2013-06-18 04:22:30, dmn=2011-05-27 18:58:46 X-Mirapoint-Loop-Id: ff8f806ffa246b59a24a4871583c4bd8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 X-Mailman-Approved-At: Tue, 03 Nov 2015 09:53:13 -0500 Cc: "wangxin \(U\)" , "Gonglei \(Arei\)" , "Huangweidong \(C\)" Subject: [Qemu-devel] [PATCH] SeaBios: Fix reset procedure reentrancy problem on qemu-kvm platform X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Xulei \(Stone, Euler\)" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On qemu-kvm platform, when I reset a VM through "virsh reset", and coincidently the VM is in process of internal rebooting at the same time. Then the VM will not be successfully reseted any more due to the reset reentrancy. I found: (1)SeaBios try to shutdown the VM after reseting it failed by apm_shutdown(). However, apm_shutdown() does not work on qemu-kvm platform; (2)I add 1s sleep in qemu_prep_reset(), then continuously reset the VM twice, aforementioned case must happen. This patch fixes this issue by letting the VM always execute the reboot routing while a reenrancy happenes instead of attempting apm_shutdown on qemu-kvm platform. Signed-off-by: Lei Xu --- roms/seabios/src/resume.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 1.7.12.4 diff --git a/roms/seabios/src/resume.c b/roms/seabios/src/resume.c index 1903174..96ff79e 100644 --- a/roms/seabios/src/resume.c +++ b/roms/seabios/src/resume.c @@ -16,6 +16,7 @@ #include "std/bda.h" // struct bios_data_area_s #include "string.h" // memset #include "util.h" // dma_setup +#include "fw/paravirt.h" //runningOnKVM // Handler for post calls that look like a resume. void VISIBLE16 @@ -122,7 +123,11 @@ tryReboot(void) dprintf(1, "Unable to hard-reboot machine - attempting shutdown.\n"); apm_shutdown(); } - HaveAttemptedReboot = 1; + if (!runningOnKVM()) { + // Hard reboot has failed - try to shutdown machine. + HaveAttemptedReboot = 1; + } + dprintf(1, "Attempting a hard reboot\n");