[Xen-devel] [PATCH 3/6] [events] Check if the PCI device is owner by a domain different than DOMID_SELF.

Konrad Rzeszutek Wilk
Wed, 09 Dec 2009 16:29:30 -0000

We check if there is a domain owner for the PCI device. In case of failure
(meaning no domain has registered for this device) we make
DOMID_SELF the owner.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 drivers/xen/events.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index f8bbf4c..d122022 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -39,6 +39,7 @@
 #include <asm/sync_bitops.h>
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
+#include <asm/xen/pci.h>

 #include <xen/xen-ops.h>
 #include <xen/events.h>
@@ -633,10 +634,14 @@ int xen_create_msi_irq(struct pci_dev *dev, struct
msi_desc *msidesc,
 	int irq = 0;
 	struct physdev_map_pirq map_irq;
 	int rc;
-	domid_t domid = DOMID_SELF;
+	domid_t domid;
 	int pos;
 	u32 table_offset, bir;

+	domid = rc = find_device_owner(dev);
+	if (rc < 0)
+		domid = DOMID_SELF;
+
 	memset(&map_irq, 0, sizeof(map_irq));
 	map_irq.domid = domid;
 	map_irq.type = MAP_PIRQ_TYPE_MSI;