From 603b100ba151c3b26e4eba54e3662655c6d7bc40 Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Wed, 5 Feb 2020 13:56:01 +0200 Subject: [PATCH] migrate.py: do not run with snapshot Instead, create a new image with backing-file of the original image (a "permanent" snapshot), use it during the test and remove it at the end. Also use 'writeback' cache instead of 'unsafe'. Signed-off-by: Uri Lublin squash: actually remove the snapshot. mention cache change --- tests/migrate.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/migrate.py b/tests/migrate.py index a8962389..a0739ba3 100755 --- a/tests/migrate.py +++ b/tests/migrate.py @@ -100,7 +100,7 @@ def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, w + incoming_args + extra_args) if os.path.exists(image): args += ["-m", "512", "-enable-kvm", "-drive", - "file=%s,index=0,media=disk,cache=unsafe" % image, "-snapshot"] + "file=%s,index=0,media=disk,cache=writeback" % image] # print qemu command line for the first run if not incoming_port: @@ -156,6 +156,9 @@ def cleanup(migrator): print("doing cleanup") migrator.close() +def remove_image_file(filename): + run_shell_command('rm -f %s' % filename) + class Migrator(object): migration_count = 0 @@ -246,11 +249,16 @@ def main(): print("log file %s" % args.log_filename) log = open(args.log_filename, "a+") log.write("# "+str(datetime.datetime.now())+"\n") + newimage = run_shell_command("mktemp --dry-run /tmp/migrate_XXXXXX.qcow2") + qemu_img = run_shell_command("dirname %s" % args.qemu_exec) + '/qemu-img' + run_shell_command('%s create -f qcow2 -b %s %s' % (qemu_img, args.image, newimage)) + print('using new image %s' % newimage) migrator = Migrator(client=args.client, qemu_exec=args.qemu_exec, - image=args.image, log=log, monitor_files=[args.qmp1, args.qmp2], + image=newimage, log=log, monitor_files=[args.qmp1, args.qmp2], migration_port=args.migrate_port, spice_ports=[args.spice_port1, args.spice_port2], vdagent=args.vdagent) atexit.register(cleanup, migrator) + atexit.register(remove_image_file, newimage) counter = 0 while args.counter == 0 or counter < args.counter: migrator.iterate(args.wait_user_input, args.wait_user_connect)