public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] kvm: libkvm: add deassign ioctl
@ 2009-02-10 12:40 Han, Weidong
  2009-02-11 18:59 ` Mark McLoughlin
  0 siblings, 1 reply; 2+ messages in thread
From: Han, Weidong @ 2009-02-10 12:40 UTC (permalink / raw)
  To: 'Avi Kivity'; +Cc: 'kvm@vger.kernel.org'

[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]

add this ioctl to deassign a device from guest

Signed-off-by: Weidong Han <weidong.han@intel.com>
---
 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 80300c9..cbd4c6f 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 #2: 0003-kvm-libkvm-add-deassign-ioctl.patch --]
[-- Type: application/octet-stream, Size: 1820 bytes --]

From ffc59975fedd24065844cdbf596151e8f1888c36 Mon Sep 17 00:00:00 2001
From: Weidong Han <weidong.han@intel.com>
Date: Mon, 9 Feb 2009 15:45:31 +0800
Subject: [PATCH] kvm: libkvm: add deassign ioctl

add this to support hot remove device with iommu

Signed-off-by: Weidong Han <weidong.han@intel.com>
---
 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 80300c9..cbd4c6f 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/4] kvm: libkvm: add deassign ioctl
  2009-02-10 12:40 [PATCH 3/4] kvm: libkvm: add deassign ioctl Han, Weidong
@ 2009-02-11 18:59 ` Mark McLoughlin
  0 siblings, 0 replies; 2+ messages in thread
From: Mark McLoughlin @ 2009-02-11 18:59 UTC (permalink / raw)
  To: Han, Weidong; +Cc: 'Avi Kivity', 'kvm@vger.kernel.org'

On Tue, 2009-02-10 at 20:40 +0800, Han, Weidong wrote:
> add this ioctl to deassign a device from guest
> 
> Signed-off-by: Weidong Han <weidong.han@intel.com>

Looks fine.

Acked-by: Mark McLoughlin <markmc@redhat.com>

Cheers,
Mark.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-11 18:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-10 12:40 [PATCH 3/4] kvm: libkvm: add deassign ioctl Han, Weidong
2009-02-11 18:59 ` Mark McLoughlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox