From patchwork Fri Apr 8 15:07:29 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: 694821 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 p38F7r1u002235 for ; Fri, 8 Apr 2011 15:07:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757503Ab1DHPHk (ORCPT ); Fri, 8 Apr 2011 11:07:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51131 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757204Ab1DHPHi (ORCPT ); Fri, 8 Apr 2011 11:07:38 -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 p38F7bux030441 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Apr 2011 11:07:38 -0400 Received: from freedom.redhat.com (vpn-10-185.rdu.redhat.com [10.11.10.185]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p38F7V9R004524; Fri, 8 Apr 2011 11:07:36 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 3/4] KVM test: Refine image_check function Date: Fri, 8 Apr 2011 12:07:29 -0300 Message-Id: <1302275250-6215-4-git-send-email-lmr@redhat.com> In-Reply-To: <1302275250-6215-1-git-send-email-lmr@redhat.com> References: <1302275250-6215-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 15:07:53 +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. Changes from v1: * Print stdout and stderr of the checking program in cases 1) and 2), to help debug eventual problems. Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/kvm_vm.py | 27 ++++++++++++++++++++++++--- 1 files changed, 24 insertions(+), 3 deletions(-) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 8114670..f004f4f 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -294,10 +294,31 @@ 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: + for e_line in cmd_result.stdout.splitlines(): + logging.error("[stdout] %s", e_line) + for e_line in cmd_result.stderr.splitlines(): + logging.error("[stderr] %s", e_line) + 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: + for e_line in cmd_result.stdout.splitlines(): + logging.error("[stdout] %s", e_line) + for e_line in cmd_result.stderr.splitlines(): + logging.error("[stderr] %s", e_line) 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):