WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 7 of 7] qemu: passthrough support in stubdoms

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 7 of 7] qemu: passthrough support in stubdoms
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Mon, 12 Oct 2009 18:21:02 +0100
Delivery-date: Mon, 12 Oct 2009 10:24:52 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
Few changes are needed in qemu to enable pci passthrough in stubdoms:

- we need to explicitely ask for PCI_FILL_IDENT and PCI_FILL_CLASS to
pcilib, otherwise it won't return them by default;

- we need to postpone pcilib initialization otherwise it will fail
because the pci backend is not configured yet in the pci hotplug case;

- we have to read the pci related nodes on xenstore from the guest's
path.


Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

---

diff --git a/hw/pass-through.c b/hw/pass-through.c
index a97368a..a207b2c 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -4188,7 +4188,7 @@ static struct pt_dev * register_real_device(PCIBus *e_bus,
         PT_LOG("Error: couldn't locate device in libpci structures\n");
         return NULL;
     }
-    pci_fill_info(pci_dev, PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | 
PCI_FILL_SIZES);
+    pci_fill_info(pci_dev, PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | 
PCI_FILL_SIZES | PCI_FILL_IDENT | PCI_FILL_CLASS);
     pt_libpci_fixup(pci_dev);
 
     msi_translate = direct_pci_msitranslate;
@@ -4431,6 +4431,20 @@ int power_on_php_devfn(int devfn)
 {
     struct php_dev *php_dev = &dpci_infos.php_devs[devfn];
     struct pt_dev *pt_dev;
+    struct pci_access *pci_access;
+
+    if (!dpci_infos.pci_access) {
+        /* Initialize libpci */
+        pci_access = pci_alloc();
+        if ( pci_access == NULL ) {
+            PT_LOG("Error: pci_access is NULL\n");
+            return -1;
+        }
+        pci_init(pci_access);
+        pci_scan_bus(pci_access);
+        dpci_infos.pci_access = pci_access;
+    }
+
     pt_dev =
         register_real_device(dpci_infos.e_bus,
             "DIRECT PCI",
@@ -4455,20 +4469,7 @@ int power_off_php_devfn(int php_devfn)
 
 int pt_init(PCIBus *e_bus)
 {
-    struct pci_access *pci_access;
-
-    /* Initialize libpci */
-    pci_access = pci_alloc();
-    if ( pci_access == NULL )
-    {
-        PT_LOG("Error: pci_access is NULL\n");
-        return -1;
-    }
-    pci_init(pci_access);
-    pci_scan_bus(pci_access);
-
     memset(&dpci_infos, 0, sizeof(struct dpci_infos));
-    dpci_infos.pci_access = pci_access;
     dpci_infos.e_bus      = e_bus;
 
     return 0;
diff --git a/xenstore.c b/xenstore.c
index 4dcc4d1..da278f4 100644
--- a/xenstore.c
+++ b/ xenstore.c
@@ -604,6 +604,10 @@ void xenstore_parse_domain_config(int hvm_domid)
         fprintf(logfile, "Watching %s\n", buf);
     }
 
+    /* no need for ifdef CONFIG_STUBDOM, since in the qemu case
+     * hvm_domid is always equal to domid */
+    hvm_domid = domid;
+
     /* get the pci pass-through parameter */
     if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/num_devs",
                   hvm_domid, pci_devid) == -1)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 7 of 7] qemu: passthrough support in stubdoms, Stefano Stabellini <=