Hi Victor,
On 10/7/19 3:19 PM, Victor Toso wrote:
From: Victor Toso <me@xxxxxxxxxxxxxx>
This is used in the migrate message and being able to tweak it allows
clients from different machines to test this local migration test.
Example of usage:
./migrate.py --hostname 192.168.122.1 --wait-user-connect
In a VM with access to 192.168.122.1:
remote-viewer spice://192.168.122.1:5911
Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
tests/migrate.py | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/tests/migrate.py b/tests/migrate.py
index 742c9fab..2f8b3fbb 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -20,7 +20,7 @@ Will leave a log file, migrate_test.log, in current directory.
# and repeat:
# active wait until it's active
# active client_migrate_info
-# active migrate tcp:localhost:9000
+# active migrate tcp:$hostname:9000
I think the migrate command itself can keep the "localhost"
(Not too important, but shows that the migration itself is on a single
host.)
See also below for the same
# _wait for event of quit
# active stop, active<->passive
#
@@ -57,6 +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("--hostname", dest='hostname', default='localhost',
+ help="Set hostname used in migration message (default: localhost")
This is to be used together with --wait-user-connect, right ?
Consider adding a check for it (can be a separate patch).
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,
@@ -115,10 +117,10 @@ def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, w
proc.incoming_port = incoming_port
return proc
-def start_client(client, spice_port):
- client_cmd = "spicy --uri spice://localhost:%s" % (spice_port)
+def start_client(client, hostname, spice_port):
+ client_cmd = "spicy --uri spice://%s:%s" % (hostname, spice_port)
if client == "remote-viewer":
- client_cmd = "remote-viewer spice://localhost:%s" % (spice_port)
+ client_cmd = "remote-viewer spice://%s:%s" % (hostname, spice_port)
If the script starts it, then both server and client are on the same
(localhost) machine.
return Popen(client_cmd.split(), executable=client)
@@ -151,7 +153,7 @@ class Migrator(object):
migration_count = 0
def __init__(self, log, client, qemu_exec, image, monitor_files,
- spice_ports, migration_port, vdagent):
+ spice_ports, migration_port, vdagent, hostname):
self.client = client if client != "none" else None
self.log = log
self.qemu_exec = qemu_exec
@@ -160,6 +162,7 @@ class Migrator(object):
self.monitor_files = monitor_files
self.spice_ports = spice_ports
self.vdagent = vdagent
+ self.hostname = hostname
self.active = start_qemu(qemu_exec=qemu_exec, image=image, spice_port=spice_ports[0],
qmp_filename=monitor_files[0], with_agent=self.vdagent)
@@ -189,7 +192,9 @@ class Migrator(object):
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])
+ self.connected_client = start_client(client = self.client,
+ hostname = self.hostname,
+ spice_port = self.spice_ports[0])
if wait_for_user_input:
print "waiting for Enter to start migrations"
@@ -201,11 +206,11 @@ class Migrator(object):
self.active.qmp.cmd('client_migrate_info', {
'protocol' : 'spice',
- 'hostname' : 'localhost',
+ 'hostname' : self.hostname,
I think this is the important code.
'port' : self.target.spice_port
})
self.active.qmp.cmd('migrate', {
- 'uri': 'tcp:localhost:%s' % self.migration_port
+ 'uri': 'tcp:%s:%s' % (self.hostname, self.migration_port)
Here, it can be left 'localhost'
Uri.
})
wait_active(self.active.qmp, False)
wait_active(self.target.qmp, True)
@@ -239,7 +244,7 @@ def main():
migrator = Migrator(client=args.client, qemu_exec=args.qemu_exec,
image=args.image, log=log, monitor_files=[args.qmp1, args.qmp2],
migration_port=args.migrate_port, spice_ports=[args.spice_port1,
- args.spice_port2], vdagent=args.vdagent)
+ args.spice_port2], vdagent=args.vdagent, hostname=args.hostname)
atexit.register(cleanup, migrator)
counter = 0
while args.counter == 0 or counter < args.counter:
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel