[Spice-devel] [spice/tests/migrate v1 4/4] tests: migrate: fix migration with --vdagent option

Victor Toso victortoso at redhat.com
Thu Oct 3 10:14:23 UTC 2019


From: Victor Toso <me at victortoso.com>

Before this patch, running the test with --vdagent option would error
in the second migration attempt with:

 | qemu-system-x86_64: Unknown savevm section or instance
 | '0000:00:04.0/virtio-console' 0. Make sure that your current VM setup
 | matches your saved VM setup, including any hotplugged devices

The reason is that target host created for migration was lacking the
configuration for vdagent that is present in the first source/target
migration VMs.

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

diff --git a/tests/migrate.py b/tests/migrate.py
index 9afeb59c..5f0f13a2 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -77,10 +77,17 @@ def get_args():
         sys.exit(1)
     return args
 
-def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, extra_args=[]):
+def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, with_agent=False):
     incoming_args = []
     if incoming_port:
         incoming_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 = ([qemu_exec, "-qmp", "unix:%s,server,nowait" % qmp_filename,
         "-spice", "disable-ticketing,port=%s" % spice_port]
         + incoming_args + extra_args)
@@ -147,13 +154,12 @@ class Migrator(object):
         self.monitor_files = monitor_files
         self.spice_ports = spice_ports
         self.vdagent = vdagent
-        extra_args = []
-        if self.vdagent:
-            extra_args = ['-device', 'virtio-serial', '-chardev', 'spicevmc,name=vdagent,id=vdagent', '-device', 'virtserialport,chardev=vdagent,name=com.redhat.spice.0']
+
         self.active = start_qemu(qemu_exec=qemu_exec, image=image, spice_port=spice_ports[0],
-                                 qmp_filename=monitor_files[0], extra_args=extra_args)
+                                 qmp_filename=monitor_files[0], with_agent=self.vdagent)
         self.target = start_qemu(qemu_exec=qemu_exec, image=image, spice_port=spice_ports[1],
-                                 qmp_filename=monitor_files[1], incoming_port=migration_port)
+                                 qmp_filename=monitor_files[1], with_agent=self.vdagent,
+                                 incoming_port=migration_port)
         self.remove_monitor_files()
         self.connected_client = None
 
@@ -209,6 +215,7 @@ class Migrator(object):
         self.target = start_qemu(spice_port=new_spice_port,
                             qemu_exec=self.qemu_exec, image=self.image,
                             qmp_filename=new_qmp_filename,
+                            with_agent=self.vdagent,
                             incoming_port=self.migration_port)
         print self.migration_count
         self.migration_count += 1
-- 
2.21.0



More information about the Spice-devel mailing list