From: Huanle Han Date: Tue, 7 Apr 2015 18:40:15 +0000 (+0800) Subject: qemu: fix index error when clean up vport profile X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c61ded8a7d7bcfd60267c450fbb4c43169fdce1d;p=libvirt.git 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: Huanle Han --- diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f41286c3e2..611f53a1a3 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -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,