Skip to contentSkip to conversation

KVM test: Avoid race condition on boot_savevm

PATCH New Lucas Meneghel Rodrigues 1 participant 4 messages Nov 30, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 KVM test: Avoid race condition on boot_savevm

As while loops termination conditions are checked at the beginning of the loop, if we successfuly log onto the vm on the last cycle, but the timeout happened to be ended by then, we'd have a test failure.

So, introduce a variable that records whether the test managed to log onto the VM, and use this variable as the criteria for PASS/FAIL.

---
 client/tests/kvm/tests/boot_savevm.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
client/tests/kvm/tests/boot_savevm.py +3 -1
index 91199fb..d02463d 100644
@@ -21,6 +21,7 @@ def run_boot_savevm(test, params, env):
     savevm_login_delay = float(params.get("savevm_login_delay"))
     end_time = time.time() + float(params.get("savevm_timeout"))
 
+    successful_login = False
     while time.time() < end_time:
         time.sleep(savevm_delay)
         try:
@@ -46,10 +47,11 @@ def run_boot_savevm(test, params, env):
 
         try:
             vm.wait_for_login(timeout=savevm_login_delay)
+            successful_login = True
             break
         except Exception, detail:
             logging.debug(detail)
 
-    if (time.time() > end_time):
+    if not successful_login:
         raise error.TestFail("Not possible to log onto the vm after %s s" %
                              params.get("savevm_timeout"))
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 2/4 KVM test: boot_savevm: Add more debug and kernel panic detection

Print total time elapsed and number of save/load VM cycles performed during the test. Also, verify whether a kernel panic happened during the test execution.

---
 client/tests/kvm/tests/boot_savevm.py |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
client/tests/kvm/tests/boot_savevm.py +17 -6
index d02463d..d4899de 100644
@@ -19,10 +19,14 @@ def run_boot_savevm(test, params, env):
     vm.verify_alive()
     savevm_delay = float(params.get("savevm_delay"))
     savevm_login_delay = float(params.get("savevm_login_delay"))
-    end_time = time.time() + float(params.get("savevm_timeout"))
+    savevm_login_timeout = float(params.get("savevm_timeout"))
+    start_time = time.time()
+
+    cycles = 0
 
     successful_login = False
-    while time.time() < end_time:
+    while (time.time() - start_time) < savevm_login_timeout:
+        logging.info("Save/load cycle %d", cycles + 1)
         time.sleep(savevm_delay)
         try:
             vm.monitor.cmd("stop")
@@ -45,13 +49,20 @@ def run_boot_savevm(test, params, env):
         except kvm_monitor.MonitorError, e:
             logging.error(e)
 
+        vm.verify_kernel_crash()
+
         try:
             vm.wait_for_login(timeout=savevm_login_delay)
             successful_login = True
             break
-        except Exception, detail:
-            logging.debug(detail)
+        except:
+            pass
+
+        cycles += 1
 
+    time_elapsed = int(time.time() - start_time)
+    info = "after %s s, %d load/save cycles" % (time_elapsed, cycles + 1)
     if not successful_login:
-        raise error.TestFail("Not possible to log onto the vm after %s s" %
-                             params.get("savevm_timeout"))
+        raise error.TestFail("Can't log on '%s' %s" % (vm.name, info))
+    else:
+        logging.info("Test ended %s", info)
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH 3/4 KVM test: subtests.cfg.sample: Decrease boot_savevm login timeout

In reply to Lucas Meneghel Rodrigues

This way we'll have much more stress by doing more save/load cycles during boot time. We did see some disk corruption problems using this value, but the condition is not 100% reproducible.

---
 client/tests/kvm/subtests.cfg.sample |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/subtests.cfg.sample +1 -1
index 03ddbe2..55f1b21 100644
@@ -348,7 +348,7 @@ variants:
     - boot_savevm: install setup image_copy unattended_install.cdrom
         type = boot_savevm
         savevm_delay = 0.3
-        savevm_login_delay = 120
+        savevm_login_delay = 5
         savevm_timeout = 2000
         kill_vm_on_error = yes
         kill_vm_gracefully = yes
Signature · 1 line
1.7.7.3
#3 lore raw

PATCH 4/4 Virt: screendump thread - handle IOErrors on PPM conversion

In reply to Lucas Meneghel Rodrigues

Under some conditions, monitor screendumps can get truncated, generating IOError exceptions during PIL conversion. So handle those errors and log a warning rather than failing the entire screendump thread.

---
 client/virt/virt_env_process.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
client/virt/virt_env_process.py +11 -3
index 3f996ca..ab2f77e 100644
@@ -511,9 +511,17 @@ def _take_screendumps(test, params, env):
                     pass
             else:
                 try:
-                    image = PIL.Image.open(temp_filename)
-                    image.save(screendump_filename, format="JPEG", quality=quality)
-                    cache[hash] = screendump_filename
+                    try:
+                        image = PIL.Image.open(temp_filename)
+                        image.save(screendump_filename, format="JPEG",
+                                   quality=quality)
+                        cache[hash] = screendump_filename
+                    except IOError, error_detail:
+                        logging.warning("VM '%s' failed to produce a "
+                                        "screendump: %s", vm.name, error_detail)
+                        # Decrement the counter as we in fact failed to
+                        # produce a converted screendump
+                        counter[vm] -= 1
                 except NameError:
                     pass
             os.unlink(temp_filename)
Signature · 1 line
1.7.7.3