Dns stops working on precise when network manager is enabled

In Precise and Quantal, we nuke the dnsmasq launched by NetworkManager

Fixes LP# 993666

Change-Id: I4b39010765e2cbbea1ca3fc3120bf329015b7a56
diff --git a/stack.sh b/stack.sh
index 005d88e..4c10c74 100755
--- a/stack.sh
+++ b/stack.sh
@@ -967,7 +967,14 @@
 
 if is_service_enabled n-net q-dhcp; then
     # Delete traces of nova networks from prior runs
-    sudo killall dnsmasq || true
+    # Do not kill any dnsmasq instance spawned by NetworkManager
+    netman_pid=$(pidof NetworkManager || true)
+    if [ -z "$netman_pid" ]; then
+        sudo killall dnsmasq || true
+    else
+        sudo ps h -o pid,ppid -C dnsmasq | grep -v $netman_pid | awk '{print $1}' | sudo xargs kill || true
+    fi
+
     clean_iptables
     rm -rf ${NOVA_STATE_PATH}/networks
     sudo mkdir -p ${NOVA_STATE_PATH}/networks