@@ -288,6 +288,10 @@ def postprocess(test, params, env):
int(params.get("post_command_timeout", "600")),
params.get("post_command_noncritical") == "yes")
+ # Kill the tailing threads of all VMs
+ for vm in kvm_utils.env_get_all_vms(env):
+ vm.kill_tail_thread()
+
# Terminate tcpdump if no VMs are alive
living_vms = [vm for vm in kvm_utils.env_get_all_vms(env) if vm.is_alive()]
if not living_vms and env.has_key("tcpdump"):
@@ -489,6 +489,7 @@ class kvm_tail(kvm_spawn):
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 @@ class kvm_tail(kvm_spawn):
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 @@ class kvm_tail(kvm_spawn):
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)
@@ -573,6 +573,14 @@ class VM:
return not self.process or not self.process.is_alive()
+ def kill_tail_thread(self):
+ """
+ Stop the tailing thread which reports the output of qemu.
+ """
+ if self.process:
+ self.process.kill_tail_thread()
+
+
def get_params(self):
"""
Return the VM's params dict. Most modified params take effect only
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> --- client/tests/kvm/kvm_preprocessing.py | 4 ++++ client/tests/kvm/kvm_subprocess.py | 12 ++++++++++++ client/tests/kvm/kvm_vm.py | 8 ++++++++ 3 files changed, 24 insertions(+), 0 deletions(-)