connectauth: Drop sanity checking for libvirtd

Nowadays with libvirt split daemons, libvirtd isn't required to
be installed for a first run local connection to succeed, so we
are needlessly blocking the app from 'just working' in many cases.
Especially considering that many distros often have libvirt running
out of the box due to gnome-boxes pulling it in.

Drop the daemon checking entirely.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2023-09-12 13:18:42 -04:00
parent 17dc777481
commit 775edfd5dc
4 changed files with 14 additions and 37 deletions

View File

@ -139,15 +139,12 @@ def testCLIFirstRunURIBad(app):
app.click_alert_button("bad:///uri", "Close")
def testCLIFirstRunNoLibvirtd(app):
def testCLIFirstRunNoURI(app):
# Emulate first run with no libvirtd detected
app.open(use_uri=False, firstrun_uri="bad:///uri",
extra_opts=["--test-options=fake-no-libvirtd"])
app.open(use_uri=False, firstrun_uri="")
errlabel = 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)

View File

@ -131,14 +131,14 @@ class vmmEngine(vmmGObject):
"""
from .lib import connectauth
tryuri = vmmCreateConn.default_uri()
log.debug("Probed default URI=%s", tryuri)
detected_uri = vmmCreateConn.default_uri()
log.debug("Probed default URI=%s", detected_uri)
if self.config.CLITestOptions.firstrun_uri is not None:
tryuri = self.config.CLITestOptions.firstrun_uri or None
log.debug("Using test-options firstrun_uri=%s", tryuri)
detected_uri = self.config.CLITestOptions.firstrun_uri or None
log.debug("Using test-options firstrun_uri=%s", detected_uri)
manager = self._get_manager()
msg = connectauth.setup_first_uri(self.config, tryuri)
msg = connectauth.setup_first_uri(self.config, detected_uri)
if msg:
manager.set_startup_error(msg)
return
@ -149,7 +149,7 @@ class vmmEngine(vmmGObject):
if ConnectError:
self._handle_conn_error(c, ConnectError)
conn = vmmConnectionManager.get_instance().add_conn(tryuri)
conn = vmmConnectionManager.get_instance().add_conn(detected_uri)
conn.set_autoconnect(True)
conn.connect_once("open-completed", _open_completed)
conn.open()

View File

@ -7,7 +7,6 @@
import collections
import os
import re
import shutil
import time
from gi.repository import GLib
@ -161,7 +160,7 @@ def connect_error(conn, errmsg, tb, warnconsole):
"or install an SSH askpass package locally.")
show_errmsg = False
else:
hint += _("Verify that the 'libvirtd' daemon is running "
hint += _("Verify that an appropriate libvirt daemon is running "
"on the remote host.")
elif conn.is_xen(): # pragma: no cover
@ -176,8 +175,8 @@ def connect_error(conn, errmsg, tb, warnconsole):
"may not be able to connect to libvirt as a "
"regular user. Try running as root.")
show_errmsg = False
elif re.search(r"libvirt-sock", tb): # pragma: no cover
hint += _("Verify that the 'libvirtd' daemon is running.")
elif re.search(r"virt[a-z]*-sock", tb): # pragma: no cover
hint += _("Verify that an appropriate libvirt daemon is running.")
show_errmsg = False
msg = _("Unable to connect to libvirt %s." % conn.get_uri())
@ -203,27 +202,11 @@ def connect_error(conn, errmsg, tb, warnconsole):
# App first run connection setup #
##################################
def setup_first_uri(config, tryuri):
# Add /usr/sbin to the path in case non-root user launches virt-manager
libvirtd_installed = bool(shutil.which("libvirtd", path=os.environ['PATH'] + os.pathsep + "/usr/sbin"))
if config.CLITestOptions.fake_no_libvirtd:
libvirtd_installed = False
if tryuri and libvirtd_installed:
return
# Manager fail message
def setup_first_uri(_config, detected_uri):
msg = ""
if not libvirtd_installed: # pragma: no cover
msg += _("The libvirtd service does not appear to be installed. "
"Install and run the libvirtd service to manage "
"virtualization on this host.")
if not tryuri or "qemu" not in tryuri:
if msg:
msg += "\n\n" # pragma: no cover
if not detected_uri:
msg += _("Could not detect a default hypervisor. Make "
"sure the appropriate QEMU/KVM virtualization "
"sure the appropriate QEMU/KVM virtualization and libvirt "
"packages are installed to manage virtualization "
"on this host.")

View File

@ -168,8 +168,6 @@ class CLITestOptionsClass:
* firstrun-uri: If set, use this as the initial connection URI
if we are doing firstrun testing
* 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
@ -223,7 +221,6 @@ 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_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")