From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 1/2] KVM: page track: add a new notifier type: track_flush_slot Date: Fri, 14 Oct 2016 12:43:00 +0200 Message-ID: References: <1475998904-13456-1-git-send-email-xiaoguang.chen@intel.com> <1475998904-13456-2-git-send-email-xiaoguang.chen@intel.com> <20161009083134.GA19090@nvidia.com> <20161010180140.GA27757@nvidia.com> <1259cdba-c137-c3da-abe2-ecf51aec6738@linux.intel.com> <523e1446-75f1-fe3a-d818-f7d238d57751@redhat.com> <5800B579.9000705@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Xiao Guangrong , Neo Jia , Xiaoguang Chen , kvm@vger.kernel.org, guangrong.xiao@intel.com, Kirti Wankhede , Alex Williamson , "Tian, Kevin" , qemu-devel To: Jike Song Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42634 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753912AbcJNKnG (ORCPT ); Fri, 14 Oct 2016 06:43:06 -0400 In-Reply-To: <5800B579.9000705@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 14/10/2016 12:37, Jike Song wrote: > Hi Paolo & Alex, > > IIUC, passing file descriptors means touching QEMU and the UAPI between > QEMU and VFIO. Would you guys have a look at below draft patch? If it's > on the correct direction, I'll send the split ones. Thanks! > > -- > Thanks, > Jike > > > diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c > index bec694c..f715d37 100644 > --- a/hw/vfio/pci-quirks.c > +++ b/hw/vfio/pci-quirks.c > @@ -10,12 +10,14 @@ > * the COPYING file in the top-level directory. > */ > > +#include > #include "qemu/osdep.h" > #include "qemu/error-report.h" > #include "qemu/range.h" > #include "qapi/error.h" > #include "hw/nvram/fw_cfg.h" > #include "pci.h" > +#include "sysemu/kvm.h" > #include "trace.h" > > /* Use uin32_t for vendor & device so PCI_ANY_ID expands and cannot match hw */ > @@ -1844,3 +1846,15 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev) > break; > } > } > + > +void vfio_quirk_kvmgt(VFIOPCIDevice *vdev) > +{ > + int vmfd; > + > + if (!kvm_enabled() || !vdev->kvmgt) > + return; > + > + /* Tell the device what KVM it attached */ > + vmfd = kvm_get_vmfd(kvm_state); > + ioctl(vdev->vbasedev.fd, VFIO_SET_KVMFD, vmfd); > +} vfio_kvm_device_add_group is already telling the group id file descriptor to KVM. You can use that existing hook (whose kernel side is virt/kvm/vfio.c). Paolo