diff mbox

[KVM-AUTOTEST] kvm_vm.py: choose a monitor filename in the constructor instead of VM.create()

Message ID debb6318d7b643282e0cf9c5304cee11c437a746.1243179847.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish May 24, 2009, 3:46 p.m. UTC
This will reduce the number of monitor files left in /tmp, because the
constructor is called fewer times than VM.create().

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm_runtest_2/kvm_vm.py |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm_runtest_2/kvm_vm.py b/client/tests/kvm_runtest_2/kvm_vm.py
index a1462c6..3ce2003 100644
--- a/client/tests/kvm_runtest_2/kvm_vm.py
+++ b/client/tests/kvm_runtest_2/kvm_vm.py
@@ -106,6 +106,14 @@  class VM:
         self.image_dir = image_dir
         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.
 
@@ -281,14 +289,6 @@  class VM:
                     kvm_log.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))