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 <jzupka@xxxxxxxxxx> --- 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 -- 1.7.7.6 -- 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