[libvirt] [PATCH] 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. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> --- src/nwfilter/nwfilter_gentech_driver.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c =================================================================== --- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c +++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c @@ -898,11 +898,18 @@ _virNWFilterInstantiateFilter(virConnect 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 exit; + } + rc = __virNWFilterInstantiateFilter(conn, teardownOld, net->ifname, @@ -917,6 +924,7 @@ _virNWFilterInstantiateFilter(virConnect false, foundNewFilter); +exit: virNWFilterUnlockFilterUpdates(); return rc;

On 08/10/2011 04:34 AM, Stefan Berger wrote:
When instantiating a filter, a VM may disappear and remove its tap interfaces. Tolerate this case and don't report an error.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
ACK with one nit:
+ rc = 0; + goto exit; + } + rc = __virNWFilterInstantiateFilter(conn, teardownOld, net->ifname, @@ -917,6 +924,7 @@ _virNWFilterInstantiateFilter(virConnect false, foundNewFilter);
+exit:
Coding conventions document that we prefer 'cleanup:' rather than 'exit:' for the goto statement and label name. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 08/10/2011 11:14 AM, Eric Blake wrote:
On 08/10/2011 04:34 AM, Stefan Berger wrote:
When instantiating a filter, a VM may disappear and remove its tap interfaces. Tolerate this case and don't report an error.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
ACK with one nit:
+ rc = 0; + goto exit; + } + rc = __virNWFilterInstantiateFilter(conn, teardownOld, net->ifname, @@ -917,6 +924,7 @@ _virNWFilterInstantiateFilter(virConnect false, foundNewFilter);
+exit:
Coding conventions document that we prefer 'cleanup:' rather than 'exit:' for the goto statement and label name.
Fixed in and pushed. Stefan
participants (2)
-
Eric Blake
-
Stefan Berger