Fix nwfilter driver reload/shutdown handling when unprivileged

https://bugzilla.redhat.com/show_bug.cgi?id=903184

Although the nwfilter driver skips startup when running in a
session libvirtd, it did not skip reload or shutdown. This
caused errors to be reported when sending SIGHUP to libvirtd,
and caused an abort() in libdbus on shutdown due to trying
to remove a dbus filter that was never added
(cherry picked from commit abbec81bd0c9bf917f2c63045222734d7e4411fb)

Conflicts:
	src/nwfilter/nwfilter_driver.c - earlier changes f4ea67f and
79b8a56 related to using bool and auto-shutdown of drivers are not backported
This commit is contained in:
Daniel P. Berrange 2013-01-16 13:12:16 +00:00 committed by Eric Blake
parent 5e10d0ef1e
commit ba4e7b6344
2 changed files with 19 additions and 11 deletions

View File

@ -556,6 +556,7 @@ typedef struct _virNWFilterDriverState virNWFilterDriverState;
typedef virNWFilterDriverState *virNWFilterDriverStatePtr; typedef virNWFilterDriverState *virNWFilterDriverStatePtr;
struct _virNWFilterDriverState { struct _virNWFilterDriverState {
virMutex lock; virMutex lock;
bool privileged;
virNWFilterObjList nwfilters; virNWFilterObjList nwfilters;

View File

@ -183,6 +183,7 @@ nwfilterDriverStartup(int privileged)
goto err_free_driverstate; goto err_free_driverstate;
driverState->watchingFirewallD = (sysbus != NULL); driverState->watchingFirewallD = (sysbus != NULL);
driverState->privileged = privileged;
if (!privileged) if (!privileged)
return 0; return 0;
@ -279,6 +280,9 @@ nwfilterDriverReload(void) {
return -1; return -1;
} }
if (!driverState->privileged)
return 0;
conn = virConnectOpen("qemu:///system"); conn = virConnectOpen("qemu:///system");
if (conn) { if (conn) {
@ -358,21 +362,24 @@ nwfilterDriverShutdown(void) {
if (!driverState) if (!driverState)
return -1; return -1;
virNWFilterConfLayerShutdown(); if (driverState->privileged) {
virNWFilterTechDriversShutdown(); virNWFilterConfLayerShutdown();
virNWFilterDHCPSnoopShutdown(); virNWFilterTechDriversShutdown();
virNWFilterLearnShutdown(); virNWFilterDHCPSnoopShutdown();
virNWFilterIPAddrMapShutdown(); virNWFilterLearnShutdown();
virNWFilterIPAddrMapShutdown();
nwfilterDriverLock(driverState); nwfilterDriverLock(driverState);
nwfilterDriverRemoveDBusMatches(); nwfilterDriverRemoveDBusMatches();
/* free inactive nwfilters */ /* free inactive nwfilters */
virNWFilterObjListFree(&driverState->nwfilters); virNWFilterObjListFree(&driverState->nwfilters);
VIR_FREE(driverState->configDir);
nwfilterDriverUnlock(driverState);
}
VIR_FREE(driverState->configDir);
nwfilterDriverUnlock(driverState);
virMutexDestroy(&driverState->lock); virMutexDestroy(&driverState->lock);
VIR_FREE(driverState); VIR_FREE(driverState);