On 03/08/2016 11:36 AM, Cole Robinson wrote:
We do this in 2 passes: before PCI addresses are about to be
collected,
we convert type=pci auto_allocate=true to type=none auto_allocate=true,
since the existing code is already expecting type=none here.
After all PCI allocation should be complete, we do another pass of the
device addresses converting type=pci auto_allocate=true to
auto_allocate=false, so we don't trigger the unallocated address
validation check in generic domain code.
This sounds confusing. What about instead changing the existing code so
that it checks for a valid PCI address instead of checking for
type=none? A simple check for this is if domain == bus == slot == 0 (bus
0 is *always* either a pcie-root or a pci-root, and for both of those
slot 0 is reserved, so once an address has been assigned, it will never
be 0000:00:00.x .)
So rather than doing this dance with type and auto_allocate, you can
just modify the auto allocation to say:
if (info->type == ...NONE ||
(info->type == ...PCI &&
!virDevicePCIAddressIsValid(&info->addr.pci)) {
// Bob Loblaw
}
(virDevicePCIAddressIsValid() has some extra checks for values being too
large, but does the essential check for domain/bus/slot == 0 as well)