mirror of https://gitee.com/openkylin/libvirt.git
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.
This commit is contained in:
parent
6bdcef11e3
commit
4cf974b674
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue