mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
nwfilter_gentech: Use automatic mutex management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
68523b2605
commit
398745c3b3
@ -744,9 +744,7 @@ virNWFilterInstantiateFilterInternal(virNWFilterDriverState *driver,
|
|||||||
bool *foundNewFilter)
|
bool *foundNewFilter)
|
||||||
{
|
{
|
||||||
int ifindex;
|
int ifindex;
|
||||||
int rc;
|
VIR_LOCK_GUARD lock = virLockGuardLock(&updateMutex);
|
||||||
|
|
||||||
virMutexLock(&updateMutex);
|
|
||||||
|
|
||||||
/* after grabbing the filter update lock check for the interface; if
|
/* after grabbing the filter update lock check for the interface; if
|
||||||
it's not there anymore its filters will be or are being removed
|
it's not there anymore its filters will be or are being removed
|
||||||
@ -756,20 +754,14 @@ virNWFilterInstantiateFilterInternal(virNWFilterDriverState *driver,
|
|||||||
/* interfaces / VMs can disappear during filter instantiation;
|
/* interfaces / VMs can disappear during filter instantiation;
|
||||||
don't mark it as an error */
|
don't mark it as an error */
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
rc = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = virNWFilterInstantiateFilterUpdate(driver, teardownOld,
|
return virNWFilterInstantiateFilterUpdate(driver, teardownOld,
|
||||||
binding,
|
binding,
|
||||||
ifindex,
|
ifindex,
|
||||||
useNewFilter,
|
useNewFilter,
|
||||||
false, foundNewFilter);
|
false, foundNewFilter);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virMutexUnlock(&updateMutex);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -780,9 +772,9 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverState *driver,
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
bool foundNewFilter = false;
|
bool foundNewFilter = false;
|
||||||
|
VIR_LOCK_GUARD lock = virLockGuardLock(&updateMutex);
|
||||||
|
|
||||||
virNWFilterReadLockFilterUpdates();
|
virNWFilterReadLockFilterUpdates();
|
||||||
virMutexLock(&updateMutex);
|
|
||||||
|
|
||||||
rc = virNWFilterInstantiateFilterUpdate(driver, true,
|
rc = virNWFilterInstantiateFilterUpdate(driver, true,
|
||||||
binding, ifindex,
|
binding, ifindex,
|
||||||
@ -799,7 +791,6 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverState *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virNWFilterUnlockFilterUpdates();
|
virNWFilterUnlockFilterUpdates();
|
||||||
virMutexUnlock(&updateMutex);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -921,11 +912,9 @@ _virNWFilterTeardownFilter(const char *ifname)
|
|||||||
int
|
int
|
||||||
virNWFilterTeardownFilter(virNWFilterBindingDef *binding)
|
virNWFilterTeardownFilter(virNWFilterBindingDef *binding)
|
||||||
{
|
{
|
||||||
int ret;
|
VIR_LOCK_GUARD lock = virLockGuardLock(&updateMutex);
|
||||||
virMutexLock(&updateMutex);
|
|
||||||
ret = _virNWFilterTeardownFilter(binding->portdevname);
|
return _virNWFilterTeardownFilter(binding->portdevname);
|
||||||
virMutexUnlock(&updateMutex);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user