]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: fix index error when clean up vport profile
authorHuanle Han <hanxueluo@gmail.com>
Tue, 7 Apr 2015 18:40:15 +0000 (02:40 +0800)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 14 Apr 2015 12:49:15 +0000 (14:49 +0200)
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 <hanxueluo@gmail.com>
src/qemu/qemu_migration.c

index f41286c3e2e1952d0ce7615724bbef71821d0d1d..611f53a1a3579a8fa6f6454653116b7253645949 100644 (file)
@@ -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,