On Thu, Sep 22, 2016 at 01:10:04PM +0200, Andrew Jones wrote: > kvm-unit-tests shouldn't be asserting and dying when it's presented a > valid virtio-net-pci device though. It should handle the probing > correctly, or at least just warn that it doesn't know how to, and then > ignore it. Alex, can you consider what might need to be tweaked in this > series to do that? If the tweak below works for you? diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c index 4a2716a33150..a2a2b902f154 100644 --- a/lib/pci-host-generic.c +++ b/lib/pci-host-generic.c @@ -165,11 +165,10 @@ static struct pci_host_bridge *pci_dt_probe(void) return host; } -static u64 pci_alloc_resource(u32 bar, u64 size) +static bool pci_alloc_resource(u64 *addr, u32 bar, u64 size) { struct pci_host_bridge *host = pci_host_bridge; struct pci_addr_space *as = &host->addr_space[0]; - phys_addr_t addr; u32 mask; int i; @@ -180,17 +179,17 @@ static u64 pci_alloc_resource(u32 bar, u64 size) } if (i >= host->nr_addr_spaces) { printf("No PCI resource found for a device\n"); - assert(0); + return false; } mask = pci_bar_mask(bar); size = ALIGN(size, ~mask + 1); assert(as->allocated + size <= as->size); - addr = as->pci_start + as->allocated; + *addr = as->pci_start + as->allocated; as->allocated += size; - return addr; + return true; } bool pci_probe(void) @@ -225,13 +224,14 @@ bool pci_probe(void) continue; bar = pci_bar_get(dev, i); - addr = pci_alloc_resource(bar, size); - pci_bar_set_addr(dev, i, addr); - - if (pci_bar_is_memory(dev, i)) - cmd |= PCI_COMMAND_MEMORY; - else - cmd |= PCI_COMMAND_IO; + if (pci_alloc_resource(&addr, bar, size)) { + pci_bar_set_addr(dev, i, addr); + + if (pci_bar_is_memory(dev, i)) + cmd |= PCI_COMMAND_MEMORY; + else + cmd |= PCI_COMMAND_IO; + } if (pci_bar_is64(dev, i)) i++; -- 1.8.3.1 > Thanks, > drew -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html