From ba4e7b63441e3a99560b33a8edc71c24480e3473 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 16 Jan 2013 13:12:16 +0000 Subject: [PATCH] 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 --- src/conf/nwfilter_conf.h | 1 + src/nwfilter/nwfilter_driver.c | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 805fbe7453..80aa74539f 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -556,6 +556,7 @@ typedef struct _virNWFilterDriverState virNWFilterDriverState; typedef virNWFilterDriverState *virNWFilterDriverStatePtr; struct _virNWFilterDriverState { virMutex lock; + bool privileged; virNWFilterObjList nwfilters; diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index ba148230c7..dda6da7d79 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -183,6 +183,7 @@ nwfilterDriverStartup(int privileged) goto err_free_driverstate; driverState->watchingFirewallD = (sysbus != NULL); + driverState->privileged = privileged; if (!privileged) return 0; @@ -279,6 +280,9 @@ nwfilterDriverReload(void) { return -1; } + if (!driverState->privileged) + return 0; + conn = virConnectOpen("qemu:///system"); if (conn) { @@ -358,21 +362,24 @@ nwfilterDriverShutdown(void) { if (!driverState) return -1; - virNWFilterConfLayerShutdown(); - virNWFilterTechDriversShutdown(); - virNWFilterDHCPSnoopShutdown(); - virNWFilterLearnShutdown(); - virNWFilterIPAddrMapShutdown(); + if (driverState->privileged) { + virNWFilterConfLayerShutdown(); + virNWFilterTechDriversShutdown(); + virNWFilterDHCPSnoopShutdown(); + virNWFilterLearnShutdown(); + virNWFilterIPAddrMapShutdown(); - nwfilterDriverLock(driverState); + nwfilterDriverLock(driverState); - nwfilterDriverRemoveDBusMatches(); + nwfilterDriverRemoveDBusMatches(); - /* free inactive nwfilters */ - virNWFilterObjListFree(&driverState->nwfilters); + /* free inactive nwfilters */ + virNWFilterObjListFree(&driverState->nwfilters); + + VIR_FREE(driverState->configDir); + nwfilterDriverUnlock(driverState); + } - VIR_FREE(driverState->configDir); - nwfilterDriverUnlock(driverState); virMutexDestroy(&driverState->lock); VIR_FREE(driverState);