mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
nwfilter_driver: Split up nwfilterStateCleanup
This allows nwfilterStateCleanupLocked to be used in nwfilterStateInitialize in a later patch. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8c86168868
commit
68523b2605
@ -53,8 +53,6 @@ VIR_LOG_INIT("nwfilter.nwfilter_driver");
|
||||
|
||||
static virNWFilterDriverState *driver;
|
||||
|
||||
static int nwfilterStateCleanup(void);
|
||||
|
||||
static int nwfilterStateReload(void);
|
||||
|
||||
static virMutex driverMutex = VIR_MUTEX_INITIALIZER;
|
||||
@ -150,6 +148,51 @@ virNWFilterTriggerRebuildImpl(void *opaque)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nwfilterStateCleanupLocked(void)
|
||||
{
|
||||
if (!driver)
|
||||
return -1;
|
||||
|
||||
if (driver->privileged) {
|
||||
virNWFilterConfLayerShutdown();
|
||||
virNWFilterDHCPSnoopShutdown();
|
||||
virNWFilterLearnShutdown();
|
||||
virNWFilterIPAddrMapShutdown();
|
||||
virNWFilterTechDriversShutdown();
|
||||
nwfilterDriverRemoveDBusMatches();
|
||||
|
||||
if (driver->lockFD != -1)
|
||||
virPidFileRelease(driver->stateDir, "driver", driver->lockFD);
|
||||
|
||||
g_free(driver->stateDir);
|
||||
g_free(driver->configDir);
|
||||
g_free(driver->bindingDir);
|
||||
}
|
||||
|
||||
virObjectUnref(driver->bindings);
|
||||
|
||||
/* free inactive nwfilters */
|
||||
virNWFilterObjListFree(driver->nwfilters);
|
||||
|
||||
g_clear_pointer(&driver, g_free);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nwfilterStateCleanup:
|
||||
*
|
||||
* Shutdown the nwfilter driver, it will stop all active nwfilters
|
||||
*/
|
||||
static int
|
||||
nwfilterStateCleanup(void)
|
||||
{
|
||||
VIR_LOCK_GUARD lock = virLockGuardLock(&driverMutex);
|
||||
return nwfilterStateCleanupLocked();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nwfilterStateInitialize:
|
||||
*
|
||||
@ -307,48 +350,6 @@ nwfilterStateReload(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nwfilterStateCleanup:
|
||||
*
|
||||
* Shutdown the nwfilter driver, it will stop all active nwfilters
|
||||
*/
|
||||
static int
|
||||
nwfilterStateCleanup(void)
|
||||
{
|
||||
if (!driver)
|
||||
return -1;
|
||||
|
||||
if (driver->privileged) {
|
||||
virNWFilterConfLayerShutdown();
|
||||
virNWFilterDHCPSnoopShutdown();
|
||||
virNWFilterLearnShutdown();
|
||||
virNWFilterIPAddrMapShutdown();
|
||||
virNWFilterTechDriversShutdown();
|
||||
|
||||
nwfilterDriverLock();
|
||||
|
||||
nwfilterDriverRemoveDBusMatches();
|
||||
|
||||
if (driver->lockFD != -1)
|
||||
virPidFileRelease(driver->stateDir, "driver", driver->lockFD);
|
||||
|
||||
g_free(driver->stateDir);
|
||||
g_free(driver->configDir);
|
||||
g_free(driver->bindingDir);
|
||||
nwfilterDriverUnlock();
|
||||
}
|
||||
|
||||
virObjectUnref(driver->bindings);
|
||||
|
||||
/* free inactive nwfilters */
|
||||
virNWFilterObjListFree(driver->nwfilters);
|
||||
|
||||
g_clear_pointer(&driver, g_free);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static virDrvOpenStatus
|
||||
nwfilterConnectOpen(virConnectPtr conn,
|
||||
virConnectAuthPtr auth G_GNUC_UNUSED,
|
||||
|
Loading…
Reference in New Issue
Block a user