From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Recommended way access KVM data structures from other kernel subsystems ? Date: Mon, 03 Sep 2012 12:26:07 +0300 Message-ID: <504477AF.1070900@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "kvm@vger.kernel.org" To: "Pandarathil, Vijaymohan R" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35248 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756150Ab2ICJ0L (ORCPT ); Mon, 3 Sep 2012 05:26:11 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 08/23/2012 10:49 AM, Pandarathil, Vijaymohan R wrote: > Hi, > > I am looking for the recommended approach for accessing KVM driver data from other kernel components. In my case, I need to set some global variable/state in KVM driver from one of the NMI handlers. I see that using kvm_x86_ops is one option. I can define a new function as part of kvm_x86_ops and invoke that function from the NMI handler as below. > > nmi_handler() { > > ... > If (kvm_x86_ops) { > kvm_x86_ops->new_fn(); > > } > > after adding new_func() to struct kvm_x86_ops. > > Is this the right approach ? No, kvm_x86_ops is not available to the core kernel code. > Or is there some other existing mechanism ? Is KVM driver always loaded ? No. > I am fairly new to KVM and so any guidance is very much appreciated. Do something like void nmi_xyz_register(struct nmi_xyz *x); void nmi_xyz_unregister(struct nmi_xyz *x); struct nmi_xyz { void (*nmi)(void); }; then add code to kvm to use nmi_xyz (whatever that is). -- error compiling committee.c: too many arguments to function