Skip to content

Commit

Permalink
Adding libvirt remote connection verification
Browse files Browse the repository at this point in the history
Depending on the remote libvirt configuration, setting a password-less
login between the hosts isn't enough to ensure a password-less API
connection to the remote libvirt service.

This patch adds a virsh verification to ensure that this password-less
connection can be estabished before moving further with the live
migration process. If the verification fails, a proper error message
is given to warn the user about the need of making a manual configuration
in the libvirt service of the remote host.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
  • Loading branch information
danielhb authored and alinefm committed Oct 14, 2016
1 parent f42d8b5 commit f4bbf64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"KCHVM0087E": _("console parameter is only supported for s390x/s390 architecture."),
"KCHVM0088E": _("invalid console type, supported types are sclp/virtio."),
"KCHVM0089E": _("Unable to setup password-less login at remote host %(host)s using user %(user)s: remote directory %(sshdir)s does not exist."),
"KCHVM0090E": _("Unable to create a password-less libvirt connection to the remote libvirt daemon at host %(host)s with the user %(user)s. Please verify the remote server libvirt configuration. More information: http://libvirt.org/auth.html ."),

"KCHVMHDEV0001E": _("VM %(vmid)s does not contain directly assigned host device %(dev_name)s."),
"KCHVMHDEV0002E": _("The host device %(dev_name)s is not allowed to directly assign to VM."),
Expand Down
18 changes: 18 additions & 0 deletions model/vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import platform
import pwd
import random
import signal
import socket
import subprocess
import string
Expand Down Expand Up @@ -1840,6 +1841,22 @@ def append_id_rsa_to_remote_authorized_keys(ssh_client, id_rsa_data):
if ssh_client:
ssh_client.close()

def _check_remote_libvirt_conn(self, remote_host,
user='root', transport='ssh'):

dest_uri = 'qemu+%s://%s@%s/system' % (transport, user, remote_host)
cmd = ['virsh', '-c', dest_uri, 'list']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
shell=True, preexec_fn=os.setsid)
timeout = 0
while proc.poll() is None:
time.sleep(1)
timeout += 1
if timeout == 5:
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
raise OperationFailed("KCHVM0090E",
{'host': remote_host, 'user': user})

def _get_remote_libvirt_conn(self, remote_host,
user='root', transport='ssh'):
dest_uri = 'qemu+%s://%s@%s/system' % (transport, user, remote_host)
Expand All @@ -1853,6 +1870,7 @@ def migration_pre_check(self, remote_host, user, password):
user,
password
)
self._check_remote_libvirt_conn(remote_host, user)
self._check_if_migrating_same_arch_hypervisor(remote_host, user)

if platform.machine() in ['ppc64', 'ppc64le']:
Expand Down

0 comments on commit f4bbf64

Please sign in to comment.