diff options
author | Stefan Berger <stefanb@us.ibm.com> | 2011-08-11 06:56:50 -0400 |
---|---|---|
committer | Stefan Berger <stefanb@us.ibm.com> | 2011-08-11 06:56:50 -0400 |
commit | 762101c7affbd32af18eccc07249c2684cbb84a2 (patch) | |
tree | b8052694a9f3a419428c705a1687b60d42b4fbf5 /src/nwfilter/nwfilter_gentech_driver.c | |
parent | qemu: Fix -chardev udp if parameters are omitted (diff) | |
download | libvirt-762101c7affbd32af18eccc07249c2684cbb84a2.tar.gz libvirt-762101c7affbd32af18eccc07249c2684cbb84a2.tar.bz2 libvirt-762101c7affbd32af18eccc07249c2684cbb84a2.zip |
nwfilter: tolerate disappearing interfaces while instantiating filter
When instantiating a filter, a VM may disappear and remove its tap interfaces. Tolerate this case and don't report an error.
Diffstat (limited to 'src/nwfilter/nwfilter_gentech_driver.c')
-rw-r--r-- | src/nwfilter/nwfilter_gentech_driver.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 7d9871a14..78919838b 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -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; |