[v1,4/8] tests: migrate: cosmetic changes on start_qemu()

Submitted by Victor Toso on Oct. 7, 2019, 12:19 p.m.

Details

Message ID 20191007121935.22567-4-victortoso@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Oct. 7, 2019, 12:19 p.m.
From: Victor Toso <me@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@redhat.com>
---
 tests/migrate.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

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