KVM test: kvm_subprocess: add function kill_tail_thread()

Normally all threads are killed when the test process exits.  However, when
running multiple iterations of a test (with iterations=n) the test process
remains alive between iterations, and new threads are started but old threads
are not killed.  This function allow to stop thread execution explicitly.

This patch also makes the postprocessor call the function for all VMs.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@3543 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index dcb20cc..07303a8 100644
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -489,6 +489,7 @@
         self.output_prefix = output_prefix
 
         # Start the thread in the background
+        self.__thread_kill_requested = False
         self.tail_thread = threading.Thread(None, self._tail)
         self.tail_thread.start()
 
@@ -551,6 +552,15 @@
         self.output_prefix = output_prefix
 
 
+    def kill_tail_thread(self):
+        """
+        Stop the tailing thread which calls output_func() and
+        termination_func().
+        """
+        self.__thread_kill_requested = True
+        self._join_thread()
+
+
     def _tail(self):
         def print_line(text):
             # Pre-pend prefix and remove trailing whitespace
@@ -567,6 +577,8 @@
         fd = self._get_fd("tail")
         buffer = ""
         while True:
+            if self.__thread_kill_requested:
+                return
             try:
                 # See if there's any data to read from the pipe
                 r, w, x = select.select([fd], [], [], 0.05)