From: Lucas Meneghel Rodrigues Subject: [PATCH 3/4] KVM test: Refine image_check function Date: Fri, 8 Apr 2011 02:08:24 -0300 Message-ID: <1302239305-15786-4-git-send-email-lmr@redhat.com> References: <1302239305-15786-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: ehabkost@redhat.com, kvm@vger.kernel.org To: autotest@test.kernel.org Return-path: In-Reply-To: <1302239305-15786-1-git-send-email-lmr@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org 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 --- 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