Add a couple of useful debug messages, update comments to reflect recent changes, use the proper case for VFIO in variable names and fix parameter alignment in a function definition. --- src/util/virhostdev.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index b350de0..31cd152 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -652,9 +652,9 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr, hostdev_mgr->inactivePCIHostdevs, pcidevs }; bool strict_acs_check = !!(flags & VIR_HOSTDEV_STRICT_ACS_CHECK); - bool usesVfio = (virPCIDeviceGetStubDriver(dev) == VIR_PCI_STUB_DRIVER_VFIO); + bool usesVFIO = (virPCIDeviceGetStubDriver(dev) == VIR_PCI_STUB_DRIVER_VFIO); - if (!usesVfio && !virPCIDeviceIsAssignable(dev, strict_acs_check)) { + if (!usesVFIO && !virPCIDeviceIsAssignable(dev, strict_acs_check)) { virReportError(VIR_ERR_OPERATION_INVALID, _("PCI device %s is not assignable"), virPCIDeviceGetName(dev)); @@ -670,7 +670,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr, * and some other are assigned to a domain. KVM will actually prevent * that from happening, but we want to bail earlier and with a better * error message */ - if (usesVfio && + if (usesVFIO && virPCIDeviceIOMMUGroupIterate(dev, virHostdevIsPCIDeviceSafeForDetach, &data) < 0) { @@ -892,7 +892,8 @@ virHostdevExpandPCIDeviceListIOMMUGroups(virPCIDeviceListPtr list, * are locked */ static void -virHostdevReattachPCIDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr) +virHostdevReattachPCIDevice(virPCIDevicePtr dev, + virHostdevManagerPtr mgr) { /* We don't need to do anything for unmanaged devices */ if (!virPCIDeviceGetManaged(dev)) { @@ -911,6 +912,7 @@ virHostdevReattachPCIDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr) } } + VIR_DEBUG("Reattaching PCI device %s", virPCIDeviceGetName(dev)); if (virPCIDeviceReattach(dev, mgr->activePCIHostdevs, mgr->inactivePCIHostdevs) < 0) { virErrorPtr err = virGetLastError(); @@ -951,11 +953,13 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr, goto cleanup; } - /* Loop through the assigned devices 4 times: 1) delete them all from - * activePCIHostdevs, 2) restore network config of SRIOV netdevs, 3) Do a - * PCI reset on each device, 4) reattach the devices to their host drivers - * (managed) or add them to inactivePCIHostdevs (!managed). - */ + /* Loop through the assigned devices 5 times: 1) delete them all from + * activePCIHostdevs, 2) restore network config of SRIOV netdevs, 3) Add + * all devices to inactivePCIHostdevs, and stop processing those devices + * that can't be safely reattached to the host right now, 4) Do a PCI reset + * on each device, 5) Reattach managed devices to their host drivers. + * Between 3) and 4), we make sure devices we've previously delayed are + * handled properly */ /* * Loop 1: verify that each device in the hostdevs list really was in use @@ -1051,10 +1055,11 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr, hostdev_mgr->inactivePCIHostdevs) < 0) goto cleanup; - /* Loop 3: perform a PCI Reset on all devices */ + /* Loop 4: perform a PCI Reset on all devices */ for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); + VIR_DEBUG("Resetting PCI device %s", virPCIDeviceGetName(dev)); if (virPCIDeviceReset(dev, hostdev_mgr->activePCIHostdevs, hostdev_mgr->inactivePCIHostdevs) < 0) { virErrorPtr err = virGetLastError(); @@ -1064,7 +1069,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr, } } - /* Loop 4: reattach devices to their host drivers (if managed) or place + /* Loop 5: reattach devices to their host drivers (if managed) or place * them on the inactive list (if not managed) */ while (virPCIDeviceListCount(pcidevs) > 0) { -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list