From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NUpKi-0002fp-Ms for qemu-devel@nongnu.org; Tue, 12 Jan 2010 17:35:28 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NUpKd-0002cX-VV for qemu-devel@nongnu.org; Tue, 12 Jan 2010 17:35:28 -0500 Received: from [199.232.76.173] (port=38459 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUpKd-0002cO-Ls for qemu-devel@nongnu.org; Tue, 12 Jan 2010 17:35:23 -0500 Received: from mail-qy0-f199.google.com ([209.85.221.199]:60094) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NUpKd-0004ac-60 for qemu-devel@nongnu.org; Tue, 12 Jan 2010 17:35:23 -0500 Received: by qyk37 with SMTP id 37so9665734qyk.18 for ; Tue, 12 Jan 2010 14:35:19 -0800 (PST) Message-ID: <4B4CF925.80602@codemonkey.ws> Date: Tue, 12 Jan 2010 16:35:17 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <20100111171703.GC11936@redhat.com> In-Reply-To: <20100111171703.GC11936@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH-RFC 02/13] kvm: add API to set ioeventfd List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org On 01/11/2010 11:17 AM, Michael S. Tsirkin wrote: > Signed-off-by: Michael S. Tsirkin > --- > kvm-all.c | 24 ++++++++++++++++++++++++ > kvm.h | 3 +++ > 2 files changed, 27 insertions(+), 0 deletions(-) > > diff --git a/kvm-all.c b/kvm-all.c > index a312654..aa00119 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -1113,3 +1113,27 @@ void kvm_remove_all_breakpoints(CPUState *current_env) > { > } > #endif /* !KVM_CAP_SET_GUEST_DEBUG */ > + > +#ifdef KVM_IOEVENTFD > +int kvm_set_ioeventfd(uint16_t addr, uint16_t data, int fd, bool assigned) > +{ > + struct kvm_ioeventfd kick = { > + .datamatch = data, > + .addr = addr, > + .len = 2, > + .flags = KVM_IOEVENTFD_FLAG_DATAMATCH | KVM_IOEVENTFD_FLAG_PIO, > + .fd = fd, > + }; > + if (!assigned) > + kick.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN; > + int r = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD,&kick); > + if (r< 0) > + return r; > + return 0; > +} > I think we really ought to try to avoid having global state used here. That means either we need to pass a CPUState to this function or we need to have a ioeventfd be allocated as a structure that is then passed around that can store a copy of the kvm_state fetched through CPUState. I think the later is best. We really don't want ioeventfd scattered throughout the code. Regards, Anthony Liguori