diff mbox

[v2,25/30] xen/x86: add all PCI devices to PVHv2 Dom0

Message ID 1474991845-27962-26-git-send-email-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné Sept. 27, 2016, 3:57 p.m. UTC
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/domain_build.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Jan Beulich Oct. 10, 2016, 1:44 p.m. UTC | #1
>>> On 27.09.16 at 17:57, <roger.pau@citrix.com> wrote:
> --- a/xen/arch/x86/domain_build.c
> +++ b/xen/arch/x86/domain_build.c
> @@ -2378,6 +2378,25 @@ static int __init hvm_setup_acpi(struct domain *d)
>      return 0;
>  }
>  
> +static int __init hvm_setup_pci(struct domain *d)
> +{
> +    struct pci_dev *pdev;
> +    int rc;
> +
> +    printk("** Adding PCI devices **\n");
> +
> +    pcidevs_lock();
> +    list_for_each_entry( pdev, &d->arch.pdev_list, domain_list )
> +    {
> +        rc = hwdom_add_device(pdev);

Considering the loop construct it is clear that the devices must
already have been added to the domain by the time you get here.
Hence the title (together with there not being any description) is
at least misleading.

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c
index 407f742..b4a14a3 100644
--- a/xen/arch/x86/domain_build.c
+++ b/xen/arch/x86/domain_build.c
@@ -2378,6 +2378,25 @@  static int __init hvm_setup_acpi(struct domain *d)
     return 0;
 }
 
+static int __init hvm_setup_pci(struct domain *d)
+{
+    struct pci_dev *pdev;
+    int rc;
+
+    printk("** Adding PCI devices **\n");
+
+    pcidevs_lock();
+    list_for_each_entry( pdev, &d->arch.pdev_list, domain_list )
+    {
+        rc = hwdom_add_device(pdev);
+        if ( rc )
+            return rc;
+    }
+    pcidevs_unlock();
+
+    return 0;
+}
+
 static int __init construct_dom0_hvm(struct domain *d, const module_t *image,
                                      unsigned long image_headroom,
                                      module_t *initrd,
@@ -2426,6 +2445,13 @@  static int __init construct_dom0_hvm(struct domain *d, const module_t *image,
         return rc;
     }
 
+    rc = hvm_setup_pci(d);
+    if ( rc )
+    {
+        printk("Failed to add PCI devices: %d\n", rc);
+        return rc;
+    }
+
     return 0;
 }