KVM test: kvm_subprocess: don't immediately check /proc/$PID/cmdline

kvm_spawn.is_alive() incorrectly assumes that /proc/$PID/cmdline immediately
reflects the new command line of the forked process.  This makes it report
false negatives occasionally.  To prevent that, perform the command line check
only if the process is more than 10 seconds old, or if the process has been
pickled and unpickled.  In both cases, there is more than enough time for
/proc/$PID/cmdline to get updated.

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



git-svn-id: http://test.kernel.org/svn/autotest/trunk@3513 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index c15e779..6362856 100644
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -214,6 +214,8 @@
             # Wait for the server to complete its initialization
             while not "Server %s ready" % self.id in sub.stdout.readline():
                 pass
+            # Remember the start time for is_alive()
+            self.start_time = time.time()
 
         # Open the reading pipes
         self.reader_fds = {}
@@ -379,6 +381,10 @@
         except:
             # If we couldn't find the file for some reason, skip the check
             return True
+        # If this process is new (less than 10 secs old) skip the check
+        if hasattr(self, "start_time") and time.time() < self.start_time + 10:
+            return True
+        # Perform the check
         if self.id in cmdline:
             return True
         return False