This is a followup to Alex's original proposal: https://www.redhat.com/archives/libvir-list/2012-October/msg00365.html
The core idea & concepts are the same as in Alex's patch, but I realized I could take the opportunity to refactor part of libvirtd to improve life in general. The state drivers currently have an 'active' method which is polled on every iteration of the event loop to determine if any resources (such as VMs) are active. This is the kind of information we need to inhibit host shutdown/suspend, but it is not being made available in an easily consumable way. The key idea I had was to remove the 'active' method from the state drivers and instead pass in a callback to the 'startup' method in the state driver. This so called 'inhibit' callback is used by drivers to signal when they have resources active. This callback is used both to inhibit shutdown of libvirtd (when the --timeout arg is used), and to inhibit shutdown of the host OS itself. The state driver also gains a 'stop' method which is intended to stop any resources which are causing the shutdown inhibition. In other words, to save any VMs to disk. One of the side effects of this change is that the --timeout param to libvirtd actually now works much better. Only running VMs cause libvirtd shutdown to be inhibited. Networks / storage pools no longer inhibit it. This is obviously targetted at post-1.0.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list