[Spice-devel] [spice v1 4/8] tests: migrate: cosmetic changes on start_qemu()

Victor Toso victortoso at redhat.com
Mon Oct 7 12:19:31 UTC 2019


From: Victor Toso <me at victortoso.com>

This function can be tweak quite a bit due all possibilities around
QEMU configuration. This patch removes incoming_args and extra_args
and move their values to the right place in the function.

I'm also applying a more extensive coding style for parameters, so
when we need to do changes it should happen with fewer lines.

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 tests/migrate.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/tests/migrate.py b/tests/migrate.py
index 375e59a0..3ae9e053 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -78,23 +78,29 @@ def get_args():
     return args
 
 def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, with_agent=False):
-    incoming_args = []
+    args = [
+        qemu_exec,
+        "-qmp", "unix:%s,server,nowait" % qmp_filename,
+        "-spice", "disable-ticketing,port=%s" % spice_port
+    ]
     if incoming_port:
-        incoming_args = ("-incoming tcp::%s" % incoming_port).split()
+        args += ("-incoming tcp::%s" % incoming_port).split()
 
-    extra_args = []
     if with_agent:
-        extra_args = ['-device', 'virtio-serial',
-                      '-chardev', 'spicevmc,name=vdagent,id=vdagent',
-                      '-device', 'virtserialport,chardev=vdagent,name=com.redhat.spice.0']
+        args += [
+            '-device', 'virtio-serial',
+            '-chardev', 'spicevmc,name=vdagent,id=vdagent',
+            '-device', 'virtserialport,chardev=vdagent,name=com.redhat.spice.0'
+        ]
 
-    args = ([qemu_exec, "-qmp", "unix:%s,server,nowait" % qmp_filename,
-        "-spice", "disable-ticketing,port=%s" % spice_port]
-        + incoming_args + extra_args)
     if os.path.exists(image):
-        args += ["-m", "512", "-drive",
-                 "file=%s,index=0,media=disk,cache=unsafe" % image, "-snapshot"]
+        args += [
+            "-m", "512",
+            "-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)
     proc.qmp_filename = qmp_filename
-- 
2.21.0



More information about the Spice-devel mailing list