connectauth: Drop systemd libvirtd service startup

Latest libvirt uses socket activation, so libvirtd.service in
offline state does not indicate a problem necessarily.

Also on Fedora nowadays we have a weak RPM dependency on
libvirt-daemon which we didn't in the past.

Both things combine to make this code less useful and less accurate,
so let's remove most of it.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-09-15 14:46:36 -04:00
parent 54ae6f2723
commit 83fcab0177
4 changed files with 23 additions and 71 deletions

View File

@ -159,7 +159,7 @@ class VMMDogtailApp(object):
window_name=None, xmleditor_enabled=False, keyfile=None,
break_setfacl=False, first_run=True, no_fork=True,
will_fail=False, enable_libguestfs=False,
firstrun_uri=None, fake_systemd_success=True):
firstrun_uri=None):
extra_opts = extra_opts or []
if tests.utils.TESTCONFIG.debug and no_fork:
@ -191,8 +191,6 @@ class VMMDogtailApp(object):
cmd.append("--test-options=enable-libguestfs")
if enable_libguestfs is False:
cmd.append("--test-options=disable-libguestfs")
if fake_systemd_success:
cmd.append("--test-options=fake-systemd-success")
if keyfile:
import atexit
import tempfile

View File

@ -123,11 +123,23 @@ class VMMCLI(lib.testcase.UITestCase):
self.app.root.find("test default", "table cell")
def testCLIFirstRunURIBad(self):
# Emulate first run with a URI that will succeed
# Emulate first run with a URI that will not succeed
self.app.open(use_uri=False, firstrun_uri="bad:///uri")
self.app.topwin.find("bad uri", "table cell")
self.app.click_alert_button("bad:///uri", "Close")
def testCLIFirstRunNoLibvirtd(self):
# Emulate first run with no libvirtd detected
self.app.open(use_uri=False, firstrun_uri="bad:///uri",
extra_opts=["--test-options=fake-no-libvirtd"])
errlabel = self.app.topwin.find("error-label")
lib.utils.check(
lambda: "Checking for virtualization" in errlabel.text)
lib.utils.check(
lambda: "libvirtd service does not appear" in errlabel.text)
lib.utils.check(
lambda: "detect a default hypervisor" in errlabel.text)
def testCLITraceLibvirt(self):
# Just test this for code coverage
self.app.open(keyfile="allstats.ini",

View File

@ -7,6 +7,7 @@
import collections
import os
import re
import shutil
import time
from gi.repository import GLib
@ -202,65 +203,12 @@ def connect_error(conn, errmsg, tb, warnconsole):
# App first run connection setup #
##################################
def _start_libvirtd(config):
log.debug("Trying to start libvirtd through systemd")
unitname = "libvirtd.service"
libvirtd_installed = False
libvirtd_active = False
unitpath = None
# Fetch all units from systemd
try:
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
systemd = Gio.DBusProxy.new_sync(bus, 0, None,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager", None)
units = systemd.ListUnits()
log.debug("Successfully listed units via systemd")
except Exception: # pragma: no cover
units = []
log.exception("Couldn't connect to systemd")
libvirtd_installed = os.path.exists("/var/run/libvirt")
libvirtd_active = os.path.exists("/var/run/libvirt/libvirt-sock")
# Check if libvirtd is installed and running
for unitinfo in units:
if unitinfo[0] != unitname:
continue
libvirtd_installed = True
libvirtd_active = unitinfo[3] == "active"
unitpath = unitinfo[6]
break
log.debug("libvirtd_installed=%s libvirtd_active=%s unitpath=%s",
libvirtd_installed, libvirtd_active, unitpath)
# If it's not running, try to start it
try:
if unitpath and libvirtd_installed and not libvirtd_active: # pragma: no cover
unit = Gio.DBusProxy.new_sync(
bus, 0, None,
"org.freedesktop.systemd1", unitpath,
"org.freedesktop.systemd1.Unit", None)
if config.CLITestOptions.fake_systemd_success:
unit.Start("(s)", "fail")
time.sleep(2)
libvirtd_active = True
except Exception: # pragma: no cover
log.exception("Error starting libvirtd")
return libvirtd_installed, libvirtd_active
def setup_first_uri(config, tryuri):
libvirtd_installed, libvirtd_active = _start_libvirtd(config)
if config.CLITestOptions.fake_systemd_success:
libvirtd_installed = True
libvirtd_active = True
libvirtd_installed = bool(shutil.which("libvirtd"))
if config.CLITestOptions.fake_no_libvirtd:
libvirtd_installed = False
if tryuri and libvirtd_installed and libvirtd_active:
if tryuri and libvirtd_installed:
return
# Manager fail message
@ -269,9 +217,6 @@ def setup_first_uri(config, tryuri):
msg += _("The libvirtd service does not appear to be installed. "
"Install and run the libvirtd service to manage "
"virtualization on this host.")
elif not libvirtd_active: # pragma: no cover
msg += _("libvirtd is installed but not running. Start the "
"libvirtd service to manage virtualization on this host.")
if not tryuri or "qemu" not in tryuri:
if msg:
@ -286,7 +231,4 @@ def setup_first_uri(config, tryuri):
msg += _("A virtualization connection can be manually "
"added via File->Add Connection")
if (tryuri is None or
not libvirtd_installed or
not libvirtd_active):
return msg
return msg or None

View File

@ -150,8 +150,8 @@ class CLITestOptionsClass:
* firstrun-uri: If set, use this as the initial connection URI
if we are doing firstrun testing
* fake-systemd-success: If doing firstrun testing, fake that
systemd checks for libvirtd succeeded
* fake-no-libvirtd: If doing firstrun testing, fake that
libvirtd is not installed
* fake-vnc-username: Fake VNC username auth request
* fake-console-resolution: Fake viewer console resolution response.
Spice doesn't return values here when we are just testing
@ -201,7 +201,7 @@ class CLITestOptionsClass:
self.test_vm_run_fail = _get("test-vm-run-fail")
self.spice_agent = _get("spice-agent")
self.firstrun_uri = _get_value("firstrun-uri")
self.fake_systemd_success = _get("fake-systemd-success")
self.fake_no_libvirtd = _get("fake-no-libvirtd")
self.fake_vnc_username = _get("fake-vnc-username")
self.fake_console_resolution = _get("fake-console-resolution")
self.fake_systray = _get("fake-systray")