]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Fix PCI address allocation
authorJiri Denemark <jdenemar@redhat.com>
Wed, 4 Aug 2010 12:46:06 +0000 (14:46 +0200)
committerDaniel Veillard <veillard@redhat.com>
Wed, 4 Aug 2010 12:46:06 +0000 (14:46 +0200)
commitbf0bf4e783d57413588392b8cadfb6a27dc68cc3
treec9f280a27abc0d938f6dc71a2639dfded1c00f35
parent9cbc3c8e064807fe6713d83ebcc415bc360093a6
qemu: Fix PCI address allocation

Patch version revamped by Eric Blake <eblake@redhat.com> of Jiri
Denemark <jdenemar@redhat.com> original patch

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.

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.

* src/qemu/qemu_conf.c: fix pci reservation code to do a round-robbin
  check of all available PCI splot availability before failing.
src/qemu/qemu_conf.c