xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: xen-devel@lists.xen.org
Cc: "Wei Liu" <wei.liu2@citrix.com>,
	"Ian Jackson" <ian.jackson@eu.citrix.com>,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Samuel Thibault" <samuel.thibault@ens-lyon.org>
Subject: [PATCH 2/3] libxl: attach PCI device to qemu only after setting pciback/pcifront
Date: Tue, 18 Oct 2016 03:53:32 +0200	[thread overview]
Message-ID: <1476755613-3921-3-git-send-email-marmarek@invisiblethingslab.com> (raw)
In-Reply-To: <1476755613-3921-1-git-send-email-marmarek@invisiblethingslab.com>

When qemu is running in stubdomain, handling "pci-ins" command will fail
if pcifront is not initialized already. Fix this by sending such command
only after confirming that pciback/front is running.

It is possible to handle this case in mini-os code, by delaying
"pci-ins" handling until pcifront_thread finishes devices discovery. But
the same problem most likely will apply to any other stubdomain
implementations when they come (Rumprun, Linux) - so better handle this
at libxl level.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/libxl/libxl_pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 2ae1bc4..3805d30 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -1195,6 +1195,7 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcide
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     unsigned int orig_vdev, pfunc_mask;
+    char *be_path;
     libxl_device_pci *assigned;
     int num_assigned, i, rc;
     int stubdomid = 0;
@@ -1249,6 +1250,14 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcide
         rc = do_pci_add(gc, stubdomid, &pcidev_s, 0);
         if ( rc )
             goto out;
+        /* wait for the device actually being connected, otherwise device model
+         * running there will fail to find the device */
+        be_path = libxl__sprintf(gc, "%s/backend/pci/%d/0",
+                libxl__xs_get_dompath(gc, 0), stubdomid);
+        rc = libxl__wait_for_backend(gc, be_path,
+                    GCSPRINTF("%d", XenbusStateConnected));
+        if ( rc )
+            goto out;
     }
 
     orig_vdev = pcidev->vdevfn & ~7U;
-- 
2.5.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-10-18  1:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18  1:53 [PATCH 0/3] Fix PCI passthrough for HVM with stubdomain Marek Marczykowski-Górecki
2016-10-18  1:53 ` [PATCH 1/3] libxl: attach xen-pciback only to PV domains Marek Marczykowski-Górecki
2016-10-18 20:52   ` Konrad Rzeszutek Wilk
2016-10-18 21:03     ` Marek Marczykowski-Górecki
2016-10-19  9:37   ` Wei Liu
2016-10-19 20:46     ` Konrad Rzeszutek Wilk
2016-10-19 22:42       ` Marek Marczykowski-Górecki
2016-10-25 13:10         ` Konrad Rzeszutek Wilk
2016-10-25 19:22           ` Marek Marczykowski-Górecki
2016-10-25 19:42             ` Andrew Cooper
2016-10-18  1:53 ` Marek Marczykowski-Górecki [this message]
2016-10-19  9:37   ` [PATCH 2/3] libxl: attach PCI device to qemu only after setting pciback/pcifront Wei Liu
2016-10-18  1:53 ` [PATCH 3/3] libxl: don't try to manipulate json config for stubdomain Marek Marczykowski-Górecki
2016-10-19  9:38   ` Wei Liu
2016-10-19 10:32     ` Marek Marczykowski-Górecki
2016-10-18 18:44 ` [PATCH 0/3] Fix PCI passthrough for HVM with stubdomain Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476755613-3921-3-git-send-email-marmarek@invisiblethingslab.com \
    --to=marmarek@invisiblethingslab.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).