libxl: fix cold plugged PCI devices with stubdomains
PATCH 1/1 libxl: fix cold plugged PCI devices with stubdomains
In reply to a message not in the archive# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1323432076 0
# Node ID 9c1b223e152eaaa3861f9b6132590de0b4f6cb7e # Parent d8c390192ad1147d7202cf04be090478f1810a5d
libxl: fix cold plugged PCI devices with stubdomains
Since 23565:72eafe80ebc1 the xenstore entries for the stubdomain's PCI were never created and therefore the stubdom ends up waiting forever for the devices which it has been asked to insert to show up.
Since the stubdomain is already running when we call the libxl_device_pci_add loop in do_domain_create we should treat it as if "starting == 0".
tools/libxl/libxl_pci.c +2 -1
@@ -819,7 +819,8 @@ int libxl__device_pci_add(libxl__gc *gc, stubdomid =libxl_get_stubdom_id (ctx, domid);if (stubdomid !=0 ) {libxl_device_pci pcidev_s = *pcidev; - rc =do_pci_add (gc, stubdomid, &pcidev_s, starting); +/* stubdomain is always running by now, even at create time */ + rc =do_pci_add (gc, stubdomid, &pcidev_s,0 );if ( rc ) goto out; }
PATCH 1/1 mini-os: do not wait for pci backend in pcifront_scan
In reply to a message not in the archive# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1323432077 0
# Node ID d50241faddf372f2262627b9b2071d2a077e8151 # Parent 9c1b223e152eaaa3861f9b6132590de0b4f6cb7e
mini-os: do not wait for pci backend in pcifront_scan
This blocks the main thread indefinitely if there is no PCI backend present in xenstore.
Even in the case where there are passthrough devices configured libxl creates the stubdom and waits for it to startup _before_ adding the backend. Since the stub domains main thread is blocked before it can write the "running" state to xenstore the toolstack eventually times out and kills everything.
There is already a separate pcifront thread which waits for the backend to appear and calls init_pcifront at the appropriate time should a backend ever appear.
Unfortunately I don't have any free test boxes with VT-d so I haven't been able to test the cases where PCI deivces are passed through but I obviously have tested that I can now start an HVM domain with stub qemu without PCI devices passed through which I couldn't do before so this is an improvement. This stuff is a bit like pushing the lump around the carpet :-/
extras/mini-os/kernel.c +1 -0
@@ -448,6 +448,7 @@ static void print_pcidev(unsigned int dostatic void pcifront_thread (void *p) { +pcifront_watches (NULL ); pci_dev =init_pcifront (NULL );if (!pci_dev)return ;
extras/mini-os/pcifront.c +3 -12
@@ -280,23 +280,14 @@ void pcifront_scan(struct pcifront_dev * {char *path;int i, n, len; -char *s, *msg =NULL , *err =NULL ; +char *s, *msg =NULL ;unsigned int domain, bus, slot, fun;if (!dev) dev = pcidev;if (!dev) { -xenbus_event_queue events =NULL ; -char *fe_state ="device/pci/0/state" ; -xenbus_watch_path_token (XBT_NIL , fe_state, fe_state, &events); -while ((err =xenbus_read (XBT_NIL , fe_state, &msg)) !=NULL || msg[0 ] !='4' ) { -free (msg); -free (err); -printk ("pcifront_scan: waiting for pcifront to become ready\n" ); -xenbus_wait_for_watch (&events); - } -xenbus_unwatch_path_token (XBT_NIL , fe_state, fe_state); - dev = pcidev; +printk ("pcifront_scan: device or bus\n" ); +return ; } len =strlen (dev->backend) +1 +5 +10 +1 ;
Quoted 7 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1323432076 0
# Node ID9c1b223e152eaaa3861f9b6132590de0b4f6cb7e# Parentd8c390192ad1147d7202cf04be090478f1810a5d
libxl: fix cold plugged PCI devices with stubdomains
Quoted 8 lines
Since 23565:72eafe80ebc1 the xenstore entries for the stubdomain's PCI were never created and therefore the stubdom ends up waiting forever for the devices which it has been asked to insert to show up.
Since the stubdomain is already running when we call the
libxl_device_pci_addloop indo_domain_createwe should treat it as if "starting == 0".Signed-off-by Ian Campbell <[email protected]>
Acked
Quoted 19 lines
diff -r
d8c390192ad1-r9c1b223e152etools/libxl/libxl_pci.ctools/libxl/libxl_pci.c +2
-1@@ -819,7 +819,8 @@ int libxl__device_pci_add(libxl__gc *gc, stubdomid =libxl_get_stubdom_id (ctx, domid);if (stubdomid !=0 ) {libxl_device_pci pcidev_s = *pcidev; - rc =do_pci_add (gc, stubdomid, &pcidev_s, starting); +/* stubdomain is always running by now, even at create time */ + rc =do_pci_add (gc, stubdomid, &pcidev_s,0 );if ( rc ) goto out; }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 2 of 2] mini-os: do not wait for pci backend in pcifront_scan
In reply to Ian CampbellIan Campbell writes ("[PATCH 2 of 2] mini-os: do not wait for pci backend in pcifront_scan"):
Quoted 9 lines
Even in the case where there are passthrough devices configured libxl creates the stubdom and waits for it to startup _before_ adding the backend. Since the stub domains main thread is blocked before it can write the "running" state to xenstore the toolstack eventually times out and kills everything.
There is already a separate pcifront thread which waits for the backend to appear and calls
init_pcifrontat the appropriate time should a backend ever appear.
Quoted 6 lines
Unfortunately I don't have any free test boxes with VT-d so I haven't been able to test the cases where PCI deivces are passed through but I obviously have tested that I can now start an HVM domain with stub qemu without PCI devices passed through which I couldn't do before so this is an improvement. This stuff is a bit like pushing the lump around the carpet :-/
Right. The worry would be, surely, that this somehow breaks by unpausing the guest before everything has been set up by the stubdom.
But I'm happy to ack this patch on the basis that it seemed to improve things for you and should be harmless for the non-stubdom case.
(Not applying it yet as the patch floodgate is still closed pending a test pass.)
Ian.
Ian Campbell writes ("[PATCH 1 of 2] libxl: fix cold plugged PCI devices with stubdomains"):
Quoted 9 lines
libxl: fix cold plugged PCI devices with stubdomains
Since 23565:72eafe80ebc1 the xenstore entries for the stubdomain's PCI were never created and therefore the stubdom ends up waiting forever for the devices which it has been asked to insert to show up.
Since the stubdomain is already running when we call the
libxl_device_pci_addloop indo_domain_createwe should treat it as if "starting == 0".
That sounds plausible.
Ian.
Re: [PATCH 2 of 2] mini-os: do not wait for pci backend in pcifront_scan
In reply to Ian JacksonQuoted 17 lines · Ian Jackson
Ian Campbell writes ("[PATCH 2 of 2] mini-os: do not wait for pci backend in
pcifront_scan"):Quoted 9 lines
Even in the case where there are passthrough devices configured libxl creates the stubdom and waits for it to startup _before_ adding the backend. Since the stub domains main thread is blocked before it can write the "running" state to xenstore the toolstack eventually times out and kills everything.
There is already a separate pcifront thread which waits for the backend to appear and calls
init_pcifrontat the appropriate time should a backend ever appear.Quoted 6 lines
Unfortunately I don't have any free test boxes with VT-d so I haven't been able to test the cases where PCI deivces are passed through but I obviously have tested that I can now start an HVM domain with stub qemu without PCI devices passed through which I couldn't do before so this is an improvement. This stuff is a bit like pushing the lump around the carpet :-/
Quoted 2 lines
Right. The worry would be, surely, that this somehow breaks by unpausing the guest before everything has been set up by the stubdom.
Yes. I was a bit unclear how this ever worked though...
We could potentially add something to libxl__create_pci_backend which interlocks against the stubdom pcifront but without a system with an IOMMU I'm not really in a position to test such a patch.
Quoted 2 lines
But I'm happy to ack this patch on the basis that it seemed to improve things for you and should be harmless for the non-stubdom case.
Thanks.
Quoted 4 lines
Acked-by Ian Jackson <[email protected]>(Not applying it yet as the patch floodgate is still closed pending a test pass.)
Sure.
Ian.
Ian Jackson
AppliedRe: [PATCH 0 of 2] Qemu stubdom PCI fixlets
In reply to a message not in the archiveIan Campbell writes ("[Xen-devel] [PATCH 0 of 2] Qemu stubdom PCI fixlets"):
Quoted 1 line
Applied both, thanks.
Ian.