From 294de0ec6c6b2f5d39dcdc3687a42095fca01288 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Mon, 11 Jun 2012 11:37:07 +0200 Subject: Do not attempt to kill already-dead dnsmasq Check that the dnsmasq process is running (and actually looks like a dnsmasq process) before attempting to kill it. Fixes bug 1010275. Change-Id: Ib49209e1624dfb30470adbe13d7fc045ec1fdf83 --- nova/network/linux_net.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nova') diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 811395f9c..484320261 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -660,7 +660,14 @@ def update_dhcp_hostfile_with_text(dev, hosts_text): def kill_dhcp(dev): pid = _dnsmasq_pid_for(dev) if pid: - _execute('kill', '-9', pid, run_as_root=True) + # Check that the process exists and looks like a dnsmasq process + conffile = _dhcp_file(dev, 'conf') + out, _err = _execute('cat', '/proc/%d/cmdline' % pid, + check_exit_code=False) + if conffile.split('/')[-1] in out: + _execute('kill', '-9', pid, run_as_root=True) + else: + LOG.debug(_('Pid %d is stale, skip killing dnsmasq'), pid) # NOTE(ja): Sending a HUP only reloads the hostfile, so any -- cgit