From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gregory Haskins Subject: Re: [PATCH v8] qemu-kvm: add irqfd support Date: Tue, 02 Jun 2009 11:48:17 -0400 Message-ID: <4A2549C1.70703@novell.com> References: <20090602154233.30489.81627.stgit@dev.haskins.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig5A10D50E0ED9A99431D759C7" Cc: kvm@vger.kernel.org, avi@redhat.com To: unlisted-recipients:; (no To-header on input) Return-path: Received: from victor.provo.novell.com ([137.65.250.26]:35834 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752279AbZFBPsV (ORCPT ); Tue, 2 Jun 2009 11:48:21 -0400 In-Reply-To: <20090602154233.30489.81627.stgit@dev.haskins.net> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5A10D50E0ED9A99431D759C7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Gregory Haskins wrote: > irqfd lets you create an eventfd based file-desriptor to inject interru= pts > to a kvm guest. We associate one gsi per fd for fine-grained routing. > > [note: this is meant to work in conjunction with the POLLHUP version of= > irqfd, which has not yet been accepted into kvm.git] > > [ Changelog: > > v8: > *) removed deassign() verb in favor of POLLHUP support on close= () > *) only include sys/eventfd.h if CAP_IRQFD is defined to proper= ly > support older kernels > *) s/ENOENT/ENOSYS > ]=20 > =20 Hmm..it would appear I already released a 'v8' in the past. :( In any case, this is the latest version to consider -Greg > Signed-off-by: Gregory Haskins > --- > > kvm/libkvm/libkvm.c | 49 +++++++++++++++++++++++++++++++++++++++++++= ++++++ > kvm/libkvm/libkvm.h | 14 ++++++++++++++ > 2 files changed, 63 insertions(+), 0 deletions(-) > > diff --git a/kvm/libkvm/libkvm.c b/kvm/libkvm/libkvm.c > index ba0a5d1..10cb2ac 100644 > --- a/kvm/libkvm/libkvm.c > +++ b/kvm/libkvm/libkvm.c > @@ -1444,3 +1444,52 @@ int kvm_assign_set_msix_entry(kvm_context_t kvm,= > return ret; > } > #endif > + > +#ifdef KVM_CAP_IRQFD > + > +#include > + > +static int _kvm_irqfd(kvm_context_t kvm, int fd, int gsi, int flags) > +{ > + int r; > + struct kvm_irqfd data =3D { > + .fd =3D fd, > + .gsi =3D gsi, > + .flags =3D flags, > + }; > + > + r =3D ioctl(kvm->vm_fd, KVM_IRQFD, &data); > + if (r =3D=3D -1) > + r =3D -errno; > + return r; > +} > + > +int kvm_irqfd(kvm_context_t kvm, int gsi, int flags) > +{ > + int r; > + int fd; > + > + if (!kvm_check_extension(kvm, KVM_CAP_IRQFD)) > + return -ENOENT; > + > + fd =3D eventfd(0, 0); > + if (fd < 0) > + return -errno; > + > + r =3D _kvm_irqfd(kvm, fd, gsi, 0); > + if (r < 0) { > + close(fd); > + return -errno; > + } > + > + return fd; > +} > + > +#else /* KVM_CAP_IRQFD */ > + > +int kvm_irqfd(kvm_context_t kvm, int gsi, int flags) > +{ > + return -ENOSYS; > +} > + > +#endif /* KVM_CAP_IRQFD */ > diff --git a/kvm/libkvm/libkvm.h b/kvm/libkvm/libkvm.h > index 4821a1e..aca8ed6 100644 > --- a/kvm/libkvm/libkvm.h > +++ b/kvm/libkvm/libkvm.h > @@ -856,6 +856,20 @@ int kvm_commit_irq_routes(kvm_context_t kvm); > */ > int kvm_get_irq_route_gsi(kvm_context_t kvm); > =20 > +/*! > + * \brief Create a file descriptor for injecting interrupts > + * > + * Creates an eventfd based file-descriptor that maps to a specific GS= I > + * in the guest. eventfd compliant signaling (write() from userspace,= or > + * eventfd_signal() from kernelspace) will cause the GSI to inject > + * itself into the guest at the next available window. > + * > + * \param kvm Pointer to the current kvm_context > + * \param gsi GSI to assign to this fd > + * \param flags reserved, must be zero > + */ > +int kvm_irqfd(kvm_context_t kvm, int gsi, int flags); > + > #ifdef KVM_CAP_DEVICE_MSIX > int kvm_assign_set_msix_nr(kvm_context_t kvm, > struct kvm_assigned_msix_nr *msix_nr); > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > =20 --------------enig5A10D50E0ED9A99431D759C7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkolScQACgkQlOSOBdgZUxkjYwCggmd5SI+wVdXKe26qrL15O+YJ J4wAnjRlvyTOk7uTzaTSOIoMFRcXGrpv =k070 -----END PGP SIGNATURE----- --------------enig5A10D50E0ED9A99431D759C7--