aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaine Stump <laine@laine.org>2012-09-16 21:22:27 -0400
committerLaine Stump <laine@laine.org>2012-09-18 04:21:33 -0400
commit4cf974b67427e33e3ce38df4787cddd6e2822d67 (patch)
tree2e7f6fe61d298dc12abee8635d7fd0c845f2fe34
parentnetwork: implement virNetworkUpdate for test_driver (diff)
downloadlibvirt-4cf974b67427e33e3ce38df4787cddd6e2822d67.tar.gz
libvirt-4cf974b67427e33e3ce38df4787cddd6e2822d67.tar.bz2
libvirt-4cf974b67427e33e3ce38df4787cddd6e2822d67.zip
network: restart radvd/dnsmasq if needed when libvirtd is restarted
A user on IRC had accidentally killed all of his libvirt-started dnsmasq instances (due to a buggy dnsmasq service script in Fedora 16), and had hoped that libvirtd would notice this on restart and reload all the dnsmasq daemons (as it does with iptables rules). Unfortunately this was not the case - as long as the network object had a pid registered for dnsmasq and/or radvd, it assumed that the processes were running. This patch takes advantage of the new utility functions in bridge_driver.c to do a "refresh" of all radvd and dnsmasq processes started by libvirt each time libvirtd is restarted - this function attempts to do a SIGHUP of each existing process, and if that fails, it restarts the process, rebuilding all the associated config files and commandline parameters in the process. This normally has no effect, but will be useful in solving the occasional "odd situation" without needing to take the drastic step of destroying/re-starting the network.
-rw-r--r--src/network/bridge_driver.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 252c96446..0e38016e2 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -117,6 +117,7 @@ static int networkShutdownNetworkExternal(struct network_driver *driver,
virNetworkObjPtr network);
static void networkReloadIptablesRules(struct network_driver *driver);
+static void networkRefreshDaemons(struct network_driver *driver);
static struct network_driver *driverState = NULL;
@@ -344,6 +345,7 @@ networkStartup(int privileged) {
networkFindActiveConfigs(driverState);
networkReloadIptablesRules(driverState);
+ networkRefreshDaemons(driverState);
networkAutostartConfigs(driverState);
networkDriverUnlock(driverState);
@@ -404,6 +406,7 @@ networkReload(void) {
driverState->networkConfigDir,
driverState->networkAutostartDir);
networkReloadIptablesRules(driverState);
+ networkRefreshDaemons(driverState);
networkAutostartConfigs(driverState);
networkDriverUnlock(driverState);
return 0;
@@ -1210,6 +1213,37 @@ networkRestartRadvd(virNetworkObjPtr network)
}
#endif /* #if 0 */
+/* SIGHUP/restart any dnsmasq or radvd daemons.
+ * This should be called when libvirtd is restarted.
+ */
+static void
+networkRefreshDaemons(struct network_driver *driver)
+{
+ unsigned int i;
+
+ VIR_INFO("Refreshing network daemons");
+
+ for (i = 0 ; i < driver->networks.count ; i++) {
+ virNetworkObjPtr network = driver->networks.objs[i];
+
+ virNetworkObjLock(network);
+ if (virNetworkObjIsActive(network) &&
+ ((network->def->forwardType == VIR_NETWORK_FORWARD_NONE) ||
+ (network->def->forwardType == VIR_NETWORK_FORWARD_NAT) ||
+ (network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE))) {
+ /* Only the three L3 network types that are configured by
+ * libvirt will have a dnsmasq or radvd daemon associated
+ * with them. Here we send a SIGHUP to an existing
+ * dnsmasq and/or radvd, or restart them if they've
+ * disappeared.
+ */
+ networkRefreshDhcpDaemon(network);
+ networkRefreshRadvd(network);
+ }
+ virNetworkObjUnlock(network);
+ }
+}
+
static int
networkAddMasqueradingIptablesRules(struct network_driver *driver,
virNetworkObjPtr network,