提交 7adb4bfc 编写于 作者: H Huanle Han 提交者: Martin Kletzander

hostdev: Fix index error in loop after remove an element

'virPCIDeviceList' is actually an array. Removing one element makes the
rest of the element move.

Use while loop, increase index only when not virPCIDeviceListDel(pcidevs, dev)
Signed-off-by: NHuanle Han <hanxueluo@gmail.com>
上级 b84c5729
......@@ -785,7 +785,8 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
* them and reset all the devices before re-attach.
* Attach mac and port profile parameters to devices
*/
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
i = 0;
while (i < virPCIDeviceListCount(pcidevs)) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDevicePtr activeDev = NULL;
......@@ -806,6 +807,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
}
virPCIDeviceListDel(hostdev_mgr->activePCIHostdevs, dev);
i++;
}
/* At this point, any device that had been used by the guest is in
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册