File 049-virt-install-detect-wayland-in-order-to-start-virt-viewer.patch of Package virt-manager

Subject: virt-install: detect wayland in order to start virt-viewer
From: Pavel Hrdina phrdina@redhat.com Mon Mar 24 12:11:23 2025 +0100
Date: Mon Mar 24 15:32:28 2025 +0100:
Git: 4f9618289f279f86994a5d2f1aada8a6524f5a6f

When running virt-install using waypipe the DISPLAY variable is not
defined and virt-install will complain that it cannot start virt-viewer.

Check for WAYLAND_DISPLAY as well, DISPLAY is defined only when xwayland
is used. In case of waypipe it configures only WAYLAND_DISPLAY.

Move the check before we check for virt-viewer as without display there
is no point to check if virt-viewer is installed or not.

Fixes: https://github.com/virt-manager/virt-manager/issues/884
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1999,18 +1999,20 @@ def _determine_default_autoconsole_type(
         log.debug("No viewer to launch for graphics type '%s'", gtype)
         return None
 
+    if (
+        not os.environ.get("DISPLAY", "")
+        and not os.environ.get("DISPLAY_WAYLAND")
+        and not xmlutil.in_testsuite()
+    ):  # pragma: no cover
+        log.warning(_("No display detected. Not running virt-viewer."))
+        return None
+
     if not HAS_VIRTVIEWER and not xmlutil.in_testsuite():  # pragma: no cover
         log.warning(_("Unable to connect to graphical console: "
                        "virt-viewer not installed. Please install "
                        "the 'virt-viewer' package."))
         return None
 
-    if (not os.environ.get("DISPLAY", "") and
-        not xmlutil.in_testsuite()):  # pragma: no cover
-        log.warning(_("Graphics requested but DISPLAY is not set. "
-                       "Not running virt-viewer."))
-        return None
-
     return "graphical"
 
 
openSUSE Build Service is sponsored by