From patchwork Wed Nov 4 00:19:43 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: 539654 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 C3C9A141330 for ; Wed, 4 Nov 2015 11:20:28 +1100 (AEDT) Received: from localhost ([::1]:51792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtloQ-0001dA-Qp for incoming@patchwork.ozlabs.org; Tue, 03 Nov 2015 19:20:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztlo3-00016G-4J for qemu-devel@nongnu.org; Tue, 03 Nov 2015 19:20:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ztlnz-0007xG-Uz for qemu-devel@nongnu.org; Tue, 03 Nov 2015 19:20:03 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:62452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztlnz-0007u5-1B for qemu-devel@nongnu.org; Tue, 03 Nov 2015 19:19:59 -0500 Received: from 172.24.1.51 (EHLO SZXEMI413-HUB.china.huawei.com) ([172.24.1.51]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BQJ25585; Wed, 04 Nov 2015 08:19:54 +0800 (CST) Received: from SZXEMI504-MBS.china.huawei.com ([169.254.1.13]) by SZXEMI413-HUB.china.huawei.com ([10.86.210.41]) with mapi id 14.03.0235.001; Wed, 4 Nov 2015 08:19:43 +0800 From: "Xulei (Stone, Euler)" To: "qemu-devel@nongnu.org" Thread-Topic: [Qemu-devel][PATCH] SeaBios: Fix reset procedure reentrancy problem on qemu-kvm platform Thread-Index: AdEWlnpEJU/E5gLcSI6x68qwTc0jTA== Date: Wed, 4 Nov 2015 00:19:43 +0000 Message-ID: <8E78D212B8C25246BE4CE7EA0E645FE5295A5F@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.0A090201.56394F2A.0045, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.1.13, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 163266fb650ddaf8c6e3db9a19b3aa3a X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: "Xulei \(Stone, Euler\)" , "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");