From patchwork Fri Feb 13 06:57:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Han, Weidong" X-Patchwork-Id: 6963 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1D6x7kH024902 for ; Fri, 13 Feb 2009 06:59:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751616AbZBMG7F (ORCPT ); Fri, 13 Feb 2009 01:59:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751694AbZBMG7F (ORCPT ); Fri, 13 Feb 2009 01:59:05 -0500 Received: from mga11.intel.com ([192.55.52.93]:6516 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751616AbZBMG7C (ORCPT ); Fri, 13 Feb 2009 01:59:02 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 12 Feb 2009 22:57:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,200,1233561600"; d="scan'208,223";a="665305087" Received: from azsmsx602.amr.corp.intel.com ([10.2.121.201]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2009 23:02:55 -0800 Received: from pdsmsx602.ccr.corp.intel.com (172.16.12.184) by azsmsx602.amr.corp.intel.com (10.2.121.201) with Microsoft SMTP Server (TLS) id 8.1.311.2; Thu, 12 Feb 2009 23:58:41 -0700 Received: from pdsmsx503.ccr.corp.intel.com ([172.16.12.95]) by pdsmsx602.ccr.corp.intel.com ([172.16.12.184]) with mapi; Fri, 13 Feb 2009 14:57:37 +0800 From: "Han, Weidong" To: "'Avi Kivity'" CC: "'kvm@vger.kernel.org'" , "'Mark McLoughlin'" Date: Fri, 13 Feb 2009 14:57:36 +0800 Subject: [PATCH 2/6] kvm: libkvm: add deassign ioctl Thread-Topic: [PATCH 2/6] kvm: libkvm: add deassign ioctl Thread-Index: AcmNqFmyWP5R5EDcQ6625NVzg4ICYA== Message-ID: <715D42877B251141A38726ABF5CABF2C01959AFDD4@pdsmsx503.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org add this to support hot remove device with iommu Acked-by: Mark McLoughlin Signed-off-by: Weidong Han --- 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