From c50e888fd4a1e7759921634e93b19a36ea95a4b5 Mon Sep 17 00:00:00 2001 From: Feng Yang Date: Thu, 3 May 2012 14:49:40 +0000 Subject: [PATCH] virt test: Check windows bsod dump when unattended_install fail. If unattended_install fail for windows guest and rename_error_image set, image_copy will call rename the fail image. Then call win_bsod_catch.py to check whether dump file is created in guest. If yes, will try to analyze dump file with Windbg. resolved conflict in tests/image_copy.py and remove a blank space. Signed-off-by: Feng Yang signed-off-by: Yiqiao Pu --- tests/image_copy.py | 59 ++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/tests/image_copy.py b/tests/image_copy.py index ffea7824..6f95af9e 100644 --- a/tests/image_copy.py +++ b/tests/image_copy.py @@ -1,7 +1,7 @@ import os, logging from autotest.client.shared import error from autotest.client import utils -from virttest import utils_misc, data_dir +from virttest import utils_misc, data_dir, utils_test def run_image_copy(test, params, env): @@ -15,6 +15,10 @@ def run_image_copy(test, params, env): @param params: Dictionary with the test parameters @param env: Dictionary with test environment. """ + vm = env.get_vm(params["main_vm"]) + if vm is not None: + vm.destroy() + mount_dest_dir = params.get('dst_dir', '/mnt/images') if not os.path.exists(mount_dest_dir): try: @@ -31,22 +35,39 @@ def run_image_copy(test, params, env): params['image_format']) src_path = os.path.join(mount_dest_dir, image) dst_path = '%s/%s.%s' % (data_dir.get_data_dir(), params['image_name'], params['image_format']) + pwd = os.path.join(test.bindir, "images") + if params.get("rename_error_image", "no") == "yes": + error_image = os.path.basename(image_name) + "-error" + error_image += '.' + params['image_format'] + error_dst_path = os.path.join(pwd, error_image) + mv_cmd = "/bin/mv %s %s" % (dst_path, error_dst_path) + utils.system(mv_cmd, timeout=360, ignore_status=True) + + try: + error.context("Mount the NFS share directory") + if not utils_misc.mount(src, mount_dest_dir, 'nfs', 'ro'): + raise error.TestError('Could not mount NFS share %s to %s' % + (src, mount_dest_dir)) + + # Check the existence of source image + error.context("Check the existence of source image") + if os.path.exists("%s.xz" % src_path): + logging.debug('Copying image %s (from xz) ...', image) + cmd = "xz -cd %s.xz > %s" % (src_path, dst_path) + elif os.path.exists("%s.gz" % src_path): + logging.debug('Copying image %s (from gzip) ...', image) + cmd = "gzip -cd %s.gz > %s" % (src_path, dst_path) + elif os.path.exists(src_path): + logging.debug('Copying image %s (uncompressed) ...', image) + cmd = 'cp %s %s' % (src_path, dst_path) + else: + raise error.TestError('Could not find %s in NFS share' % src_path) - if not utils_misc.mount(src, mount_dest_dir, 'nfs', 'ro'): - raise error.TestError('Could not mount NFS share %s to %s' % - (src, mount_dest_dir)) - - # Check the existence of source image - if os.path.exists("%s.xz" % src_path): - logging.debug('Copying image %s (from xz) ...', image) - cmd = "xz -cd %s.xz > %s" % (src_path, dst_path) - elif os.path.exists("%s.gz" % src_path): - logging.debug('Copying image %s (from gzip) ...', image) - cmd = "gzip -cd %s.gz > %s" % (src_path, dst_path) - elif os.path.exists(src_path): - logging.debug('Copying image %s (uncompressed) ...', image) - cmd = 'cp %s %s' % (src_path, dst_path) - else: - raise error.TestError('Could not find %s in NFS share' % src_path) - - utils.system(cmd) + utils.system(cmd) + finally: + if params.get("sub_type"): + params['image_name'] += "-error" + params['boot_once'] = "c" + vm.create(params=params) + utils_test.run_virt_sub_test(test, params, env, + params.get("sub_type")) -- GitLab