From eb138539f2dc4ff146ddb57ca3aa0a0acc111b55 Mon Sep 17 00:00:00 2001
From: Borne Mace <borne.mace@oracle.com>
Date: Thu, 17 Nov 2016 10:42:46 -0800
Subject: [PATCH] Ignore dom0 qemu processes during destroy

Updates cleanup-containers to disclude lines related to
dom0 qemu processes.

Change-Id: I0b71ed29b9a2f239ebfdaa66b7cbe41eeaf2773c
Partially-Implements: blueprint xen-hypervisor-support
---
 tools/cleanup-containers | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/cleanup-containers b/tools/cleanup-containers
index c73d197dda..a07c1d4d13 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."