
On Tue, Aug 03, 2010 at 03:17:01PM -0600, Eric Blake wrote:
From: Jiri Denemark <jdenemar@redhat.com>
When attaching a PCI device which doesn't explicitly set its PCI address, libvirt allocates the address automatically. The problem is that when checking which PCI address is unused, we only check for those with slot number higher than the highest slot number ever used.
Thus attaching/detaching such device several times in a row (31 is the theoretical limit, less then 30 tries are enough in practise) makes any further device attachment fail. Furthermore, attaching a device with predefined PCI address to 0:0:31 immediately forbids attachment of any PCI device without explicit address.
This patch changes the logic so that we always check all PCI addresses before we say there is no PCI address available.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
Modifications from v1: revert back to remembering the last slot reserved, but allow wraparound to not be limited by the end. In this way, slots are still assigned in the same order as before the patch, rather than filling in the gaps closest to 0 and risking making windows guests mad.
ACK, that looks fine, I will push it once as part of my 0.8.3 release within an hour or so ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/