support for remote migration
Quoted 4 lines · ----- "yogi
Hello everyone,
I like to submit patch to add support for "remote migration" in kvm-autotest.
Sounds like a good idea.
Also, the patch isn't too big, which I personally appreciate very much (makes it easier to read).
Quoted 35 lines
To use this patch the following four parameters should be added to the
existing migration testremote = dst
hostip = <localhost ip or name>
remoteip = <remote host ip or name>
remuser = root
rempassword = <password>the field remote=dst indicates the VM "dst" should be created on remote
machine.
For example:
- migrate: install setup
type = migration
vms += " dst"
migration_test_command= help
kill_vm_on_error= yes
remote = dst
hostip = 192.168.1.2
remoteip = 192.168.1.3
remuser = root
rempassword = 123456
variants:Three files r being modified in this patch
kvm_utils.py,kvm_tests.pyandkvm_vm.py.kvm_utils.py- if the ssh-keys have been exchanged between the test machines,then remote login fails with message "Got unexpected login prompt", to prevent this, have made it return a session rather then None
kvm_tests.py- the host address used in migration is made dynamic
Quoted 9 lines
kvm_vm.py- have replaced unix sockets with tcp sockets for
monitor,
in both remote and local VM. Added two newvariables(remote,ssh_port)to
class VM,remote set to True if the VM is on a remote machine,ssh_port
contains the redirection port, funtionget_address()returns the ip of
the host whr the VM is(local or remote).
I've only looked at the code briefly, and it looks very good overall, but I have a few comments/questions:
Regarding remote_login:
- Why should remote_login return a session when it gets an unexpected login prompt? If you get a login prompt doesn't that mean something went wrong? The username is always provided in the ssh command line, so we shouldn't expect to receive a login prompt -- or am I missing something? I am pretty confident this is true in the general case, but maybe it's different when ssh keys have been exchanged between the hosts.
- I think it makes little sense to return a session object when you see a login prompt because that session will be useless. You can't send any commands to it because you don't have a shell prompt yet. Any command you send will be interpreted as a username, and will most likely be the wrong username.
- When a guest is in the process of booting and we try to log into it, remote_login sometimes fails because it gets an unexpected login prompt. This is good, as far as I understand, because it means the guest isn't ready yet (still booting). The next time remote_login attempts to log in, it usually succeeds. If we consider an unexpected login prompt OK, we pass login attempts that actually should have failed (and the resulting sessions will be useless anyway).
Other things:
- If I understand correctly, remote migration will only work if the remote qemu binary path is exactly the same as the local one. Maybe we should receive a qemu path parameter that will allow for some flexibility.
- In VM.make_qemu_command(), in the code that handles redirections, you add 'self.ssh_port = host_port'. I don't think this is correct because there can be multiple redirections, unrelated to SSH, so you certainly shouldn't assume that the only redirection is an SSH one. When you want the host port redirected to the guest's SSH port, you should use self.get_port(int(self.params.get("ssh_port"))). This will also work if for some reason 'ssh_port' changes while the guest is alive.
- It seems that the purpose of 'remote = dst' is to indicate to 'dst' that it should be started as a remote VM. The preferred way to do this is to pass something like 'remote_dst = yes' and then in VM.create() you can test for params.get("remote") == "yes". See "Addressing objects" in the wiki (http://www.linux-kvm.org/page/KVM-Autotest/Parameters#Addressing_objects_.28VMs.2C_images.2C_NICs_etc.29).
In general, any parameter you want to pass to a specific VM, you pass using <param>_<vmname> = <value>, e.g. 'mem_dst = 128', and then in VM.create() the parameter is accessible without the VM name extension (e.g. self.params.get("mem") will equal "128").
Thanks,
Michael
Hello everyone,
I like to resubmit patch to add support for "remote migration" in kvm-autotest, based on Michael Goldish's suggestions.
To use this patch the following seven parameters should be added to the existing migration test
remote_dst = yes
hostip = <localhost ip or name>
remoteip = <remote host ip or name> remuser = root
rempassword = <password>
qemu_path_dst = <qemu binary path on remote host> image_dir_dst = <images dir on remote host>
For example:
- migrate: install setup
type = migration
vms += " dst"
migration_test_command = help kill_vm_on_error = yes
hostip = 192.168.1.2
remoteip = 192.168.1.3
remuser = root
rempassword = 123456
remote_dst = yes
qemu_path_dst = /tmp/kvm_autotest_root/qemu image_dir_dst = /tmp/kvm_autotest_root/images
variants:
The parameter "remote_dst = yes", indicates that the VM "dst" should be started on the remote host.If the parameter qemu_path_dst and image_dir_dst, it is assumed tht the qemu binary images path is same on both local and remote host.
Quoted 8 lines
Regarding
remote_login:- Why should
remote_loginreturn a session when it gets an unexpected login prompt? If you get a login prompt doesn't that mean something went wrong? The username is always provided in the ssh command line, so we shouldn't expect to receive a login prompt -- or am I missing something? I am pretty confident this is true in the general case, but maybe it's different when ssh keys have been exchanged between the hosts.- I think it makes little sense to return a session object when you see a login prompt because that session will be useless. You can't send any commands to it because you don't have a shell prompt yet. Any command you send will be interpreted as a username, and will most likely be the wrong username.
- When a guest is in the process of booting and we try to log into it,
remote_loginsometimes fails because it gets an unexpected login prompt. This is good, as far as I understand, because it means the guest isn't ready yet (still booting). The next timeremote_loginattempts to log in, it usually succeeds. If we consider an unexpected login prompt OK, we pass login attempts that actually should have failed (and the resulting sessions will be useless anyway).
I have removed this from the current patch, so now the remote_login function is unchanged.I will recheck my machine configuration and submit it as new patch if necessary. I had exchanged ssh keys between the hosts(both local and remote hosts), but the login sessions seem to terminates with "Got unexpected login prompt".
Quoted 3 lines
Other things:
- If I understand correctly, remote migration will only work if the remote qemu binary path is exactly the same as the local one. Maybe we should receive a qemu path parameter that will allow for some flexibility.
update the patch with this option by providing 2 new parameters qemu_path_dst and image_dir_dst
Quoted 1 line
- In
VM.make_qemu_command(), in the code that handles redirections, you add 'self.ssh_port =host_port'. I don't think this is correct because there can be multiple redirections, unrelated to SSH, so you certainly shouldn't assume that the only redirection is an SSH one. When you want the host port redirected to the guest's SSH port, you should use self.get_port(int(self.params.get("ssh_port"))). This will also work if for some reason 'ssh_port' changes while the guest is alive.
yes,should not have done that. So also removed it from this patch
Quoted 2 lines
- It seems that the purpose of 'remote = dst' is to indicate to 'dst' that it should be started as a remote VM. The preferred way to do this is to pass something like '
remote_dst= yes' and then inVM.create()you can test forparams.get("remote")== "yes". See "Addressing objects" in the wiki (http://www.linux-kvm.org/page/KVM-Autotest/Parameters#Addressing_objects_.28VMs.2C_images.2C_NICs_etc.29).
In general, any parameter you want to pass to a specific VM, you pass using <param>_<vmname> = <value>, e.g. 'mem_dst= 128', and then inVM.create()the parameter is accessible without the VM name extension (e.g.self.params.get("mem")will equal "128").
updated the patch with the above suggestion
Thank you,for your suggestion Michael, they were very helpful(srry i took so long to reply,was traveling,so was not able to reply and resubmit the patch).
Thx
yogi
kvm_tests.py | 2 +- kvm_vm.py | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 44 insertions(+), 12 deletions(-)
---
client/tests/kvm_runtest_2//kvm_tests.py +1 -1
@@ -81,7 +81,7 @@ def run_migration(test, params, env): session.close() # Define the migration command - cmd = "migrate -d tcp:localhost:%d" % dest_vm.migration_port + cmd = "migrate -d tcp:%s:%d" % (dest_vm.hostip,dest_vm.migration_port) kvm_log.debug("Migration command: %s" % cmd) # Migrate
client/tests/kvm_runtest_2//kvm_vm.py +43 -11
108 lines not on this page · raw message