Fix 1: Fix index error in loop after remove an element from the array
'virPCIDeviceList' is actually an array. Removing one element makes the
rest of the element move. Use while loop, increase index only when not
do 'virPCIDeviceListDel(pcidevs, dev)'
Fix 2:
In such a case:
1. Domain A and B xml contain the same SRIOV net hostdev(<interface
type='hostdev' /> with same pci address).
2. virsh start A (Successfully, and configure the SRIOV net with
custom mac)
3. virsh start B (Fail because of the hostdev used by domain A or other
reason.)
In step 3, 'virHostdevNetConfigRestore' is called for the hostdev
which is still used by domain A. It makes the mac/vlan of the SRIOV net
change.
Code Change in this fix:
1. As the pci used by other domain have been removed from
'pcidevs' in previous loop, we only restore the nic config for
the hostdev still in 'pcidevs'(used by this domain)
2. wrap a function 'virHostdevIsPCINetDevice', which detect whether the
hostdev is a pci net device or not.
3. update the comments to make it more clear
Huanle Han (2):
hostdev: Fix index error in loop after remove an element
hostdev: fix net config restore error
src/util/virhostdev.c | 56 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 40 insertions(+), 16 deletions(-)
--
1.9.1