This series is part of my ongoing quest to fix Bug 1272300[1]. I had previously posted a mostly complete solution[2], which did however fail to handle devices detached / reattached using virsh's nodedev-* commands. Part of that series has already been merged. This series refactors the PCI hostdev code so that all detach / reattach operations go through a single function, which means that once the previous code is reimplemented on top of it, all cases will be handled correctly. One problem with the previous code is that bookkeeping was performed all over the place, making it very easy to introduce subtle bugs. After this refactoring it's hopefully easier to follow along. Despite this being a refactoring, it introduces some changes in behaviour. These changes do, in fact, improve consistency, and should not cause any issue AFAICT, but they're still worth mentioning and thinking over. Basically, every time a device is detached from the host, its original status will be restored once it's reattached, which means that if it was not bound to any driver when 'virsh nodedev-detach' is called, it will not be bound to any driver after 'virsh nodedev-reattach' is called. This is the same thing that used to happen, and still happens, when such a managed PCI hostdev is attached and then detached from a guest. One more thing worth mentioning is that the code now relies heavily on libvirt's internal state, ie. the list of active and inactive PCI hostdevs. These lists do not currently survive daemon restarts, so the series is unfit for merge until that detail is sorted out. It's unclear to me how I could go about that, any suggestion? Cheers. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1272300 [2] https://www.redhat.com/archives/libvir-list/2015-December/msg00070.html Andrea Bolognani (7): hostdev: Add reattachPCIDevices() hostdev: Use common reattach code to rollback prepare errors hostdev: Use common reattach code in virHostdevPCINodeDeviceReAttach() hostdev: Add detachPCIDevices() hostdev: Use common detach code in virHostdevPCINodeDeviceDetach() pci: Phase out virPCIDeviceReattachInit() pci: Add debug messages when unbinding from stub driver src/libvirt_private.syms | 1 - src/util/virhostdev.c | 389 +++++++++++++++++++++++++++++------------------ src/util/virpci.c | 30 ++-- src/util/virpci.h | 1 - tests/virpcitest.c | 5 +- 5 files changed, 267 insertions(+), 159 deletions(-) -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list