]> xenbits.xensource.com Git - qemu-xen-3.4-testing.git/commitdiff
passthrough: support passthrough in stubdoms
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 13 Oct 2009 17:16:42 +0000 (18:16 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 13 Oct 2009 17:16:42 +0000 (18:16 +0100)
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.

[PATCH 7 of 7] qemu: passthrough support in stubdoms
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/pass-through.c
xenstore.c

index a97368a5a33a978065628a12a5438d27973b39c8..a207b2c5f15c93458e9ad980f877534b9777f7bf 100644 (file)
@@ -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;
index 4dcc4d105959f84b9d7996f2728ebeaf944c8b10..da278f4a0be7db772b5e9134d84b00a82188e235 100644 (file)
@@ -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)