]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nwfilter: tolerate disappearing interfaces while instantiating filter
authorStefan Berger <stefanb@us.ibm.com>
Thu, 11 Aug 2011 10:56:50 +0000 (06:56 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Thu, 11 Aug 2011 10:56:50 +0000 (06:56 -0400)
When instantiating a filter, a VM may disappear and remove its tap interfaces. Tolerate this case and don't report an error.

src/nwfilter/nwfilter_gentech_driver.c

index 7d9871a146ddb99d2d56d83513b3fe6c32c63d9b..78919838b4c823d6659a50bc5e0832384738efbf 100644 (file)
@@ -898,11 +898,18 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
     int ifindex;
     int rc;
 
-    if (ifaceGetIndex(true, net->ifname, &ifindex) < 0)
-        return 1;
-
     virNWFilterLockFilterUpdates();
 
+    /* after grabbing the filter update lock check for the interface; if
+       it's not there anymore its filters will be or are being removed
+       (while holding the lock) and we don't want to build new ones */
+    if (ifaceGetIndex(false, net->ifname, &ifindex) < 0) {
+        /* interfaces / VMs can disappear during filter instantiation;
+           don't mark it as an error */
+        rc = 0;
+        goto cleanup;
+    }
+
     rc = __virNWFilterInstantiateFilter(conn,
                                         teardownOld,
                                         net->ifname,
@@ -917,6 +924,7 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
                                         false,
                                         foundNewFilter);
 
+cleanup:
     virNWFilterUnlockFilterUpdates();
 
     return rc;