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

qemu: fix index error when clean up vport profile

1. 'last_good_net' indicates the index of last successfully configured
net. so def->nets[last_good_net] should also be clean up if error occurs.

2. if error occurs in 'virNetDevMacVLanVPortProfileRegisterCallback'
(second 'goto err_exit' in loop), we should also do
'virNetDevVPortProfileDisassociate' cleanup for the
'virNetDevVPortProfileAssociate'(first code block in loop). So we should
consider the net is successfully configured after first code block in
loop finishes.
Signed-off-by: NHuanle Han <hanxueluo@gmail.com>
上级 03d7462d
......@@ -5080,6 +5080,7 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def)
net->ifname);
goto err_exit;
}
last_good_net = i;
VIR_DEBUG("Port profile Associate succeeded for %s", net->ifname);
if (virNetDevMacVLanVPortProfileRegisterCallback(net->ifname, &net->mac,
......@@ -5088,13 +5089,12 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def)
VIR_NETDEV_VPORT_PROFILE_OP_CREATE))
goto err_exit;
}
last_good_net = i;
}
return 0;
err_exit:
for (i = 0; last_good_net != -1 && i < last_good_net; i++) {
for (i = 0; last_good_net != -1 && i <= last_good_net; i++) {
net = def->nets[i];
if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
ignore_value(virNetDevVPortProfileDisassociate(net->ifname,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册