From c875bf9054577a8aa1f874499959a88cce40f98d Mon Sep 17 00:00:00 2001 From: Ping Li Date: Thu, 8 Nov 2018 22:46:25 +0800 Subject: [PATCH] live_snapshot_chain: Flush data to disk before running system_reset QMP command 'system_reset' is issued after creating files in the guest. The command has an effect similar to the physical reset button on a PC. But filesystems may be left in an unclean state which causes the loss of data. Run the command "sync" to flush the data to disk. Signed-off-by: Ping Li --- qemu/tests/cfg/live_snapshot_chain.cfg | 5 +++++ qemu/tests/live_snapshot_chain.py | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/qemu/tests/cfg/live_snapshot_chain.cfg b/qemu/tests/cfg/live_snapshot_chain.cfg index 23953167..ff37c94b 100644 --- a/qemu/tests/cfg/live_snapshot_chain.cfg +++ b/qemu/tests/cfg/live_snapshot_chain.cfg @@ -14,6 +14,11 @@ check_alive_cmd = "ls" kill_vm = yes remove_snapshot_images = yes + Windows: + x86_64: + sync_bin = WIN_UTILS:\Sync\sync64.exe /accepteula + i386, i686: + sync_bin = WIN_UTILS:\Sync\sync.exe /accepteula variants: - @default: - with_data_plane: diff --git a/qemu/tests/live_snapshot_chain.py b/qemu/tests/live_snapshot_chain.py index 6c35b77c..47324844 100644 --- a/qemu/tests/live_snapshot_chain.py +++ b/qemu/tests/live_snapshot_chain.py @@ -7,6 +7,7 @@ from virttest import error_context from virttest import storage from virttest import qemu_storage from virttest import data_dir +from virttest import utils_misc @error_context.context_aware @@ -90,10 +91,12 @@ def run(test, params, env): file_dir = params.get("file_dir") dir_create_cmd = params.get("dir_create_cmd") md5_cmd = params.get("md5_cmd") + sync_cmd = params.get("sync_bin", "sync") snapshot_chain = generate_snapshot_chain(snapshot_chain, snapshot_num) snapshot_chain = re.split(r"\s+", snapshot_chain) session = vm.wait_for_login(timeout=timeout) + sync_cmd = utils_misc.set_winutils_letter(session, sync_cmd) md5_value = {} files_in_guest = {} @@ -134,6 +137,10 @@ def run(test, params, env): session.cmd(file_create_cmd % image) md5 = session.cmd_output(md5_cmd % image) md5_value[image] = {image: md5} + status, output = session.cmd_status_output(sync_cmd) + if status != 0: + test.error("Execute '%s' with failures('%s') " % + (sync_cmd, output)) if image_params.get("check_alive_cmd"): session.cmd(image_params.get("check_alive_cmd")) if image_params.get("file_create"): -- GitLab