<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr"><div>In attempting to isolate vfio-pci problems between two different guest instances, the creation of a second guest (with existing guest shutdown) resulted in:.</div><div><br></div><div>Aug 09 12:43:23 grit libvirtd[6716]: internal error: Device 0000:01:00.3 is already in use<br>Aug 09 12:43:23 grit libvirtd[6716]: internal error: Device 0000:01:00.3 is already in use<br>Aug 09 12:43:23 grit libvirtd[6716]: Failed to allocate PCI device list: internal error: Device 0000:01:00.3 is already in use</div><div><br></div><div>Compiled against library: libvirt 6.1.0<br>Using library: libvirt 6.1.0<br>Using API: QEMU 6.1.0<br>Running hypervisor: QEMU 4.2.1</div><div>(fc32 default install)<br></div><div><br></div><div>The upstream code seems  also to test definitions rather than active uses of the PCI device.</div><div><br></div><div>My potentially naive patch to correct this (but not the failing test cases) would be:</div><div><br></div><div>diff --git a/src/util/virpci.c b/src/util/virpci.c<br>index 47c671daa0..a00c5e6f44 100644<br>--- a/src/util/virpci.c<br>+++ b/src/util/virpci.c<br>@@ -1597,7 +1597,7 @@ int<br> virPCIDeviceListAdd(virPCIDeviceListPtr list,<br>                     virPCIDevicePtr dev)<br> {<br>-    if (virPCIDeviceListFind(list, dev)) {<br>+    if (virPCIDeviceBusContainsActiveDevices(dev, list)) {<br>         virReportError(VIR_ERR_INTERNAL_ERROR,<br>                        _("Device %s is already in use"), dev->name);<br>         return -1;<br></div><div><br></div><div>Is this too simplistic or undesirable a feature request/implementation?</div><div><br></div><div>I'd be grateful if someone carries this through as I'm unsure when I may get time for this (busy handling other open source ecosystems). With an install and test mechanisms that doesn't create a mess of overwritten packages I"m happy to test a git branch or patches.<br></div></div>
</div></div>