From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jike Song Subject: Re: [PATCH 1/2] KVM: page track: add a new notifier type: track_flush_slot Date: Fri, 14 Oct 2016 20:26:25 +0800 Message-ID: <5800CEF1.9050004@intel.com> 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: "Tian, Kevin" , Neo Jia , kvm@vger.kernel.org, guangrong.xiao@intel.com, Alex Williamson , Xiaoguang Chen , qemu-devel , Kirti Wankhede , Xiao Guangrong To: Paolo Bonzini Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org On 10/14/2016 06:43 PM, Paolo Bonzini wrote: > > > 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). Thanks for quick reply. I'll do some homework and report back :) -- Thanks, Jike