From 2d8c2e673a795406cd30144b1cab222aaa943889 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 5 May 2023 11:40:09 +0200 Subject: [PATCH] el8toel9: Warn about deprecated Xorg drivers Some Xorg drivers have been deprecated in favor of the "modesetting" driver. If Xorg is configured to use those drivers, it may not be able to work properly after the upgrade. Add a new actor to check in the journal whether such Xorg drivers are in use and in that case, also warn if there are custom Xorg config options. Known limitation: This actor checks the journal logs since the last boot, meaning that if Xorg was started manually from a console or if the system has been rebooted after a graphical Xorg session was used, the actor will not be able to detect the use of deprecated drivers. Signed-off-by: Olivier Fourdan --- .../checkxorgdeprecateddrivers/actor.py | 42 +++++++++++++++++++ .../libraries/xorgdriverlib.py | 39 +++++++++++++++++ .../tools/check_syslog_for_driver.sh | 10 +++++ .../tools/check_syslog_for_driver_config.sh | 9 ++++ 4 files changed, 100 insertions(+) create mode 100644 repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/actor.py create mode 100644 repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/libraries/xorgdriverlib.py create mode 100755 repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver.sh create mode 100755 repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver_config.sh diff --git a/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/actor.py b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/actor.py new file mode 100644 index 0000000000..e5d3db5dd7 --- /dev/null +++ b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/actor.py @@ -0,0 +1,42 @@ +from leapp import reporting +from leapp.actors import Actor +from leapp.libraries.actor.xorgdriverlib import was_xorg_driver_used, has_xorg_driver_config +from leapp.reporting import create_report, Report +from leapp.tags import ChecksPhaseTag, IPUWorkflowTag + + +class CheckXorgDeprecatedDrivers(Actor): + """ + Warn if Xorg deprecated drivers are in use. + + """ + + name = 'check_xorg_deprecated_drivers' + consumes = () + produces = (Report,) + tags = (ChecksPhaseTag, IPUWorkflowTag) + + def process(self): + for driver in [ 'RADEON', 'ATI', 'AMDGPU', 'MACH64', 'intel', 'spiceqxl', 'qxl', 'NOUVEAU', 'NV', 'VESA' ]: + if was_xorg_driver_used(driver): + report_summary = ('Leapp has detected that the deprecated Xorg driver {} is used.' + '\n\n' + 'Please uninstall the Xorg driver before upgrading to make sure you have a ' + 'graphical session after upgrading.') + create_report([ + reporting.Title('Deprecated Xorg driver detected'), + reporting.Summary(report_summary.format(driver)), + reporting.Severity(reporting.Severity.MEDIUM), + reporting.Groups([reporting.Groups.DRIVERS]), + ]) + + if has_xorg_driver_config(driver): + report_summary = ('Leapp has detected a custom configuration for the deprecated Xorg driver {}.' + '\n\n' + 'Driver specific options will be ignored and have no effect without the driver.') + create_report([ + reporting.Title('Deprecated Xorg driver detected'), + reporting.Summary(report_summary.format(driver)), + reporting.Severity(reporting.Severity.MEDIUM), + reporting.Groups([reporting.Groups.DRIVERS]), + ]) diff --git a/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/libraries/xorgdriverlib.py b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/libraries/xorgdriverlib.py new file mode 100644 index 0000000000..399282aa38 --- /dev/null +++ b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/libraries/xorgdriverlib.py @@ -0,0 +1,39 @@ +# +# Helper functions +# + +from leapp.libraries.stdlib import api, CalledProcessError, run + +def was_xorg_driver_used(_driver=""): + """ + Determines whether a given Xorg driver has been used in the path month, + by checking the journalctl. + + :param _driver: name of the driver to check + :return: True if the driver usage has been found. + :rtype: bool + """ + try: + run(['check_syslog_for_driver.sh', _driver]) + except CalledProcessError: + api.current_logger().debug('Nothing about Xorg driver {} was found in journal.'.format(_driver)) + return False + api.current_logger().debug('Found logs from driver {} in journal.'.format(_driver)) + return True + +def has_xorg_driver_config(_driver=""): + """ + Determines whether custom options for the the given Xorg driver has been + used in the path month, by checking the journalctl. + + :param _driver: name of the driver to check + :return: True if custom options for the driver were found. + :rtype: bool + """ + try: + run(['check_syslog_for_driver_config.sh', _driver]) + except CalledProcessError: + api.current_logger().debug('No custom options for Xorg driver {} were found in journal.'.format(_driver)) + return False + api.current_logger().debug('Custom options for driver {} found in journal.'.format(_driver)) + return True diff --git a/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver.sh b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver.sh new file mode 100755 index 0000000000..a030f1333b --- /dev/null +++ b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo Usage: $0 DRIVER + exit -1 +fi + +/usr/bin/journalctl /usr/libexec/Xorg -b 0 | \ + /usr/bin/grep "DPI set to" | \ + /usr/bin/grep -q -F $1 diff --git a/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver_config.sh b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver_config.sh new file mode 100755 index 0000000000..bc60a44f5e --- /dev/null +++ b/repos/system_upgrade/el8toel9/actors/checkxorgdeprecateddrivers/tools/check_syslog_for_driver_config.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo Usage: $0 DRIVER + exit -1 +fi + +/usr/bin/journalctl /usr/libexec/Xorg -b 0 | \ + /usr/bin/grep -q -F "(**) $1"