From patchwork Wed Oct 31 17:19:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Zupka X-Patchwork-Id: 1680461 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 98D7CDFB80 for ; Wed, 31 Oct 2012 17:20:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758526Ab2JaRUC (ORCPT ); Wed, 31 Oct 2012 13:20:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64523 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754786Ab2JaRT7 (ORCPT ); Wed, 31 Oct 2012 13:19:59 -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 q9VHJbli005009 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 31 Oct 2012 13:19:38 -0400 Received: from jzupka-pc.local.com (dhcp-26-242.brq.redhat.com [10.34.26.242]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9VHJWIe001215; Wed, 31 Oct 2012 13:19:36 -0400 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=BDupka?= To: autotest@test.kernel.org, kvm@vger.kernel.org, kvm-autotest@redhat.com, lmr@redhat.com, ldoktor@redhat.com, jzupka@redhat.com Subject: [Autotest][PATCH 2/4] virt: Multihost-migrate stops unnecessary vm disk clone. Date: Wed, 31 Oct 2012 18:19:26 +0100 Message-Id: <1351703968-27007-3-git-send-email-jzupka@redhat.com> In-Reply-To: <1351703968-27007-1-git-send-email-jzupka@redhat.com> References: <1351703968-27007-1-git-send-email-jzupka@redhat.com> MIME-Version: 1.0 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 If force_image_clone == no then only check vm image consistency. If vm image consistency is good use old image else copy again from original. Remove image if consistency is not correct after finish of test. Signed-off-by: Ji?í Župka --- shared/cfg/subtests.cfg.sample | 2 ++ virttest/env_process.py | 17 +++++++++++++++-- virttest/storage.py | 8 +++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/shared/cfg/subtests.cfg.sample b/shared/cfg/subtests.cfg.sample index 0fcc1bf..2286690 100644 --- a/shared/cfg/subtests.cfg.sample +++ b/shared/cfg/subtests.cfg.sample @@ -1187,6 +1187,8 @@ variants: test_control_file = monotonic_time.control - @multi_host: + remove_image_on_check_error = yes + force_image_clone = no virt_test_type = kvm no JeOS variants: diff --git a/virttest/env_process.py b/virttest/env_process.py index b4e2293..0481178 100644 --- a/virttest/env_process.py +++ b/virttest/env_process.py @@ -120,6 +120,7 @@ def postprocess_image(test, params, image_name): @param test: An Autotest test object. @param params: A dict containing image postprocessing parameters. """ + clone_master = params.get("clone_master", None) base_dir = data_dir.get_data_dir() if params.get("storage_type") == "iscsi": iscsidev = kvm_storage.Iscsidev(params, base_dir, image_name) @@ -128,13 +129,25 @@ def postprocess_image(test, params, image_name): image = kvm_storage.QemuImg(params, base_dir, image_name) if params.get("check_image") == "yes": try: - image.check_image(params, base_dir) + if clone_master is None: + image.check_image(params, base_dir) + elif clone_master == "yes": + if image_name in params.get("master_images_clone").split(): + image.check_image(params, base_dir) except Exception, e: if params.get("restore_image_on_check_error", "no") == "yes": image.backup_image(params, base_dir, "restore", True) + if params.get("remove_image_on_check_error", "no") == "yes": + cl_images = params.get("master_images_clone", "") + if image_name in cl_images.split(): + image.remove() raise e if params.get("remove_image") == "yes": - image.remove() + if clone_master is None: + image.remove() + elif clone_master == "yes": + if image_name in params.get("master_images_clone").split(): + image.remove() def postprocess_vm(test, params, env, name): diff --git a/virttest/storage.py b/virttest/storage.py index 0e877d6..8fe560b 100644 --- a/virttest/storage.py +++ b/virttest/storage.py @@ -288,9 +288,11 @@ class QemuImg(object): m_image_fn = get_image_filename(params, root_dir) image_fn = get_image_filename(image_params, root_dir) - logging.info("Clone master image for vms.") - utils.run(params.get("image_clone_commnad") % (m_image_fn, - image_fn)) + force_clone = params.get("force_image_clone", "no") + if not os.path.exists(image_fn) or force_clone == "yes": + logging.info("Clone master image for vms.") + utils.run(params.get("image_clone_commnad") % (m_image_fn, + image_fn)) params["image_name_%s_%s" % (image_name, vm_name)] = vm_image_name