On 07/30/2010 08:56 AM, Jiri Denemark wrote:
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.
---
src/qemu/qemu_conf.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 57bc02f..eaebcc1 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2055,8 +2055,6 @@ qemuAssignDeviceAliases(virDomainDefPtr def, unsigned long long
qemuCmdFlags)
#define QEMU_PCI_ADDRESS_LAST_SLOT 31
struct _qemuDomainPCIAddressSet {
virHashTablePtr used;
- int nextslot;
- /* XXX add domain, bus later when QEMU allows > 1 */
- for (i = addrs->nextslot ; i <= QEMU_PCI_ADDRESS_LAST_SLOT
; i++) {
+ for (i = 0 ; i <= QEMU_PCI_ADDRESS_LAST_SLOT ; i++) {
Don't we still want to start from the last slot, and wrap around the
search only when we reach the end, rather than always starting from 0?
I'm thinking particularly about compatibility with older qemu, where
always starting from 0 risks interleaving new assignments among the
pre-assigned slots, and may end up allocating slots in a way that throws
off Windows. Or am I worried about a non-issue?
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org