File 5d976da3-libxl-attach-PCI-device-to-qemu-only-after-setting-pciback-pcifront.patch of Package xen.16819
Subject: libxl: attach PCI device to qemu only after setting pciback/pcifront
From: Marek Marczykowski-Górecki marmarek@invisiblethingslab.com Tue Oct 1 05:24:19 2019 +0100
Date: Fri Oct 4 17:04:51 2019 +0100:
Git: ac2726ecc156fdc7434ca0211022f3124ecfe50a
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.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
---
tools/libxl/libxl_pci.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- xen-4.12.2-testing.orig/tools/libxl/libxl_pci.c
+++ xen-4.12.2-testing/tools/libxl/libxl_pci.c
@@ -1214,6 +1214,7 @@ int libxl__device_pci_add(libxl__gc *gc,
{
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;
@@ -1268,6 +1269,14 @@ int libxl__device_pci_add(libxl__gc *gc,
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;