[libvirt] [PATCH 1/2] qemu: reserve PCI addresses for implicit i440fx devices

Andrea Bolognani abologna at redhat.com
Wed Oct 11 14:13:51 UTC 2017


On Wed, 2017-10-11 at 14:45 +0200, Ján Tomko wrote:
> > I think it would make more sense to reserve the address for these
> > devices in qemuDomainCollectPCIAddress() directly, along with the
> > other ones, eg. squash in the following diff:
> > 
> > ---------- 8< ---------- 8< ---------- 8< ---------- 8< ----------
> > diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
> > index f35e01e5a..ecb91c565 100644
> > --- a/src/qemu/qemu_domain_address.c
> > +++ b/src/qemu/qemu_domain_address.c
> > @@ -1265,13 +1265,12 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
> >                                _("Bus 0 must be PCI for integrated PIIX3 "
> >                                  "USB or IDE controllers"));
> >                 return -1;
> > -            } else {
> > -                return 0;
> >             }
> >         }
> >     }
> > 
> > -    if (virDomainPCIAddressReserveAddr(addrs, addr,
> > +    if (addrs->nbuses &&
> > +        virDomainPCIAddressReserveAddr(addrs, addr,
> >                                        info->pciConnectFlags,
> >                                        info->isolationGroup) < 0) {
> >         goto cleanup;
> > @@ -1429,13 +1428,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
> >                 cont->info.addr.pci.slot = 1;
> >                 cont->info.addr.pci.function = 2;
> >             }
> > -        } else {
> > -            /* this controller is not skipped in qemuDomainCollectPCIAddress */
> > -            continue;
> >         }
> > -        if (addrs->nbuses &&
> > -            virDomainPCIAddressReserveAddr(addrs, &cont->info.addr.pci, flags, 0) < 0)
> > -            goto cleanup;
> >     }
> > 
> >     /* Implicit PIIX3 devices living on slot 1 not handled above */
> > ---------- >8 ---------- >8 ---------- >8 ---------- >8 ----------
> > 
> > What do you think about it?
> 
> I think I cannot possibly reserve the address before setting it.

qemuDomainCollectPCIAddress() is called by
qemuDomainPCIAddressSetCreate(), which is called both before and
after calling qemuDomainValidateDevicePCISlotsChipsets() - which
in turn calls qemuDomainValidateDevicePCISlotsPIIX3().

So if the controllers already had been assigned a PCI address, then
it was stored in the domain XML and it will be picked up during the
first loop, reserved in qemuDomainCollectPCIAddress() and validated
by qemuDomainValidateDevicePCISlotsPIIX3(); if it has never been
assigned a PCI address, then it will be assigned the correct one by
qemuDomainValidateDevicePCISlotsPIIX3() and that address will be
reserved the second time qemuDomainCollectPCIAddress() is called.

So it looks to me like it would work. Or did I miss something?

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list