提交 c0f025b8 编写于 作者: S Shradha Shah 提交者: Eric Blake

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: NSteve Hodgson <shodgson@solarflare.com>
Signed-off-by: NShradha Shah <sshah@solarflare.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 ba0c2199
......@@ -190,6 +190,7 @@ Patches have also been contributed by:
Wieland Hoffmann <themineo@googlemail.com>
Douglas Schilling Landgraf <dougsland@redhat.com>
Tom Vijlbrief <tom.vijlbrief@xs4all.nl>
Shradha Shah <sshah@solarflare.com>
[....send patches to get your name here....]
......
......@@ -74,7 +74,6 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
virDomainDefPtr def)
{
pciDeviceList *pcidevs;
int i;
int ret = -1;
if (!def->nhostdevs)
......@@ -83,8 +82,8 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs)))
return -1;
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
while (pciDeviceListCount(pcidevs) > 0) {
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
pciDeviceListSteal(pcidevs, dev);
if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
pciFreeDevice(dev);
......@@ -152,8 +151,8 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
}
/* Now steal all the devices from pcidevs */
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
while (pciDeviceListCount(pcidevs) > 0) {
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
pciDeviceListSteal(pcidevs, dev);
}
......@@ -164,8 +163,8 @@ inactivedevs:
/* Only steal all the devices from driver->activePciHostdevs. We will
* free them in pciDeviceListFree().
*/
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
while (pciDeviceListCount(pcidevs) > 0) {
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
pciDeviceListSteal(driver->activePciHostdevs, dev);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册