From patchwork Thu Oct 14 08:42:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jin Dongming X-Patchwork-Id: 67793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 87FEDB70DD for ; Thu, 14 Oct 2010 19:46:20 +1100 (EST) Received: from localhost ([127.0.0.1]:40591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P6JS5-0007WZ-8T for incoming@patchwork.ozlabs.org; Thu, 14 Oct 2010 04:46:17 -0400 Received: from [140.186.70.92] (port=59774 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P6JNS-0005gH-7K for qemu-devel@nongnu.org; Thu, 14 Oct 2010 04:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P6JNR-0002Py-5K for qemu-devel@nongnu.org; Thu, 14 Oct 2010 04:41:30 -0400 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:40935) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P6JNQ-0002Pu-MS for qemu-devel@nongnu.org; Thu, 14 Oct 2010 04:41:29 -0400 Received: from m1.gw.fujitsu.co.jp ([10.0.50.71]) by fgwmail7.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o9E8fRDU029488 for (envelope-from jin.dongming@np.css.fujitsu.com); Thu, 14 Oct 2010 17:41:27 +0900 Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 3671C45DE4E for ; Thu, 14 Oct 2010 17:41:27 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.fujitsu.co.jp [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 1428345DE4D for ; Thu, 14 Oct 2010 17:41:27 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id F35CA1DB8045 for ; Thu, 14 Oct 2010 17:41:26 +0900 (JST) Received: from m001.s.css.fujitsu.com (m001.s.css.fujitsu.com [10.23.4.39]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id B74E61DB803C for ; Thu, 14 Oct 2010 17:41:26 +0900 (JST) Received: from m001.css.fujitsu.com (m001 [127.0.0.1]) by m001.s.css.fujitsu.com (Postfix) with ESMTP id 9D27250EBE3; Thu, 14 Oct 2010 17:41:26 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.101.76]) by m001.s.css.fujitsu.com (Postfix) with ESMTP id 6305E50EBC5; Thu, 14 Oct 2010 17:41:26 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.5.1 Message-ID: <4CB6C28C.4050902@np.css.fujitsu.com> Date: Thu, 14 Oct 2010 17:42:52 +0900 From: Jin Dongming User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ja; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1 MIME-Version: 1.0 To: KVM list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Hidetoshi Seto , Dean Nelson , Marcelo Tosatti , "qemu-devel@nongnu.org" , Avi Kivity , Huang Ying Subject: [Qemu-devel] [PATCH 02/11] kvm, x86: introduce kvm_do_set_mce X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Share the same error handling. Signed-off-by: Hidetoshi Seto Tested-by: Jin Dongming --- qemu-kvm.c | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 6f62973..1338e99 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1130,6 +1130,22 @@ static void sigbus_reraise(void) abort(); } +#if defined(KVM_CAP_MCE) && defined(TARGET_I386) +static void kvm_do_set_mce(CPUState *env, struct kvm_x86_mce *mce, + int abort_on_error) +{ + int r; + + r = kvm_set_mce(env, mce); + if (r < 0) { + perror("kvm_set_mce FAILED"); + if (abort_on_error) { + abort(); + } + } +} +#endif + static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo, void *ctx) { @@ -1365,11 +1381,7 @@ static void kvm_on_sigbus(CPUState *env, siginfo_t *siginfo) } } mce.addr = paddr; - r = kvm_set_mce(env, &mce); - if (r < 0) { - fprintf(stderr, "kvm_set_mce: %s\n", strerror(errno)); - abort(); - } + kvm_do_set_mce(env, &mce, 1); } else #endif { @@ -1913,13 +1925,8 @@ static void kvm_do_inject_x86_mce(void *_data) return; } } - r = kvm_set_mce(data->env, data->mce); - if (r < 0) { - perror("kvm_set_mce FAILED"); - if (data->abort_on_error) { - abort(); - } - } + + kvm_do_set_mce(data->env, data->mce, data->abort_on_error); } #endif