From patchwork Mon Jun 20 13:38:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gollub X-Patchwork-Id: 897442 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5KDkFmk024258 for ; Mon, 20 Jun 2011 13:46:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754743Ab1FTNqD (ORCPT ); Mon, 20 Jun 2011 09:46:03 -0400 Received: from schattenjagd.systems.b1-systems.de ([217.11.58.34]:36578 "EHLO mx1.b1-systems.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754401Ab1FTNp4 (ORCPT ); Mon, 20 Jun 2011 09:45:56 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 20 Jun 2011 13:46:16 +0000 (UTC) X-Greylist: delayed 337 seconds by postgrey-1.27 at vger.kernel.org; Mon, 20 Jun 2011 09:45:56 EDT Received: from marvin.site (ppp-88-217-124-96.dynamic.mnet-online.de [88.217.124.96]) by mx1.b1-systems.de (Postfix) with ESMTPSA id 75EDF4075; Mon, 20 Jun 2011 15:40:18 +0200 (CEST) From: Daniel Gollub To: kvm@vger.kernel.org Cc: Daniel Gollub Subject: [PATCH 2/2] Call KVM_HC_PANIC if guest panics Date: Mon, 20 Jun 2011 15:38:14 +0200 Message-Id: <1308577094-17551-3-git-send-email-gollub@b1-systems.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308577094-17551-1-git-send-email-gollub@b1-systems.de> References: <1308577094-17551-1-git-send-email-gollub@b1-systems.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Call KVM hypercall KVM_HC_PANIC if guest kernel calls panic() to signal the host that the guest paniced. Depends on CONFIG_KVM_GUEST set. Signed-off-by: Daniel Gollub --- arch/x86/kernel/kvm.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 33c07b0..f3c7d34 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -534,6 +534,20 @@ static void __init kvm_apf_trap_init(void) set_intr_gate(14, &async_page_fault); } +static int kvm_guest_panic(struct notifier_block *nb, unsigned long l, void *p) +{ + kvm_hypercall0(KVM_HC_PANIC); + return NOTIFY_DONE; +} + +static struct notifier_block kvm_guest_paniced = { + .notifier_call = kvm_guest_panic +}; + +static void kvm_guest_panic_handler_init(void) { + atomic_notifier_chain_register(&panic_notifier_list, &kvm_guest_paniced); +} + void __init kvm_guest_init(void) { int i; @@ -541,6 +555,8 @@ void __init kvm_guest_init(void) if (!kvm_para_available()) return; + kvm_guest_panic_handler_init(); + paravirt_ops_setup(); register_reboot_notifier(&kvm_pv_reboot_nb); for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)