[KVM-AUTOTEST PATCH 05/17] KVM test: use the new wait_for_login()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 client/tests/kvm/kvm_test_utils.py                 |    4 +---
 client/tests/kvm/tests/autotest.py                 |    2 +-
 client/tests/kvm/tests/balloon_check.py            |    2 +-
 client/tests/kvm/tests/boot.py                     |    2 +-
 client/tests/kvm/tests/clock_getres.py             |    2 +-
 client/tests/kvm/tests/ethtool.py                  |    6 ++----
 client/tests/kvm/tests/file_transfer.py            |    4 +---
 client/tests/kvm/tests/guest_s4.py                 |   11 +++--------
 client/tests/kvm/tests/guest_test.py               |    7 ++++---
 client/tests/kvm/tests/iofuzz.py                   |    4 ++--
 client/tests/kvm/tests/ioquit.py                   |    8 +++-----
 client/tests/kvm/tests/iozone_windows.py           |    2 +-
 client/tests/kvm/tests/jumbo.py                    |    3 +--
 client/tests/kvm/tests/kdump.py                    |    6 +++---
 client/tests/kvm/tests/ksm_overcommit.py           |   12 +++---------
 client/tests/kvm/tests/linux_s3.py                 |    2 +-
 client/tests/kvm/tests/mac_change.py               |   10 ++++------
 client/tests/kvm/tests/migration.py                |    8 +++-----
 client/tests/kvm/tests/migration_multi_host.py     |    6 +++---
 .../kvm/tests/migration_with_file_transfer.py      |    2 +-
 client/tests/kvm/tests/migration_with_reboot.py    |   16 ++++------------
 client/tests/kvm/tests/multicast.py                |    3 +--
 client/tests/kvm/tests/netperf.py                  |    2 +-
 client/tests/kvm/tests/nic_bonding.py              |    3 +--
 client/tests/kvm/tests/nic_promisc.py              |    7 +++----
 client/tests/kvm/tests/nicdriver_unload.py         |    5 ++---
 client/tests/kvm/tests/pci_hotplug.py              |    2 +-
 client/tests/kvm/tests/physical_resources_check.py |    2 +-
 client/tests/kvm/tests/ping.py                     |    3 +--
 client/tests/kvm/tests/qemu_img.py                 |    6 +++---
 client/tests/kvm/tests/shutdown.py                 |    2 +-
 client/tests/kvm/tests/stress_boot.py              |    6 ++----
 client/tests/kvm/tests/timedrift.py                |    2 +-
 client/tests/kvm/tests/timedrift_with_migration.py |    6 ++----
 client/tests/kvm/tests/timedrift_with_reboot.py    |    2 +-
 client/tests/kvm/tests/timedrift_with_stop.py      |    2 +-
 client/tests/kvm/tests/virtio_console.py           |    8 ++------
 client/tests/kvm/tests/vlan.py                     |    8 +++-----
 client/tests/kvm/tests/vmstop.py                   |    2 +-
 client/tests/kvm/tests/whql_client_install.py      |    2 +-
 client/tests/kvm/tests/whql_submission.py          |    7 ++++---
 client/tests/kvm/tests/yum_update.py               |    2 +-
 42 files changed, 78 insertions(+), 123 deletions(-)

diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py
index caefa5e..539bb10 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -138,9 +138,7 @@ def reboot(vm, session, method="shell", sleep_before_reset=10, nic_index=0,
     # Try logging into the guest until timeout expires
     logging.info("Guest is down. Waiting for it to go up again, timeout %ds",
                  timeout)
-    # Temporary hack
-    time.sleep(timeout)
-    session = vm.remote_login(nic_index=nic_index)
+    session = vm.wait_for_login(nic_index, timeout=timeout)
     logging.info("Guest is up again")
     return session
 
diff --git a/client/tests/kvm/tests/autotest.py b/client/tests/kvm/tests/autotest.py
index 2916ebd..ec4bd9f 100644
--- a/client/tests/kvm/tests/autotest.py
+++ b/client/tests/kvm/tests/autotest.py
@@ -14,7 +14,7 @@ def run_autotest(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     # Collect test parameters
     timeout = int(params.get("test_timeout", 300))
diff --git a/client/tests/kvm/tests/balloon_check.py b/client/tests/kvm/tests/balloon_check.py
index 1ee05bf..a9226c3 100644
--- a/client/tests/kvm/tests/balloon_check.py
+++ b/client/tests/kvm/tests/balloon_check.py
@@ -67,7 +67,7 @@ def run_balloon_check(test, params, env):
     fail = 0
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     # Upper limit that we can raise the memory
     vm_assigned_mem = int(params.get("mem"))
diff --git a/client/tests/kvm/tests/boot.py b/client/tests/kvm/tests/boot.py
index 8cc0218..936ce65 100644
--- a/client/tests/kvm/tests/boot.py
+++ b/client/tests/kvm/tests/boot.py
@@ -17,7 +17,7 @@ def run_boot(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = float(params.get("login_timeout", 240))
-    session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)
+    session = vm.wait_for_login(timeout=timeout)
 
     try:
         if not params.get("reboot_method"):
diff --git a/client/tests/kvm/tests/clock_getres.py b/client/tests/kvm/tests/clock_getres.py
index 4bc558e..7c828f2 100644
--- a/client/tests/kvm/tests/clock_getres.py
+++ b/client/tests/kvm/tests/clock_getres.py
@@ -30,7 +30,7 @@ def run_clock_getres(test, params, env):
 
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
     vm.copy_files_to(test_clock, base_dir)
     session.cmd(os.path.join(base_dir, t_name))
     logging.info("PASS: Guest reported appropriate clock resolution")
diff --git a/client/tests/kvm/tests/ethtool.py b/client/tests/kvm/tests/ethtool.py
index 1aa6d0f..be8f1d2 100644
--- a/client/tests/kvm/tests/ethtool.py
+++ b/client/tests/kvm/tests/ethtool.py
@@ -176,12 +176,10 @@ def run_ethtool(test, params, env):
 
 
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm,
-                  timeout=int(params.get("login_timeout", 360)))
+    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
     # Let's just error the test if we identify that there's no ethtool installed
     session.cmd("ethtool -h")
-    session2 = kvm_test_utils.wait_for_login(vm,
-                  timeout=int(params.get("login_timeout", 360)))
+    session2 = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
     mtu = 1514
     feature_status = {}
     filename = "/tmp/ethtool.dd"
diff --git a/client/tests/kvm/tests/file_transfer.py b/client/tests/kvm/tests/file_transfer.py
index 7256c81..eb856d4 100644
--- a/client/tests/kvm/tests/file_transfer.py
+++ b/client/tests/kvm/tests/file_transfer.py
@@ -20,9 +20,7 @@ def run_file_transfer(test, params, env):
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout=int(params.get("login_timeout", 360))
 
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
-    if not session:
-        raise error.TestFail("Could not log into guest '%s'" % vm.name)
+    session = vm.wait_for_login(timeout=timeout)
 
     dir_name = test.tmpdir
     transfer_timeout = int(params.get("transfer_timeout"))
diff --git a/client/tests/kvm/tests/guest_s4.py b/client/tests/kvm/tests/guest_s4.py
index 141e3d6..9376222 100644
--- a/client/tests/kvm/tests/guest_s4.py
+++ b/client/tests/kvm/tests/guest_s4.py
@@ -13,7 +13,7 @@ def run_guest_s4(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     logging.info("Checking whether guest OS supports suspend to disk (S4)...")
     session.cmd(params.get("check_s4_support_cmd"))
@@ -28,7 +28,7 @@ def run_guest_s4(test, params, env):
     time.sleep(5)
 
     # Get the second session to start S4
-    session2 = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session2 = vm.wait_for_login(timeout=timeout)
 
     # Make sure the background program is running as expected
     check_s4_cmd = params.get("check_s4_cmd")
@@ -55,12 +55,7 @@ def run_guest_s4(test, params, env):
     # Log into the resumed VM
     relogin_timeout = int(params.get("relogin_timeout", 240))
     logging.info("Logging into resumed VM, timeout %s", relogin_timeout)
-    # Temporary hack
-    time.sleep(relogin_timeout)
-    session2 = vm.remote_login()
-    if not session2:
-        raise error.TestFail("Could not log into VM after resuming from "
-                             "suspend to disk")
+    session2 = vm.wait_for_login(timeout=relogin_timeout)
 
     # Check whether the test command is still alive
     logging.info("Checking if background command is still alive...")
diff --git a/client/tests/kvm/tests/guest_test.py b/client/tests/kvm/tests/guest_test.py
index b9786b5..54f64ca 100644
--- a/client/tests/kvm/tests/guest_test.py
+++ b/client/tests/kvm/tests/guest_test.py
@@ -20,9 +20,10 @@ def run_guest_test(test, params, env):
     reboot = params.get("reboot", "no")
 
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    serial_login = (params.get("serial_login", "no") == "yes")
-    session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout,
-                                            serial=serial_login)
+    if params.get("serial_login") == "yes":
+        session = vm.wait_for_serial_login(timeout=login_timeout)
+    else:
+        session = vm.wait_for_login(timeout=login_timeout)
 
     if reboot == "yes":
         logging.debug("Rebooting guest before test ...")
diff --git a/client/tests/kvm/tests/iofuzz.py b/client/tests/kvm/tests/iofuzz.py
index e77540e..0642e79 100644
--- a/client/tests/kvm/tests/iofuzz.py
+++ b/client/tests/kvm/tests/iofuzz.py
@@ -79,7 +79,7 @@ def run_iofuzz(test, params, env):
                 if vm.process.is_alive():
                     logging.debug("VM is alive, try to re-login")
                     try:
-                        session = kvm_test_utils.wait_for_login(vm, 0, 10, 0, 2)
+                        session = vm.wait_for_login(timeout=10)
                     except:
                         logging.debug("Could not re-login, reboot the guest")
                         session = kvm_test_utils.reboot(vm, session,
@@ -91,7 +91,7 @@ def run_iofuzz(test, params, env):
 
     login_timeout = float(params.get("login_timeout", 240))
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm, 0, login_timeout, 0, 2)
+    session = vm.wait_for_login(timeout=login_timeout)
 
     try:
         ports = {}
diff --git a/client/tests/kvm/tests/ioquit.py b/client/tests/kvm/tests/ioquit.py
index 25d3ac9..ca08b96 100644
--- a/client/tests/kvm/tests/ioquit.py
+++ b/client/tests/kvm/tests/ioquit.py
@@ -11,12 +11,10 @@ def run_ioquit(test, params, env):
     @param params: Dictionary with the test parameters.
     @param env: Dictionary with test environment.
     """
-
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm,
-                  timeout=int(params.get("login_timeout", 360)))
-    session2 = kvm_test_utils.wait_for_login(vm,
-                  timeout=int(params.get("login_timeout", 360)))
+    login_timeout = int(params.get("login_timeout", 360))
+    session = vm.wait_for_login(timeout=login_timeout)
+    session2 = vm.wait_for_login(timeout=login_timeout)
     try:
         bg_cmd = params.get("background_cmd")
         logging.info("Add IO workload for guest OS.")
diff --git a/client/tests/kvm/tests/iozone_windows.py b/client/tests/kvm/tests/iozone_windows.py
index febf898..6171906 100644
--- a/client/tests/kvm/tests/iozone_windows.py
+++ b/client/tests/kvm/tests/iozone_windows.py
@@ -19,7 +19,7 @@ def run_iozone_windows(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
     results_path = os.path.join(test.resultsdir,
                                 'raw_output_%s' % test.iteration)
     analysisdir = os.path.join(test.resultsdir, 'analysis_%s' % test.iteration)
diff --git a/client/tests/kvm/tests/jumbo.py b/client/tests/kvm/tests/jumbo.py
index 1fbce8b..fd9fb3e 100644
--- a/client/tests/kvm/tests/jumbo.py
+++ b/client/tests/kvm/tests/jumbo.py
@@ -22,9 +22,8 @@ def run_jumbo(test, params, env):
     @param params: Dictionary with the test parameters.
     @param env: Dictionary with test environment.
     """
-
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm)
+    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
     mtu = params.get("mtu", "1500")
     flood_time = params.get("flood_time", "300")
     max_icmp_pkt_size = int(mtu) - 28
diff --git a/client/tests/kvm/tests/kdump.py b/client/tests/kvm/tests/kdump.py
index ccc4307..3d9f142 100644
--- a/client/tests/kvm/tests/kdump.py
+++ b/client/tests/kvm/tests/kdump.py
@@ -17,7 +17,7 @@ def run_kdump(test, params, env):
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = float(params.get("login_timeout", 240))
     crash_timeout = float(params.get("crash_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)
+    session = vm.wait_for_login(timeout=timeout)
     def_kernel_param_cmd = ("grubby --update-kernel=`grubby --default-kernel`"
                             " --args=crashkernel=128M")
     kernel_param_cmd = params.get("kernel_param_cmd", def_kernel_param_cmd)
@@ -33,7 +33,7 @@ def run_kdump(test, params, env):
 
         @param vcpu: vcpu which is used to trigger a crash
         """
-        session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)
+        session = vm.wait_for_login(timeout=timeout)
         session.cmd_output("rm -rf /var/crash/*")
 
         logging.info("Triggering crash on vcpu %d ...", vcpu)
@@ -45,7 +45,7 @@ def run_kdump(test, params, env):
             raise error.TestFail("Could not trigger crash on vcpu %d" % vcpu)
 
         logging.info("Waiting for kernel crash dump to complete")
-        session = kvm_test_utils.wait_for_login(vm, 0, crash_timeout, 0, 2)
+        session = vm.wait_for_login(timeout=crash_timeout)
 
         logging.info("Probing vmcore file...")
         session.cmd("ls -R /var/crash | grep vmcore")
diff --git a/client/tests/kvm/tests/ksm_overcommit.py b/client/tests/kvm/tests/ksm_overcommit.py
index 375522a..129811d 100644
--- a/client/tests/kvm/tests/ksm_overcommit.py
+++ b/client/tests/kvm/tests/ksm_overcommit.py
@@ -249,9 +249,7 @@ def run_ksm_overcommit(test, params, env):
         session = lsessions[0]
         vm = lvms[0]
         for i in range(1, max_alloc):
-            # Temporary hack
-            time.sleep(360)
-            lsessions.append(vm.remote_login())
+            lsessions.append(vm.wait_for_login(timeout=360))
 
         session.cmd("swapoff -a", timeout=300)
 
@@ -552,9 +550,7 @@ def run_ksm_overcommit(test, params, env):
 
     logging.debug("Booting first guest %s", lvms[0].name)
 
-    # Temporary hack
-    time.sleep(360)
-    lsessions.append(lvms[0].remote_login())
+    lsessions.append(lvms[0].wait_for_login(timeout=360))
     # Associate vm PID
     try:
         tmp = open(params.get('pid_' + vm_name), 'r')
@@ -584,9 +580,7 @@ def run_ksm_overcommit(test, params, env):
             raise error.TestError("VM %s seems to be dead; Test requires a"
                                   "living VM" % lvms[i].name)
 
-        # Temporary hack
-        time.sleep(360)
-        lsessions.append(lvms[i].remote_login())
+        lsessions.append(lvms[i].wait_for_login(timeout=360))
         try:
             tmp = open(params.get('pid_' + vm_name), 'r')
             params['pid_' + vm_name] = int(tmp.readline())
diff --git a/client/tests/kvm/tests/linux_s3.py b/client/tests/kvm/tests/linux_s3.py
index 8a0f5eb..7758d08 100644
--- a/client/tests/kvm/tests/linux_s3.py
+++ b/client/tests/kvm/tests/linux_s3.py
@@ -13,7 +13,7 @@ def run_linux_s3(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     logging.info("Checking that VM supports S3")
     session.cmd("grep -q mem /sys/power/state")
diff --git a/client/tests/kvm/tests/mac_change.py b/client/tests/kvm/tests/mac_change.py
index 78fbab2..4876719 100644
--- a/client/tests/kvm/tests/mac_change.py
+++ b/client/tests/kvm/tests/mac_change.py
@@ -15,12 +15,11 @@ def run_mac_change(test, params, env):
     @param params: Dictionary with the test parameters.
     @param env: Dictionary with test environment.
     """
-    timeout = int(params.get("login_timeout", 360))
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session_serial = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2,
-                                                   serial=True)
+    timeout = int(params.get("login_timeout", 360))
+    session_serial = vm.wait_for_serial_login(timeout=timeout)
     # This session will be used to assess whether the IP change worked
-    session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)
+    session = vm.wait_for_login(timeout=timeout)
     old_mac = vm.get_mac_address(0)
     while True:
         vm.free_mac_address(0)
@@ -53,8 +52,7 @@ def run_mac_change(test, params, env):
 
     # Re-log into guest and check if session is responsive
     logging.info("Re-log into the guest")
-    session = kvm_test_utils.wait_for_login(vm,
-              timeout=int(params.get("login_timeout", 360)))
+    session = vm.wait_for_login(timeout=timeout)
     if not session.is_responsive():
         raise error.TestFail("The new session is not responsive.")
 
diff --git a/client/tests/kvm/tests/migration.py b/client/tests/kvm/tests/migration.py
index b9b86ba..234120c 100644
--- a/client/tests/kvm/tests/migration.py
+++ b/client/tests/kvm/tests/migration.py
@@ -21,7 +21,7 @@ def run_migration(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     mig_timeout = float(params.get("mig_timeout", "3600"))
     mig_protocol = params.get("migration_protocol", "tcp")
@@ -40,7 +40,7 @@ def run_migration(test, params, env):
 
     # Start another session with the guest and make sure the background
     # process is running
-    session2 = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session2 = vm.wait_for_login(timeout=timeout)
 
     try:
         check_command = params.get("migration_bg_check_command", "")
@@ -53,9 +53,7 @@ def run_migration(test, params, env):
 
         # Log into the guest again
         logging.info("Logging into guest after migration...")
-        # Temporary hack
-        time.sleep(30)
-        session2 = dest_vm.remote_login()
+        session2 = dest_vm.wait_for_login(timeout=30)
         logging.info("Logged in after migration")
 
         # Make sure the background process is still running
diff --git a/client/tests/kvm/tests/migration_multi_host.py b/client/tests/kvm/tests/migration_multi_host.py
index 15af0c8..4569531 100644
--- a/client/tests/kvm/tests/migration_multi_host.py
+++ b/client/tests/kvm/tests/migration_multi_host.py
@@ -47,7 +47,7 @@ def run_migration_multi_host(test, params, env):
     comm_port = int(params.get("comm_port", 12324))
     regain_ip_cmd = params.get("regain_ip_cmd", "dhclient")
     if role == 'source':
-        session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+        session = vm.wait_for_login(timeout=login_timeout)
 
         # Listen on a port to get the migration port received from
         # dest machine
@@ -100,9 +100,9 @@ def run_migration_multi_host(test, params, env):
 
         # Log into the guest again
         logging.info("Logging into migrated guest after migration...")
-        session_serial = kvm_test_utils.wait_for_login(vm, timeout=login_timeout, serial=True)
+        session_serial = vm.wait_for_serial_login(timeout=login_timeout)
         session_serial.cmd(regain_ip_cmd)
-        session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+        session = vm.wait_for_login(timeout=login_timeout)
 
     else:
         raise error.TestError('Invalid role specified')
diff --git a/client/tests/kvm/tests/migration_with_file_transfer.py b/client/tests/kvm/tests/migration_with_file_transfer.py
index 97c726b..f614d63 100644
--- a/client/tests/kvm/tests/migration_with_file_transfer.py
+++ b/client/tests/kvm/tests/migration_with_file_transfer.py
@@ -21,7 +21,7 @@ def run_migration_with_file_transfer(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     mig_timeout = float(params.get("mig_timeout", "3600"))
     mig_protocol = params.get("migration_protocol", "tcp")
diff --git a/client/tests/kvm/tests/migration_with_reboot.py b/client/tests/kvm/tests/migration_with_reboot.py
index cf25b6b..3d7ace8 100644
--- a/client/tests/kvm/tests/migration_with_reboot.py
+++ b/client/tests/kvm/tests/migration_with_reboot.py
@@ -38,23 +38,15 @@ def run_migration_with_reboot(test, params, env):
         # Try logging into the guest until timeout expires
         logging.info("Guest is down. Waiting for it to go up again, timeout "
                      "%ds", timeout)
-        session = None
-        end_time = time.time() + timeout
-        while time.time() < end_time:
-            try:
-                session = kvm_utils.remote_login(client, address, port,
-                                                 username, password, prompt,
-                                                 linesep, log_filename)
-            except kvm_utils.LoginError, e:
-                logging.debug(e)
-        if not session:
-            raise error.TestFail("Could not log into guest after reboot")
+        session = kvm_utils.wait_for_login(client, address, port, username,
+                                           password, prompt, linesep,
+                                           log_filename, timeout)
         logging.info("Guest is up again")
         session.close()
 
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     # params of reboot
     username = vm.params.get("username", "")
diff --git a/client/tests/kvm/tests/multicast.py b/client/tests/kvm/tests/multicast.py
index 39b580b..9b63146 100644
--- a/client/tests/kvm/tests/multicast.py
+++ b/client/tests/kvm/tests/multicast.py
@@ -19,8 +19,7 @@ def run_multicast(test, params, env):
     @param env: Dictionary with test environment.
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm,
-                                  timeout=int(params.get("login_timeout", 360)))
+    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
 
     def run_guest(cmd):
         try:
diff --git a/client/tests/kvm/tests/netperf.py b/client/tests/kvm/tests/netperf.py
index f1f3692..eaa868e 100644
--- a/client/tests/kvm/tests/netperf.py
+++ b/client/tests/kvm/tests/netperf.py
@@ -18,7 +18,7 @@ def run_netperf(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     login_timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+    session = vm.wait_for_login(timeout=login_timeout)
 
     netperf_dir = os.path.join(os.environ['AUTODIR'], "tests/netperf2")
     setup_cmd = params.get("setup_cmd")
diff --git a/client/tests/kvm/tests/nic_bonding.py b/client/tests/kvm/tests/nic_bonding.py
index 087b099..222ace2 100644
--- a/client/tests/kvm/tests/nic_bonding.py
+++ b/client/tests/kvm/tests/nic_bonding.py
@@ -32,8 +32,7 @@ def run_nic_bonding(test, params, env):
 
     timeout = int(params.get("login_timeout", 1200))
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session_serial = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2,
-                                                   serial=True)
+    session_serial = vm.wait_for_serial_login(timeout=timeout)
     script_path = kvm_utils.get_path(test.bindir, "scripts/bonding_setup.py")
     vm.copy_files_to(script_path, "/tmp/bonding_setup.py")
     cmd = "python /tmp/bonding_setup.py %s" % vm.get_mac_address()
diff --git a/client/tests/kvm/tests/nic_promisc.py b/client/tests/kvm/tests/nic_promisc.py
index 16a38a3..abcef25 100644
--- a/client/tests/kvm/tests/nic_promisc.py
+++ b/client/tests/kvm/tests/nic_promisc.py
@@ -18,11 +18,10 @@ def run_nic_promisc(test, params, env):
     @param params: Dictionary with the test parameters.
     @param env: Dictionary with test environment.
     """
-    timeout = int(params.get("login_timeout", 360))
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
-    session_serial = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2,
-                                                   serial=True)
+    timeout = int(params.get("login_timeout", 360))
+    session = vm.wait_for_login(timeout=timeout)
+    session_serial = vm.wait_for_serial_login(timeout=timeout)
 
     def compare(filename):
         md5_host = utils.hash_file(filename, method="md5")
diff --git a/client/tests/kvm/tests/nicdriver_unload.py b/client/tests/kvm/tests/nicdriver_unload.py
index f964e35..3c629bf 100644
--- a/client/tests/kvm/tests/nicdriver_unload.py
+++ b/client/tests/kvm/tests/nicdriver_unload.py
@@ -19,9 +19,8 @@ def run_nicdriver_unload(test, params, env):
     """
     timeout = int(params.get("login_timeout", 360))
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
-    session_serial = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2,
-                                                   serial=True)
+    session = vm.wait_for_login(timeout=timeout)
+    session_serial = vm.wait_for_serial_login(timeout=timeout)
 
     ethname = kvm_test_utils.get_linux_ifname(session, vm.get_mac_address(0))
     sys_path = "/sys/class/net/%s/device/driver" % (ethname)
diff --git a/client/tests/kvm/tests/pci_hotplug.py b/client/tests/kvm/tests/pci_hotplug.py
index 27b81de..1270f15 100644
--- a/client/tests/kvm/tests/pci_hotplug.py
+++ b/client/tests/kvm/tests/pci_hotplug.py
@@ -21,7 +21,7 @@ def run_pci_hotplug(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     # Modprobe the module if specified in config file
     module = params.get("modprobe_module")
diff --git a/client/tests/kvm/tests/physical_resources_check.py b/client/tests/kvm/tests/physical_resources_check.py
index 3234da7..1875f07 100644
--- a/client/tests/kvm/tests/physical_resources_check.py
+++ b/client/tests/kvm/tests/physical_resources_check.py
@@ -19,7 +19,7 @@ def run_physical_resources_check(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_serial_login(timeout=timeout)
 
     logging.info("Starting physical resources check test")
     logging.info("Values assigned to VM are the values we expect "
diff --git a/client/tests/kvm/tests/ping.py b/client/tests/kvm/tests/ping.py
index 9b2308f..d206848 100644
--- a/client/tests/kvm/tests/ping.py
+++ b/client/tests/kvm/tests/ping.py
@@ -18,9 +18,8 @@ def run_ping(test, params, env):
     @param params: Dictionary with the test parameters.
     @param env: Dictionary with test environment.
     """
-
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm)
+    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
 
     counts = params.get("ping_counts", 100)
     flood_minutes = float(params.get("flood_minutes", 10))
diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py
index 6351a84..b1df0ea 100644
--- a/client/tests/kvm/tests/qemu_img.py
+++ b/client/tests/kvm/tests/qemu_img.py
@@ -292,7 +292,7 @@ def run_qemu_img(test, params, env):
             vm = env.get_vm(vm_name)
             vm.create()
             timeout = int(params.get("login_timeout", 360))
-            session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+            session = vm.wait_for_login(timeout=timeout)
 
             # Do some changes to the backing_file harddisk
             try:
@@ -320,7 +320,7 @@ def run_qemu_img(test, params, env):
             vm = env.get_vm(vm_name)
             vm.create()
             timeout = int(params.get("login_timeout", 360))
-            session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+            session = vm.wait_for_login(timeout=timeout)
             try:
                 output = session.cmd("[ ! -e /commit_testfile ] && echo $?")
                 logging.info("Output of [ ! -e /commit_testfile ] && echo $?: "
@@ -346,7 +346,7 @@ def run_qemu_img(test, params, env):
             vm = env.get_vm(vm_name)
             vm.create()
             timeout = int(params.get("login_timeout", 360))
-            session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+            session = vm.wait_for_login(timeout=timeout)
             try:
                 output = session.cmd("[ -e /commit_testfile ] && echo $?")
                 logging.info("Output of [ -e /commit_testfile ] && echo $?: %s",
diff --git a/client/tests/kvm/tests/shutdown.py b/client/tests/kvm/tests/shutdown.py
index bfc5477..1150211 100644
--- a/client/tests/kvm/tests/shutdown.py
+++ b/client/tests/kvm/tests/shutdown.py
@@ -17,7 +17,7 @@ def run_shutdown(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     try:
         if params.get("shutdown_method") == "shell":
diff --git a/client/tests/kvm/tests/stress_boot.py b/client/tests/kvm/tests/stress_boot.py
index 8bdee95..620d5f0 100644
--- a/client/tests/kvm/tests/stress_boot.py
+++ b/client/tests/kvm/tests/stress_boot.py
@@ -22,7 +22,7 @@ def run_stress_boot(tests, params, env):
     logging.info("Waiting for first guest to be up...")
 
     login_timeout = float(params.get("login_timeout", 240))
-    session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+    session = vm.wait_for_login(timeout=login_timeout)
 
     num = 2
     sessions = [session]
@@ -39,9 +39,7 @@ def run_stress_boot(tests, params, env):
             kvm_preprocessing.preprocess_vm(tests, vm_params, env, vm_name)
             params['vms'] += " " + vm_name
 
-            # Temporary hack
-            time.sleep(login_timeout)
-            sessions.append(curr_vm.remote_login())
+            sessions.append(curr_vm.wait_for_login(timeout=login_timeout))
             logging.info("Guest #%d boots up successfully" % num)
 
             # check whether all previous shell sessions are responsive
diff --git a/client/tests/kvm/tests/timedrift.py b/client/tests/kvm/tests/timedrift.py
index 7951d6e..489cf9d 100644
--- a/client/tests/kvm/tests/timedrift.py
+++ b/client/tests/kvm/tests/timedrift.py
@@ -54,7 +54,7 @@ def run_timedrift(test, params, env):
 
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     # Collect test parameters:
     # Command to run to get the current time
diff --git a/client/tests/kvm/tests/timedrift_with_migration.py b/client/tests/kvm/tests/timedrift_with_migration.py
index 199a414..6cb79dc 100644
--- a/client/tests/kvm/tests/timedrift_with_migration.py
+++ b/client/tests/kvm/tests/timedrift_with_migration.py
@@ -19,7 +19,7 @@ def run_timedrift_with_migration(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     # Collect test parameters:
     # Command to run to get the current time
@@ -50,9 +50,7 @@ def run_timedrift_with_migration(test, params, env):
             vm = kvm_test_utils.migrate(vm, env)
             # Log in
             logging.info("Logging in after migration...")
-            # Temporary hack
-            time.sleep(30)
-            session = vm.remote_login()
+            session = vm.wait_for_login(timeout=30)
             logging.info("Logged in after migration")
             # Get time after current iteration
             (ht1_, gt1_) = kvm_test_utils.get_time(session, time_command,
diff --git a/client/tests/kvm/tests/timedrift_with_reboot.py b/client/tests/kvm/tests/timedrift_with_reboot.py
index 22dfd45..7668bdd 100644
--- a/client/tests/kvm/tests/timedrift_with_reboot.py
+++ b/client/tests/kvm/tests/timedrift_with_reboot.py
@@ -19,7 +19,7 @@ def run_timedrift_with_reboot(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     # Collect test parameters:
     # Command to run to get the current time
diff --git a/client/tests/kvm/tests/timedrift_with_stop.py b/client/tests/kvm/tests/timedrift_with_stop.py
index 3473276..27a1472 100644
--- a/client/tests/kvm/tests/timedrift_with_stop.py
+++ b/client/tests/kvm/tests/timedrift_with_stop.py
@@ -22,7 +22,7 @@ def run_timedrift_with_stop(test, params, env):
     login_timeout = int(params.get("login_timeout", 360))
     sleep_time = int(params.get("sleep_time", 30))
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+    session = vm.wait_for_login(timeout=login_timeout)
 
     # Collect test parameters:
     # Command to run to get the current time
diff --git a/client/tests/kvm/tests/virtio_console.py b/client/tests/kvm/tests/virtio_console.py
index 5c651a3..d7aaaf6 100644
--- a/client/tests/kvm/tests/virtio_console.py
+++ b/client/tests/kvm/tests/virtio_console.py
@@ -585,9 +585,7 @@ def run_virtio_console(test, params, env):
 
         vm = env.get_vm(params.get("main_vm"))
 
-        session = kvm_test_utils.wait_for_login(vm, 0,
-                                         float(params.get("boot_timeout", 240)),
-                                         0, 2)
+        session = vm.wait_for_login(float(params.get("boot_timeout", 240)))
 
         # connect the sockets
         for i in range(0, no_console):
@@ -1134,9 +1132,7 @@ def run_virtio_console(test, params, env):
             logging.error("Python died/is stucked/have remaining threads")
             logging.debug(tmp)
             vm[1].close()
-            vm[1] = kvm_test_utils.wait_for_login(vm[0], 0,
-                                         float(params.get("boot_timeout", 240)),
-                                         0, 2)
+            vm[1] = vm[0].wait_for_login(float(params.get("boot_timeout", 240)))
             (match, data) = _on_guest("killall -9 python "
                                       "&& echo -n PASS: python killed"
                                       "|| echo -n PASS: python was death",
diff --git a/client/tests/kvm/tests/vlan.py b/client/tests/kvm/tests/vlan.py
index 69a136b..f35e3a7 100644
--- a/client/tests/kvm/tests/vlan.py
+++ b/client/tests/kvm/tests/vlan.py
@@ -18,7 +18,6 @@ def run_vlan(test, params, env):
     @param params: Dictionary with the test parameters.
     @param env: Dictionary with test environment.
     """
-
     vm = []
     session = []
     ifname = []
@@ -79,8 +78,8 @@ def run_vlan(test, params, env):
         session[dst].cmd_output("rm -f receive")
 
     for i in range(2):
-        session.append(kvm_test_utils.wait_for_login(vm[i],
-                       timeout=int(params.get("login_timeout", 360))))
+        session.append(vm[i].wait_for_login(
+            timeout=int(params.get("login_timeout", 360))))
         if not session[i] :
             raise error.TestError("Could not log into guest(vm%d)" % i)
         logging.info("Logged in")
@@ -135,8 +134,7 @@ def run_vlan(test, params, env):
                 # we must use a dedicated session becuase the kvm_subprocess
                 # does not have the other method to interrupt the process in
                 # the guest rather than close the session.
-                session_flood = kvm_test_utils.wait_for_login(vm[src],
-                                                              timeout = 60)
+                session_flood = vm[src].wait_for_login(timeout=60)
                 kvm_test_utils.ping(vlan_ip[dst], flood=True,
                                    interface=ifname[src],
                                    session=session_flood, timeout=10)
diff --git a/client/tests/kvm/tests/vmstop.py b/client/tests/kvm/tests/vmstop.py
index 876c3ef..c3a4cb5 100644
--- a/client/tests/kvm/tests/vmstop.py
+++ b/client/tests/kvm/tests/vmstop.py
@@ -20,7 +20,7 @@ def run_vmstop(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = float(params.get("login_timeout", 240))
-    session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)
+    session = vm.wait_for_login(timeout=timeout)
 
     save_path = params.get("save_path", "/tmp")
     clean_save = params.get("clean_save") == "yes"
diff --git a/client/tests/kvm/tests/whql_client_install.py b/client/tests/kvm/tests/whql_client_install.py
index c2616c6..589f258 100644
--- a/client/tests/kvm/tests/whql_client_install.py
+++ b/client/tests/kvm/tests/whql_client_install.py
@@ -22,7 +22,7 @@ def run_whql_client_install(test, params, env):
     @param env: Dictionary with test environment.
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-    session = kvm_test_utils.wait_for_login(vm, 0, 240)
+    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
 
     # Collect test params
     server_address = params.get("server_address")
diff --git a/client/tests/kvm/tests/whql_submission.py b/client/tests/kvm/tests/whql_submission.py
index ae71942..2c0f367 100644
--- a/client/tests/kvm/tests/whql_submission.py
+++ b/client/tests/kvm/tests/whql_submission.py
@@ -19,17 +19,18 @@ def run_whql_submission(test, params, env):
     @param env: Dictionary with test environment.
     """
     # Log into all client VMs
+    login_timeout = int(params.get("login_timeout", 360))
     vms = []
     sessions = []
     for vm_name in params.objects("vms"):
         vms.append(kvm_test_utils.get_living_vm(env, vm_name))
-        sessions.append(kvm_test_utils.wait_for_login(vms[-1], 0, 240))
+        sessions.append(vms[-1].wait_for_login(timeout=login_timeout))
 
     # Make sure all NICs of all client VMs are up
     for vm in vms:
         nics = vm.params.objects("nics")
         for nic_index in range(len(nics)):
-            s = kvm_test_utils.wait_for_login(vm, nic_index, 600)
+            s = vm.wait_for_login(nic_index, 600)
             s.close()
 
     # Collect parameters
@@ -79,7 +80,7 @@ def run_whql_submission(test, params, env):
     for vm in vms:
         nics = vm.params.objects("nics")
         for nic_index in range(len(nics)):
-            s = kvm_test_utils.wait_for_login(vm, nic_index, 600)
+            s = vm.wait_for_login(nic_index, 600)
             s.close()
 
     # Run whql_pre_command and close the sessions
diff --git a/client/tests/kvm/tests/yum_update.py b/client/tests/kvm/tests/yum_update.py
index 1a2bfae..62bb4f3 100644
--- a/client/tests/kvm/tests/yum_update.py
+++ b/client/tests/kvm/tests/yum_update.py
@@ -40,7 +40,7 @@ def run_yum_update(test, params, env):
     """
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
-    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+    session = vm.wait_for_login(timeout=timeout)
 
     internal_yum_update(session, "yum update", params.get("shell_prompt"), 600)
     internal_yum_update(session, "yum update kernel",
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux