Skip to content

Commit

Permalink
el8toel9: Warn about deprecated Xorg drivers
Browse files Browse the repository at this point in the history
Some Xorg drivers have been deprecated in favor of the "modesetting"
driver.

If Xorg is configured to use those driver, 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 <[email protected]>
  • Loading branch information
ofourdan authored and pirat89 committed Jun 19, 2023
1 parent ee99c3b commit 948c782
Show file tree
Hide file tree
Showing 10 changed files with 1,314 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
ignore_words_list: ro,fo,couldn,repositor
skip: "./repos/system_upgrade/common/actors/storagescanner/tests/files/mounts,\
./repos/system_upgrade/el7toel8/actors/networkmanagerreadconfig/tests/files/nm_cfg_file_error,\
./repos/system_upgrade/el8toel9/actors/xorgdrvfact/tests/files/journalctl-xorg-intel,\
./repos/system_upgrade/el8toel9/actors/xorgdrvfact/tests/files/journalctl-xorg-qxl,\
./repos/system_upgrade/el8toel9/actors/xorgdrvfact/tests/files/journalctl-xorg-without-qxl,\
./repos/system_upgrade/common/actors/scancpu/tests/files/lscpu_s390x,\
./etc/leapp/files/device_driver_deprecation_data.json,\
./etc/leapp/files/pes-events.json,\
Expand Down
52 changes: 52 additions & 0 deletions repos/system_upgrade/el8toel9/actors/xorgdrvcheck/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from leapp import reporting
from leapp.actors import Actor
from leapp.models import XorgDrvFacts
from leapp.reporting import create_report, Report
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag

SUMMARY_XORG_DEPRECATE_DRIVERS_FMT = (
'Leapp has detected the use of some deprecated Xorg drivers. '
'Using these drivers could lead to a broken graphical session after the upgrade. '
'Any custom configuration related to these drivers will be ignored. '
'The list of used deprecated drivers: {}')

SUMMARY_XORG_DEPRECATE_DRIVERS_HINT = (
'Please uninstall the Xorg driver and remove the corresponding driver '
'customisation entries from the X.Org configuration files and directories, '
'such as `/etc/X11/xorg.conf` and `/etc/X11/xorg.conf.d/` and reboot before '
'upgrading to make sure you have a graphical session after upgrading.'
)
FMT_LIST_SEPARATOR = '\n - {}'


def _printable_drv(facts):
output = ''
for fact in facts:
for driver in fact.xorg_drivers:
output += FMT_LIST_SEPARATOR.format(driver.driver)
if driver.has_options:
output += ' (with custom driver options)'
return output


class XorgDrvCheck8to9(Actor):
"""
Warn if Xorg deprecated drivers are in use.
"""

name = 'xorgdrvcheck8to9'
consumes = (XorgDrvFacts,)
produces = (Report,)
tags = (IPUWorkflowTag, ChecksPhaseTag)

def process(self):
facts = self.consume(XorgDrvFacts)
deprecated_drivers = _printable_drv(facts)
if len(deprecated_drivers) > 0:
create_report([
reporting.Title('Deprecated Xorg driver detected'),
reporting.Summary(SUMMARY_XORG_DEPRECATE_DRIVERS_FMT.format(deprecated_drivers)),
reporting.Severity(reporting.Severity.MEDIUM),
reporting.Groups([reporting.Groups.DRIVERS]),
reporting.Remediation(hint=SUMMARY_XORG_DEPRECATE_DRIVERS_HINT)
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from leapp.models import XorgDrv, XorgDrvFacts
from leapp.reporting import Report


def test_actor_with_deprecated_driver(current_actor_context):
for driver in ['RADEON', 'ATI', 'AMDGPU', 'MACH64', 'intel', 'spiceqxl', 'qxl', 'NOUVEAU', 'NV', 'VESA']:
xorg_drv = [XorgDrv(driver=driver, has_options=False)]

current_actor_context.feed(XorgDrvFacts(xorg_drivers=xorg_drv))
current_actor_context.run()
assert current_actor_context.consume(Report)


def test_actor_without_deprecated_driver(current_actor_context):
xorg_drv = []

current_actor_context.feed(XorgDrvFacts(xorg_drivers=xorg_drv))
current_actor_context.run()
assert not current_actor_context.consume(Report)
28 changes: 28 additions & 0 deletions repos/system_upgrade/el8toel9/actors/xorgdrvfact/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from leapp.actors import Actor
from leapp.libraries.actor.xorgdriverlib import check_drv_and_options, get_xorg_logs_from_journal
from leapp.libraries.stdlib import api
from leapp.models import XorgDrvFacts
from leapp.tags import FactsPhaseTag, IPUWorkflowTag


class XorgDrvFacts8to9(Actor):
"""
Check the journal logs for deprecated Xorg drivers.
This actor checks the journal logs and looks for deprecated Xorg drivers.
"""

name = 'xorgdrvfacts8to9'
consumes = ()
produces = (XorgDrvFacts,)
tags = (IPUWorkflowTag, FactsPhaseTag)

def process(self):
xorg_logs = get_xorg_logs_from_journal()
deprecated_drivers = []
for driver in ['RADEON', 'ATI', 'AMDGPU', 'MACH64', 'intel', 'spiceqxl', 'qxl', 'NOUVEAU', 'NV', 'VESA']:
deprecated_driver = check_drv_and_options(driver, xorg_logs)
if deprecated_driver:
deprecated_drivers.append(deprecated_driver)

api.produce(XorgDrvFacts(xorg_drivers=deprecated_drivers))
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Helper functions
#

import re

from leapp.libraries.stdlib import api, CalledProcessError, run
from leapp.models import XorgDrv


def check_drv_and_options(driver, logs):
regex_driver = re.compile(''.join([driver, '.*DPI set to']))
regex_options = re.compile(''.join([r'\(\*\*\)', '.*', driver]))
has_driver = False
has_options = False

for line in logs:
if re.search(regex_driver, line):
has_driver = True
if re.search(regex_options, line):
has_options = True

if not has_driver:
return None

return XorgDrv(driver=driver, has_options=has_options)


def get_xorg_logs_from_journal():
try:
output = run(['/usr/bin/journalctl', '/usr/libexec/Xorg', '-o', 'cat', '-b', '0'], split=True)
except CalledProcessError:
api.current_logger().debug('No Xorg logs found in journal.')
return []

return output['stdout']
Loading

0 comments on commit 948c782

Please sign in to comment.