--- src/qemu/qemu_conf.c | 40 +++++++++++++++++++++++++++++++++++----- src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 2 ++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 38d28bf..bf950f2 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -2066,6 +2066,18 @@ struct _qemuDomainPCIAddressSet { }; +static void +qemuDomainPCIAddressSetUpdateNextSlot(qemuDomainPCIAddressSetPtr addrs, + const virDomainDevicePCIAddressPtr pci) +{ + if (pci->slot > addrs->nextslot) { + addrs->nextslot = pci->slot + 1; + if (QEMU_PCI_ADDRESS_LAST_SLOT < addrs->nextslot) + addrs->nextslot = 0; + } +} + + static char *qemuPCIAddressAsString(virDomainDeviceInfoPtr dev) { char *addr; @@ -2174,11 +2186,7 @@ int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs, VIR_FREE(addr); - if (dev->addr.pci.slot > addrs->nextslot) { - addrs->nextslot = dev->addr.pci.slot + 1; - if (QEMU_PCI_ADDRESS_LAST_SLOT < addrs->nextslot) - addrs->nextslot = 0; - } + qemuDomainPCIAddressSetUpdateNextSlot(addrs, pci); return 0; @@ -2236,6 +2244,28 @@ int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs, } +static void +qemuDomainPCIAddressSetUpdateIter(void *payload, + const char *name ATTRIBUTE_UNUSED, + void *data) +{ + qemuDomainPCIAddressSetUpdateNextSlot(data, payload); +} + + +void +qemuDomainPCIAddressSetUpdate(qemuDomainPCIAddressSetPtr addrs) +{ + + if (!addrs) + return; + + virHashForEach(addrs->used, qemuDomainPCIAddressSetUpdateIter, addrs); + + VIR_DEBUG("nextslot updated to %d", addrs->nextslot); +} + + void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs) { if (!addrs) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 1aa9d2e..fb93e0e 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -330,6 +330,7 @@ int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs, int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs, virDomainDeviceInfoPtr dev); +void qemuDomainPCIAddressSetUpdate(qemuDomainPCIAddressSetPtr addrs); void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs); int qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dbc3d5c..5a52549 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1461,6 +1461,8 @@ qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq if (!(priv->pciaddrs = qemuDomainPCIAddressSetCreate(obj->def)) || qemuAssignDevicePCISlots(obj->def, priv->pciaddrs) < 0) goto error; + + qemuDomainPCIAddressSetUpdate(priv->pciaddrs); } if (driver->securityDriver && -- 1.7.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list