[PATCH 3/4] KVM test: Refine image_check function

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

 



With the accumulated experience running the KVM test to
perform quality control on our KVM branches, we noticed
that qemu-img check might return exit code != 0, but
not all failures mean some data integrity problem happend.

After checking qemu-img check code, we found out that:

Exit code 1: Check error. Problem on the check itself,
most of the time harmless, however there is some risk
of data corruption.

Exit code 2: Data corruption error. This means for sure
that disk corruption happened. Bad, bad.

Exit code 3: Leaked clusters error. This means some
leaked clusters were found on the image, which is not
a data corruption condition, it only means that some
space is going to be lost on that image.

So, refine the logic of the image_check function, executing
qemu-img check and verifying its exit code

Exit code 1: Raise error.TestWarn
Exit code 2: Raise VMImageError
Exit code 3: Raise error.TestWarn

This change, together with the new logic of the KVM
run_tests() utility function, will make it possible
to still fail tests in cases 1) and 3), but letting
the dependencies to be executed.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/kvm_vm.py |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 8114670..445ba6b 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -294,10 +294,23 @@ def check_image(params, root_dir):
             except error.CmdError:
                 logging.error("Error getting info from image %s",
                               image_filename)
-            try:
-                utils.system("%s check %s" % (qemu_img_cmd, image_filename))
-            except error.CmdError:
+
+            cmd_result = utils.run("%s check %s" %
+                                   (qemu_img_cmd, image_filename),
+                                   ignore_status=True)
+            # Error check, large chances of a non-fatal problem.
+            # There are chances that bad data was skipped though
+            if cmd_result.exit_status == 1:
+                raise error.TestWarn("qemu-img check error. Some bad data in "
+                                     "the image may have gone unnoticed")
+            # Exit status 2 is data corruption for sure, so fail the test
+            elif cmd_result.exit_status == 2:
                 raise VMImageCheckError(image_filename)
+            # Leaked clusters, they are known to be harmless to data integrity
+            elif cmd_result.exit_status == 3:
+                raise error.TestWarn("Leaked clusters were noticed during "
+                                     "image check. No data integrity problem "
+                                     "was found though.")
 
     else:
         if not os.path.exists(image_filename):
-- 
1.7.4.2

--
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