From patchwork Fri Apr 8 05:08:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 694001 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p388EDta003611 for ; Fri, 8 Apr 2011 08:15:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455Ab1DHFIr (ORCPT ); Fri, 8 Apr 2011 01:08:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752227Ab1DHFIk (ORCPT ); Fri, 8 Apr 2011 01:08:40 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3858cMi030894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Apr 2011 01:08:38 -0400 Received: from freedom.redhat.com (vpn-8-92.rdu.redhat.com [10.11.8.92]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3858QKh008833; Fri, 8 Apr 2011 01:08:36 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, crosa@redhat.com, ehabkost@redhat.com, mgoldish@redhat.com, jadmanski@google.com, 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> In-Reply-To: <1302239305-15786-1-git-send-email-lmr@redhat.com> References: <1302239305-15786-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Apr 2011 08:15:22 +0000 (UTC) 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):