• J
    qemu: Fix PCI address allocation · bf0bf4e7
    Jiri Denemark 提交于
    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.
    bf0bf4e7
qemu_conf.c 204.6 KB