diff --git a/tools/cleanup-containers b/tools/cleanup-containers
index c73d197dda910317149d1d0a5ad23de5fa6e2b3d..a07c1d4d132979319d64555b5c7f0b8376ec36c6 100755
--- a/tools/cleanup-containers
+++ b/tools/cleanup-containers
@@ -1,5 +1,6 @@
 #!/bin/bash
-if [[ $COMPUTE ]] && [[ $(pgrep qemu) ]]; then
+QEMU_PIDS=$(pgrep qemu)
+if [[ $COMPUTE ]] && [[ $QEMU_PIDS ]] && [[ $(ps --no-headers wwwup $QEMU_PIDS | grep --invert-match '\-xen\-domid 0') ]]; then
     echo "Some qemu processes were detected."
     echo "Docker will not be able to stop the nova_libvirt container with those running."
     echo "Please clean them up before rerunning this script."