From patchwork Fri Jun 5 20:46:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 28305 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 n55Kks2T016169 for ; Fri, 5 Jun 2009 20:46:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752957AbZFEUqt (ORCPT ); Fri, 5 Jun 2009 16:46:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752976AbZFEUqs (ORCPT ); Fri, 5 Jun 2009 16:46:48 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59799 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752927AbZFEUqr (ORCPT ); Fri, 5 Jun 2009 16:46:47 -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 n55Kkntd003264; Fri, 5 Jun 2009 16:46:49 -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 n55KkmY9017548; Fri, 5 Jun 2009 16:46:48 -0400 Received: from localhost.localdomain (vpn-10-165.bos.redhat.com [10.16.10.165]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n55KkZ46015832; Fri, 5 Jun 2009 16:46:46 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues , Michael Goldish Subject: [KVM-AUTOTEST PATCH 6/8] Choose a monitor filename in the constructor of VM class Date: Fri, 5 Jun 2009 17:46:32 -0300 Message-Id: <1244234794-7844-7-git-send-email-lmr@redhat.com> In-Reply-To: <1244234794-7844-6-git-send-email-lmr@redhat.com> References: <1244234794-7844-1-git-send-email-lmr@redhat.com> <1244234794-7844-2-git-send-email-lmr@redhat.com> <1244234794-7844-3-git-send-email-lmr@redhat.com> <1244234794-7844-4-git-send-email-lmr@redhat.com> <1244234794-7844-5-git-send-email-lmr@redhat.com> <1244234794-7844-6-git-send-email-lmr@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 Choose a monitor filename in the VM class constructor instead of the VM.create() method. This will reduce the number of monitor files left in /tmp, because the constructor is called fewer times than VM.create(). Risk: Low (comprehensible change, just moving a block of code). Visibility: Small (users of kvm test). Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_vm.py | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 76b0251..3001648 100644 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -115,6 +115,17 @@ class VM: self.iso_dir = iso_dir + # Find available monitor filename + while True: + # The monitor filename should be unique + self.instance = time.strftime("%Y%m%d-%H%M%S-") + \ + kvm_utils.generate_random_string(4) + self.monitor_file_name = os.path.join("/tmp", + "monitor-" + self.instance) + if not os.path.exists(self.monitor_file_name): + break + + def verify_process_identity(self): """ Make sure .pid really points to the original qemu process. If .pid @@ -297,16 +308,6 @@ class VM: logging.error("Actual MD5 sum differs from expected one") return False - # Find available monitor filename - while True: - # The monitor filename should be unique - self.instance = time.strftime("%Y%m%d-%H%M%S-") + \ - kvm_utils.generate_random_string(4) - self.monitor_file_name = os.path.join("/tmp", - "monitor-" + self.instance) - if not os.path.exists(self.monitor_file_name): - break - # Handle port redirections redir_names = kvm_utils.get_sub_dict_names(params, "redirs") host_ports = kvm_utils.find_free_ports(5000, 6000, len(redir_names))