From patchwork Sun Aug 9 16:36:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 40273 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n79GXx19000839 for ; Sun, 9 Aug 2009 16:33:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752013AbZHIQd4 (ORCPT ); Sun, 9 Aug 2009 12:33:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752011AbZHIQdz (ORCPT ); Sun, 9 Aug 2009 12:33:55 -0400 Received: from mx2.redhat.com ([66.187.237.31]:58107 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752005AbZHIQdz (ORCPT ); Sun, 9 Aug 2009 12:33:55 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n79GXt4s022247; Sun, 9 Aug 2009 12:33:55 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n79GXsA5030179; Sun, 9 Aug 2009 12:33:54 -0400 Received: from localhost.localdomain (dhcp-1-31.tlv.redhat.com [10.35.1.31]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n79GXq4H020764; Sun, 9 Aug 2009 12:33:53 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: kvm_subprocess: make is_alive() much shorter Date: Sun, 9 Aug 2009 19:36:35 +0300 Message-Id: <5f867ef244ef813dcf9e4c0f370aa79deee18558.1249835735.git.mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use a much shorter and simpler is_alive() instead of the current one. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_subprocess.py | 25 +------------------------ 1 files changed, 1 insertions(+), 24 deletions(-) diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py index 41b9d80..dcb20cc 100644 --- a/client/tests/kvm/kvm_subprocess.py +++ b/client/tests/kvm/kvm_subprocess.py @@ -214,8 +214,6 @@ class kvm_spawn: # 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 = {} @@ -366,28 +364,7 @@ class kvm_spawn: """ Return True if the process is running. """ - pid = self.get_shell_pid() - # See if the PID exists - try: - os.kill(pid, 0) - except: - return False - # Make sure the PID belongs to the original process - filename = "/proc/%d/cmdline" % pid - try: - file = open(filename, "r") - cmdline = file.read() - file.close() - 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 + return _locked(self.lock_server_running_filename) def close(self, sig=signal.SIGTERM):