mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
pci: fix pciDeviceListSteal on multiple devices
pciDeviceListSteal(pcidevs, dev) removes dev from pcidevs reducing the length of pcidevs, so moving onto what was the next dev is wrong. Instead callers should pop entry 0 repeatedly until pcidevs is empty. Signed-off-by: Steve Hodgson <shodgson@solarflare.com> Signed-off-by: Shradha Shah <sshah@solarflare.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
ba0c219902
commit
c0f025b8ba
1
AUTHORS
1
AUTHORS
@ -190,6 +190,7 @@ Patches have also been contributed by:
|
|||||||
Wieland Hoffmann <themineo@googlemail.com>
|
Wieland Hoffmann <themineo@googlemail.com>
|
||||||
Douglas Schilling Landgraf <dougsland@redhat.com>
|
Douglas Schilling Landgraf <dougsland@redhat.com>
|
||||||
Tom Vijlbrief <tom.vijlbrief@xs4all.nl>
|
Tom Vijlbrief <tom.vijlbrief@xs4all.nl>
|
||||||
|
Shradha Shah <sshah@solarflare.com>
|
||||||
|
|
||||||
[....send patches to get your name here....]
|
[....send patches to get your name here....]
|
||||||
|
|
||||||
|
@ -74,7 +74,6 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
|
|||||||
virDomainDefPtr def)
|
virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
pciDeviceList *pcidevs;
|
pciDeviceList *pcidevs;
|
||||||
int i;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!def->nhostdevs)
|
if (!def->nhostdevs)
|
||||||
@ -83,8 +82,8 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
|
|||||||
if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs)))
|
if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
while (pciDeviceListCount(pcidevs) > 0) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
|
||||||
pciDeviceListSteal(pcidevs, dev);
|
pciDeviceListSteal(pcidevs, dev);
|
||||||
if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
|
if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
|
||||||
pciFreeDevice(dev);
|
pciFreeDevice(dev);
|
||||||
@ -152,8 +151,8 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now steal all the devices from pcidevs */
|
/* Now steal all the devices from pcidevs */
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
while (pciDeviceListCount(pcidevs) > 0) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
|
||||||
pciDeviceListSteal(pcidevs, dev);
|
pciDeviceListSteal(pcidevs, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,8 +163,8 @@ inactivedevs:
|
|||||||
/* Only steal all the devices from driver->activePciHostdevs. We will
|
/* Only steal all the devices from driver->activePciHostdevs. We will
|
||||||
* free them in pciDeviceListFree().
|
* free them in pciDeviceListFree().
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
while (pciDeviceListCount(pcidevs) > 0) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
|
||||||
pciDeviceListSteal(driver->activePciHostdevs, dev);
|
pciDeviceListSteal(driver->activePciHostdevs, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user