[Spice-commits] 8 commits - tests/migrate.py
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Feb 24 14:56:09 UTC 2020
tests/migrate.py | 55 ++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 40 insertions(+), 15 deletions(-)
New commits:
commit 603b100ba151c3b26e4eba54e3662655c6d7bc40
Author: Uri Lublin <uril at redhat.com>
Date: Wed Feb 5 13:56:01 2020 +0200
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 <uril at redhat.com>
squash: actually remove the snapshot. mention cache change
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)
commit eafde163586317a803a37d18f8d1d95dc055c0f3
Author: Uri Lublin <uril at redhat.com>
Date: Wed Jan 1 15:25:21 2020 +0200
migrate.py: a helper function for shell commands
Signed-off-by: Uri Lublin <uril at redhat.com>
diff --git a/tests/migrate.py b/tests/migrate.py
index 0505ee2b..a8962389 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -51,6 +51,9 @@ import argparse
if sys.version_info[0] == 3:
raw_input = input
+def run_shell_command(cmd):
+ return os.popen(cmd).read().strip()
+
def get_args():
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--qmp1', dest='qmp1', default='/tmp/migrate_test.1.qmp')
@@ -75,7 +78,7 @@ def get_args():
if os.path.exists(args.qemu):
args.qemu_exec = args.qemu
else:
- args.qemu_exec = os.popen("which %s" % args.qemu).read().strip()
+ args.qemu_exec = run_shell_command("which %s" % args.qemu)
if not os.path.exists(args.qemu_exec):
print("qemu not found (qemu = %r)" % args.qemu_exec)
sys.exit(1)
commit dd9b5bd4830540dbe51fdc7f79e852225356cfb2
Author: Uri Lublin <uril at redhat.com>
Date: Wed Jan 1 15:05:29 2020 +0200
migrate.py: print qemu command line
Signed-off-by: Uri Lublin <uril at redhat.com>
diff --git a/tests/migrate.py b/tests/migrate.py
index c24cd8ec..0505ee2b 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -99,6 +99,10 @@ def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, w
args += ["-m", "512", "-enable-kvm", "-drive",
"file=%s,index=0,media=disk,cache=unsafe" % image, "-snapshot"]
+ # print qemu command line for the first run
+ if not incoming_port:
+ print('qemu command line: %s' % ' '.join(args))
+
proc = Popen(args, executable=qemu_exec, stdin=PIPE, stdout=PIPE)
while not os.path.exists(qmp_filename):
time.sleep(0.1)
commit 5d82ed42d0b9e64f3a740f6462f861ee7db12d91
Author: Uri Lublin <uril at redhat.com>
Date: Wed Jan 1 15:03:21 2020 +0200
migrate.py: enable kvm
I LOVE KVM
(or Make the guest run faster)
Signed-off-by: Uri Lublin <uril at redhat.com>
diff --git a/tests/migrate.py b/tests/migrate.py
index 36a2db89..c24cd8ec 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -96,8 +96,9 @@ def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, w
"-spice", "disable-ticketing,port=%s" % spice_port]
+ incoming_args + extra_args)
if os.path.exists(image):
- args += ["-m", "512", "-drive",
+ args += ["-m", "512", "-enable-kvm", "-drive",
"file=%s,index=0,media=disk,cache=unsafe" % image, "-snapshot"]
+
proc = Popen(args, executable=qemu_exec, stdin=PIPE, stdout=PIPE)
while not os.path.exists(qmp_filename):
time.sleep(0.1)
commit 77ae94a214731a39132744aa7ff6fce69e2a1fd2
Author: Uri Lublin <uril at redhat.com>
Date: Thu Feb 20 16:54:14 2020 +0200
migrate.py: python3: when there is no output do not print the heading
Also don't try to decode a possibly None value.
Signed-off-by: Uri Lublin <uril at redhat.com>
diff --git a/tests/migrate.py b/tests/migrate.py
index 8ecb59fd..36a2db89 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -216,9 +216,13 @@ class Migrator(object):
dead.wait()
new_spice_port = dead.spice_port
new_qmp_filename = dead.qmp_filename
- self.log.write("# STDOUT dead %s\n" % dead.pid)
- outstr = dead.stdout.read().decode(encoding='utf-8', errors='ignore')
- self.log.write(outstr)
+
+ outstr = dead.stdout.read()
+ if outstr:
+ outstr = outstr.decode(encoding='utf-8', errors='ignore')
+ self.log.write("# STDOUT dead %s\n" % dead.pid)
+ self.log.write(outstr)
+
del dead
self.active = self.target
self.target = start_qemu(spice_port=new_spice_port,
commit 7318565eccb8e722e2c6248619ee35a07c26628e
Author: Uri Lublin <uril at redhat.com>
Date: Wed Jan 1 11:51:23 2020 +0200
migrate.py: python3: raw_input and more
There is no raw_input() in python3 -- define it as input()
Use decode() when writing subprocess output to the log, to make
sure the argument for write is a string (in python3
stdout.read() returns bytes).
There is no has_key in python3 -- use "in" instead
Signed-off-by: Uri Lublin <uril at redhat.com>
diff --git a/tests/migrate.py b/tests/migrate.py
index aa20c565..8ecb59fd 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -47,6 +47,10 @@ import datetime
import atexit
import argparse
+# python3 does not have raw_input
+if sys.version_info[0] == 3:
+ raw_input = input
+
def get_args():
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--qmp1', dest='qmp1', default='/tmp/migrate_test.1.qmp')
@@ -125,7 +129,7 @@ def wait_active(q, active):
# ValueError
time.sleep(0.1)
continue
- if ret and ret.has_key("return"):
+ if ret and "return" in ret.keys():
if ret["return"]["running"] == active:
break
for e in q.get_events():
@@ -213,7 +217,8 @@ class Migrator(object):
new_spice_port = dead.spice_port
new_qmp_filename = dead.qmp_filename
self.log.write("# STDOUT dead %s\n" % dead.pid)
- self.log.write(dead.stdout.read())
+ outstr = dead.stdout.read().decode(encoding='utf-8', errors='ignore')
+ self.log.write(outstr)
del dead
self.active = self.target
self.target = start_qemu(spice_port=new_spice_port,
commit d109bd35779f5139bc763961f7a788cde59122b1
Author: Uri Lublin <uril at redhat.com>
Date: Wed Jan 1 11:41:25 2020 +0200
migrate.py: python3: print
Add parenthesis to all print calls
Signed-off-by: Uri Lublin <uril at redhat.com>
diff --git a/tests/migrate.py b/tests/migrate.py
index dcf9c9bb..aa20c565 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -36,7 +36,7 @@ except:
try:
import qmp
except:
- print "can't find qmp"
+ print("can't find qmp")
raise SystemExit
import sys
from subprocess import Popen, PIPE
@@ -73,7 +73,7 @@ def get_args():
else:
args.qemu_exec = os.popen("which %s" % args.qemu).read().strip()
if not os.path.exists(args.qemu_exec):
- print "qemu not found (qemu = %r)" % args.qemu_exec
+ print("qemu not found (qemu = %r)" % args.qemu_exec)
sys.exit(1)
return args
@@ -141,7 +141,7 @@ def wait_for_event(q, event):
time.sleep(0.5)
def cleanup(migrator):
- print "doing cleanup"
+ print("doing cleanup")
migrator.close()
class Migrator(object):
@@ -173,7 +173,7 @@ class Migrator(object):
def kill_qemu(self):
for p in [self.active, self.target]:
- print "killing and waiting for qemu pid %s" % p.pid
+ print("killing and waiting for qemu pid %s" % p.pid)
p.kill()
p.wait()
@@ -190,7 +190,7 @@ class Migrator(object):
self.connected_client = start_client(client=self.client, spice_port=self.spice_ports[0])
if wait_for_user_input:
- print "waiting for Enter to start migrations"
+ print("waiting for Enter to start migrations")
raw_input()
# Tester can launch its own client or we wait start_client() to connect
@@ -221,12 +221,12 @@ class Migrator(object):
qmp_filename=new_qmp_filename,
with_agent=self.vdagent,
incoming_port=self.migration_port)
- print self.migration_count
+ print(self.migration_count)
self.migration_count += 1
def main():
args = get_args()
- print "log file %s" % args.log_filename
+ print("log file %s" % args.log_filename)
log = open(args.log_filename, "a+")
log.write("# "+str(datetime.datetime.now())+"\n")
migrator = Migrator(client=args.client, qemu_exec=args.qemu_exec,
commit 189c38f04fbb90f88d137ea062fe9b5ee287de70
Author: Uri Lublin <uril at redhat.com>
Date: Wed Jan 1 11:43:27 2020 +0200
migrate.py: remove unused variable err
Signed-off-by: Uri Lublin <uril at redhat.com>
diff --git a/tests/migrate.py b/tests/migrate.py
index 87a32eb0..dcf9c9bb 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -103,7 +103,7 @@ def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, w
try:
proc.qmp.connect()
break
- except socket.error, err:
+ except socket.error:
pass
proc.spice_port = spice_port
proc.incoming_port = incoming_port
More information about the Spice-commits
mailing list