Add this to support hot remove assigned device. Acked-by: Mark McLoughlin <markmc@xxxxxxxxxx> Signed-off-by: Weidong Han <weidong.han@xxxxxxxxx> --- libkvm/libkvm.c | 14 ++++++++++++++ libkvm/libkvm.h | 13 +++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index 92ffe10..a559a0d 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -1141,6 +1141,20 @@ int kvm_assign_irq(kvm_context_t kvm, } #endif +#ifdef KVM_CAP_DEVICE_DEASSIGNMENT +int kvm_deassign_pci_device(kvm_context_t kvm, + struct kvm_assigned_pci_dev *assigned_dev) +{ + int ret; + + ret = ioctl(kvm->vm_fd, KVM_DEASSIGN_PCI_DEVICE, assigned_dev); + if (ret < 0) + return -errno; + + return ret; +} +#endif + int kvm_destroy_memory_region_works(kvm_context_t kvm) { int ret = 0; diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h index e79e4fd..f6d653c 100644 --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -737,6 +737,19 @@ int kvm_assign_irq(kvm_context_t kvm, int kvm_destroy_memory_region_works(kvm_context_t kvm); #endif +#ifdef KVM_CAP_DEVICE_DEASSIGNMENT +/*! + * \brief Notifies host kernel about a PCI device to be deassigned from a guest + * + * Used for hot remove PCI device, this function notifies the host + * kernel about the deassigning of the physical PCI device from a guest. + * + * \param kvm Pointer to the current kvm_context + * \param assigned_dev Parameters, like bus, devfn number, etc + */ +int kvm_deassign_pci_device(kvm_context_t kvm, + struct kvm_assigned_pci_dev *assigned_dev); +#endif /*! * \brief Checks whether the generic irq routing capability is present -- 1.6.0.4
Attachment:
0004-kvm-libkvm-add-deassign-ioctl.patch
Description: 0004-kvm-libkvm-add-deassign-ioctl.patch