diff mbox series

[v8,1/4] libxl: fix cold plugged PCI device with stubdomain

Message ID 9a61b361c46b5b1082ef47ac6aa25f8b5db7646b.1569680095.git-series.marmarek@invisiblethingslab.com (mailing list archive)
State New, archived
Headers show
Series Fix PCI passthrough for HVM with stubdomain | expand

Commit Message

Marek Marczykowski-Górecki Sept. 28, 2019, 2:20 p.m. UTC
When libxl__device_pci_add() is called, stubdomain is already running,
even when still constructing the target domain. Previously, do_pci_add()
was called with 'starting' hardcoded to false, but now do_pci_add() shares
'starting' flag in pci_add_state for both target domain and stubdomain.

Fix this by resetting (local) 'starting' to false in pci_add_dm_done()
(previously part of do_pci_add()) when handling stubdomain, regardless
of pas->starting value.

Fixes: 11db56f9a6 (libxl_pci: Use libxl__ao_device with libxl__device_pci_add)
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/libxl/libxl_pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Anthony PERARD Sept. 30, 2019, 2:33 p.m. UTC | #1
On Sat, Sep 28, 2019 at 04:20:34PM +0200, Marek Marczykowski-Górecki wrote:
> When libxl__device_pci_add() is called, stubdomain is already running,
> even when still constructing the target domain. Previously, do_pci_add()
> was called with 'starting' hardcoded to false, but now do_pci_add() shares
> 'starting' flag in pci_add_state for both target domain and stubdomain.
> 
> Fix this by resetting (local) 'starting' to false in pci_add_dm_done()
> (previously part of do_pci_add()) when handling stubdomain, regardless
> of pas->starting value.
> 
> Fixes: 11db56f9a6 (libxl_pci: Use libxl__ao_device with libxl__device_pci_add)
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,
Ian Jackson Oct. 2, 2019, 3:43 p.m. UTC | #2
Hi Juergen.  This series
  https://lists.xenproject.org/archives/html/xen-devel/2019-09/msg03072.html
needs your release review.

Here's the first patch.  I can bounce you a digest if you like.

Thanks,
Ian.

Marek Marczykowski-Górecki writes ("[PATCH v8 1/4] libxl: fix cold plugged PCI device with stubdomain"):
> When libxl__device_pci_add() is called, stubdomain is already running,
> even when still constructing the target domain. Previously, do_pci_add()
> was called with 'starting' hardcoded to false, but now do_pci_add() shares
> 'starting' flag in pci_add_state for both target domain and stubdomain.
> 
> Fix this by resetting (local) 'starting' to false in pci_add_dm_done()
> (previously part of do_pci_add()) when handling stubdomain, regardless
> of pas->starting value.
> 
> Fixes: 11db56f9a6 (libxl_pci: Use libxl__ao_device with libxl__device_pci_add)
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> ---
>  tools/libxl/libxl_pci.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
> index 4725817..2edff64 100644
> --- a/tools/libxl/libxl_pci.c
> +++ b/tools/libxl/libxl_pci.c
> @@ -1300,6 +1300,10 @@ static void pci_add_dm_done(libxl__egc *egc,
>  
>      if (rc) goto out;
>  
> +    /* stubdomain is always running by now, even at create time */
> +    if (isstubdom)
> +        starting = false;
> +
>      sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->domain,
>                             pcidev->bus, pcidev->dev, pcidev->func);
>      f = fopen(sysfs_path, "r");
> @@ -1559,7 +1563,6 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_t domid,
>          GCNEW(pcidev_s);
>          libxl_device_pci_init(pcidev_s);
>          libxl_device_pci_copy(CTX, pcidev_s, pcidev);
> -        /* stubdomain is always running by now, even at create time */
>          pas->callback = device_pci_add_stubdom_done;
>          do_pci_add(egc, stubdomid, pcidev_s, pas); /* must be last */
>          return;
> -- 
> git-series 0.9.1
Jürgen Groß Oct. 2, 2019, 3:54 p.m. UTC | #3
On 02.10.19 17:43, Ian Jackson wrote:
> Hi Juergen.  This series
>    https://lists.xenproject.org/archives/html/xen-devel/2019-09/msg03072.html
> needs your release review.

Fir the series:

Release-acked-by: Juergen Gross <jgross@suse.com>

even if I don't see why it is necessary: the series was posted first way
before last posting date.


Juergen
Ian Jackson Oct. 4, 2019, 4:03 p.m. UTC | #4
Jürgen Groß writes ("Re: [PATCH v8 1/4] libxl: fix cold plugged PCI device with stubdomain"):
> On 02.10.19 17:43, Ian Jackson wrote:
> > Hi Juergen.  This series
> >    https://lists.xenproject.org/archives/html/xen-devel/2019-09/msg03072.html
> > needs your release review.
> 
> Fir the series:
> 
> Release-acked-by: Juergen Gross <jgross@suse.com>

Thanks.  I have pushed this (and added a couple of acks of my own).

> even if I don't see why it is necessary: the series was posted first way
> before last posting date.

I think I may have been confused.

Thanks,
Ian.
diff mbox series

Patch

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 4725817..2edff64 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -1300,6 +1300,10 @@  static void pci_add_dm_done(libxl__egc *egc,
 
     if (rc) goto out;
 
+    /* stubdomain is always running by now, even at create time */
+    if (isstubdom)
+        starting = false;
+
     sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->domain,
                            pcidev->bus, pcidev->dev, pcidev->func);
     f = fopen(sysfs_path, "r");
@@ -1559,7 +1563,6 @@  void libxl__device_pci_add(libxl__egc *egc, uint32_t domid,
         GCNEW(pcidev_s);
         libxl_device_pci_init(pcidev_s);
         libxl_device_pci_copy(CTX, pcidev_s, pcidev);
-        /* stubdomain is always running by now, even at create time */
         pas->callback = device_pci_add_stubdom_done;
         do_pci_add(egc, stubdomid, pcidev_s, pas); /* must be last */
         return;