]> xenbits.xensource.com Git - libvirt.git/commitdiff
macvtap: cannot support target device name
authorStefan Berger <stefanb@us.ibm.com>
Fri, 28 May 2010 17:00:58 +0000 (13:00 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Fri, 28 May 2010 17:00:58 +0000 (13:00 -0400)
Since the macvtap device needs active tear-down and the teardown logic
is based on the interface name, it can happen that if for example 1 out
of 3 interfaces was successfully created, that during the failure path
the macvtap's target device name is used to tear down an interface that
is doesn't own (owned by another VM).

So, in this patch, the target interface name is reset so that there is
no target interface name and the interface name is always cleared after
a tear down.

src/conf/domain_conf.c
src/qemu/qemu_conf.c
src/qemu/qemu_driver.c

index dfdb0d8629e390c259239098258bcf43549d6a85..312a6c0e0d8d8408d97112cd5bf8078dd4d24922 100644 (file)
@@ -2207,6 +2207,8 @@ virDomainNetDefParseXML(virCapsPtr caps,
         def->data.direct.linkdev = dev;
         dev = NULL;
 
+        VIR_FREE(ifname);
+
         break;
 
     case VIR_DOMAIN_NET_TYPE_USER:
index 66a949e6e43fd00675daf4c0fed7262c4f36e266..33e6b38c5bb5ebe30e4d2dde12787f3d8677d3d7 100644 (file)
@@ -1556,6 +1556,7 @@ qemudPhysIfaceConnect(virConnectPtr conn,
                 rc = -1;
                 delMacvtap(net->ifname,
                            &net->data.direct.virtPortProfile);
+                VIR_FREE(net->ifname);
             }
         }
     }
index ad7fb54b463bbf8d0baf27ed2ced6b3e6ceee9e9..477a221ac032052c6d542c57c0c076348a4f947c 100644 (file)
@@ -3708,9 +3708,11 @@ static void qemudShutdownVMDaemon(struct qemud_driver *driver,
     def = vm->def;
     for (i = 0; i < def->nnets; i++) {
         virDomainNetDefPtr net = def->nets[i];
-        if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT)
+        if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
             delMacvtap(net->ifname,
                        &net->data.direct.virtPortProfile);
+            VIR_FREE(net->ifname);
+        }
     }
 #endif
 
@@ -8545,9 +8547,11 @@ qemudDomainDetachNetDevice(struct qemud_driver *driver,
     virNWFilterTearNWFilter(detach);
 
 #if WITH_MACVTAP
-    if (detach->type == VIR_DOMAIN_NET_TYPE_DIRECT)
+    if (detach->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
         delMacvtap(detach->ifname,
                    &detach->data.direct.virtPortProfile);
+        VIR_FREE(detach->ifname);
+    }
 #endif
 
     if ((driver->macFilter) && (detach->ifname != NULL)) {