[Spice-commits] 3 commits - tests/migrate.py

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 4 11:32:40 UTC 2019


 tests/migrate.py |   44 +++++++++++++++++++++++++++++++-------------
 1 file changed, 31 insertions(+), 13 deletions(-)

New commits:
commit e86d4e3e48307ef5ebfb4b2973032af3d88e54c4
Author: Victor Toso <me at victortoso.com>
Date:   Tue Oct 1 15:57:03 2019 +0200

    tests: migrate: fix migration with --vdagent option
    
    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>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/tests/migrate.py b/tests/migrate.py
index 88e17691..87a32eb0 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)
@@ -151,13 +158,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
 
@@ -213,6 +219,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
commit 6777ec31f121f5c5745e3ac160eed62badef612d
Author: Victor Toso <me at victortoso.com>
Date:   Tue Oct 1 14:43:52 2019 +0200

    tests: migrate: wait user launch client option
    
    Useful to test different clients running different tools (gdb,
    valgrind).
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>

diff --git a/tests/migrate.py b/tests/migrate.py
index 5ed9eba4..88e17691 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -63,6 +63,8 @@ def get_args():
                         help="Append options for agent's virtserialport")
     parser.add_argument('--wait-user-input', dest="wait_user_input", action='store_true', default=False,
                         help="Wait user's input to start migration test")
+    parser.add_argument('--wait-user-connect', dest="wait_user_connect", action='store_true', default=False,
+                        help="Wait spice client to connect to move to next step of migration (default False)")
     parser.add_argument('--count', dest='counter', type=int, default=100,
                         help="Number of migrations to run (set 0 for infinite)")
     args = parser.parse_args(sys.argv[1:])
@@ -174,25 +176,28 @@ class Migrator(object):
             if os.path.exists(x):
                 os.unlink(x)
 
-    def iterate(self, wait_for_user_input=False):
+    def iterate(self, wait_for_user_input=False, wait_user_connect=False):
         wait_active(self.active.qmp, True)
         wait_active(self.target.qmp, False)
         if not self.connected_client:
             if self.client:
                 self.connected_client = start_client(client=self.client, spice_port=self.spice_ports[0])
-                wait_for_event(self.active.qmp, 'SPICE_INITIALIZED')
 
             if wait_for_user_input:
                 print "waiting for Enter to start migrations"
                 raw_input()
 
+        # Tester can launch its own client or we wait start_client() to connect
+        if wait_user_connect:
+            wait_for_event(self.active.qmp, 'SPICE_INITIALIZED')
+
         self.active.qmp.cmd('client_migrate_info', {'protocol':'spice',
             'hostname':'localhost', 'port':self.target.spice_port})
         self.active.qmp.cmd('migrate', {'uri': 'tcp:localhost:%s' % self.migration_port})
         wait_active(self.active.qmp, False)
         wait_active(self.target.qmp, True)
 
-        if self.connected_client:
+        if self.connected_client or wait_user_connect:
             wait_for_event(self.target.qmp, 'SPICE_CONNECTED')
 
         dead = self.active
@@ -224,7 +229,7 @@ def main():
     atexit.register(cleanup, migrator)
     counter = 0
     while args.counter == 0 or counter < args.counter:
-        migrator.iterate(args.wait_user_input)
+        migrator.iterate(args.wait_user_input, args.wait_user_connect)
         counter += 1
 
 if __name__ == '__main__':
commit 878d3bd1ab830114790401c31e9016f347288b0c
Author: Victor Toso <me at victortoso.com>
Date:   Mon Sep 30 10:35:42 2019 +0200

    tests: migrate: default to not launch client
    
    This supports doing migration without any client to be connected.
    If tester wants client, it needs to pass an option to --client.
    
    Change of default still is to keep the test as simple as possible
    when no arguments are given.
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/tests/migrate.py b/tests/migrate.py
index b11befdd..5ed9eba4 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -57,7 +57,8 @@ def get_args():
     parser.add_argument('--qemu', dest='qemu', default='../../qemu/x86_64-softmmu/qemu-system-x86_64')
     parser.add_argument('--log_filename', dest='log_filename', default='migrate.log')
     parser.add_argument('--image', dest='image', default='')
-    parser.add_argument('--client', dest='client', default='spicy', choices=['spicy', 'remote-viewer'])
+    parser.add_argument('--client', dest='client', default='none', choices=['spicy', 'remote-viewer', 'none'],
+                        help="Automatically lunch one of supported clients or none (default)")
     parser.add_argument('--vdagent', dest="vdagent", action='store_true', default=False,
                         help="Append options for agent's virtserialport")
     parser.add_argument('--wait-user-input', dest="wait_user_input", action='store_true', default=False,
@@ -140,7 +141,7 @@ class Migrator(object):
 
     def __init__(self, log, client, qemu_exec, image, monitor_files,
                  spice_ports, migration_port, vdagent):
-        self.client = client
+        self.client = client if client != "none" else None
         self.log = log
         self.qemu_exec = qemu_exec
         self.image = image
@@ -177,8 +178,10 @@ class Migrator(object):
         wait_active(self.active.qmp, True)
         wait_active(self.target.qmp, False)
         if not self.connected_client:
-            self.connected_client = start_client(client=self.client, spice_port=self.spice_ports[0])
-            wait_for_event(self.active.qmp, 'SPICE_INITIALIZED')
+            if self.client:
+                self.connected_client = start_client(client=self.client, spice_port=self.spice_ports[0])
+                wait_for_event(self.active.qmp, 'SPICE_INITIALIZED')
+
             if wait_for_user_input:
                 print "waiting for Enter to start migrations"
                 raw_input()
@@ -188,7 +191,10 @@ class Migrator(object):
         self.active.qmp.cmd('migrate', {'uri': 'tcp:localhost:%s' % self.migration_port})
         wait_active(self.active.qmp, False)
         wait_active(self.target.qmp, True)
-        wait_for_event(self.target.qmp, 'SPICE_CONNECTED')
+
+        if self.connected_client:
+            wait_for_event(self.target.qmp, 'SPICE_CONNECTED')
+
         dead = self.active
         dead.qmp.cmd("quit")
         dead.qmp.close()


More information about the Spice-commits mailing list