Skip to content

Commit

Permalink
Merge pull request #2248 from Yingshun/fix_conn_socket
Browse files Browse the repository at this point in the history
utils_conn: update to start socket before libvirtd started
  • Loading branch information
dzhengfy authored Sep 19, 2019
2 parents 0da6737 + 8870930 commit 6ea65e9
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions virttest/utils_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from virttest import propcan, remote, utils_libvirtd
from virttest import data_dir
from virttest import utils_package
from virttest import libvirt_version
from virttest.compat_52lts import results_stderr_52lts


Expand Down Expand Up @@ -728,7 +729,12 @@ def conn_recover(self):
server_user, server_pwd,
r"[\#\$]\s*$")
libvirtd_service = utils_libvirtd.Libvirtd(session=session)
libvirtd_service.restart()
if libvirt_version.version_compare(5, 6, 0, session):
libvirtd_service.stop()
session.cmd("systemctl stop libvirtd-tcp.socket")
libvirtd_service.start()
else:
libvirtd_service.restart()
except (remote.LoginError, aexpect.ShellError) as detail:
raise ConnServerRestartError(detail)

Expand Down Expand Up @@ -793,7 +799,14 @@ def conn_setup(self):
remote_runner = remote.RemoteRunner(session=session)
remote_runner.run('iptables -F', ignore_status=True)
libvirtd_service = utils_libvirtd.Libvirtd(session=session)
libvirtd_service.restart()
# From libvirt 5.6, libvirtd is using systemd socket activation
# by default
if libvirt_version.version_compare(5, 6, 0, session):
libvirtd_service.stop()
session.cmd("systemctl restart libvirtd-tcp.socket")
libvirtd_service.start()
else:
libvirtd_service.restart()
except (remote.LoginError, aexpect.ShellError) as detail:
raise ConnServerRestartError(detail)

Expand Down Expand Up @@ -1003,7 +1016,12 @@ def conn_recover(self):
server_user, server_pwd,
r"[\#\$]\s*$")
libvirtd_service = utils_libvirtd.Libvirtd(session=session)
libvirtd_service.restart()
if libvirt_version.version_compare(5, 6, 0, session):
libvirtd_service.stop()
session.cmd("systemctl stop libvirtd-tls.socket")
libvirtd_service.start()
else:
libvirtd_service.restart()
except (remote.LoginError, aexpect.ShellError) as detail:
raise ConnServerRestartError(detail)
logging.debug("TLS connection recover successfully.")
Expand Down Expand Up @@ -1262,7 +1280,14 @@ def server_setup(self, on_local=False):
if restart_libvirtd == "yes":
if on_local:
libvirtd_service = utils_libvirtd.Libvirtd()
libvirtd_service.restart()
# From libvirt 5.6, libvirtd is using systemd socket activation
# by default
if libvirt_version.version_compare(5, 6, 0):
libvirtd_service.stop()
process.run("systemctl restart libvirtd-tls.socket")
libvirtd_service.start()
else:
libvirtd_service.restart()
else:
try:
session = remote.wait_for_login('ssh', server_ip, '22',
Expand All @@ -1271,7 +1296,12 @@ def server_setup(self, on_local=False):
remote_runner = remote.RemoteRunner(session=session)
remote_runner.run('iptables -F', ignore_status=True)
libvirtd_service = utils_libvirtd.Libvirtd(session=session)
libvirtd_service.restart()
if libvirt_version.version_compare(5, 6, 0, session):
libvirtd_service.stop()
session.cmd("systemctl restart libvirtd-tls.socket")
libvirtd_service.start()
else:
libvirtd_service.restart()
except (remote.LoginError, aexpect.ShellError) as detail:
raise ConnServerRestartError(detail)

Expand Down

0 comments on commit 6ea65e9

Please sign in to comment.