-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 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
Showing
10 changed files
with
1,314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
repos/system_upgrade/el8toel9/actors/xorgdrvcheck/actor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
]) |
19 changes: 19 additions & 0 deletions
19
repos/system_upgrade/el8toel9/actors/xorgdrvcheck/tests/test_xorgdrvcheck.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
36 changes: 36 additions & 0 deletions
36
repos/system_upgrade/el8toel9/actors/xorgdrvfact/libraries/xorgdriverlib.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
Oops, something went wrong.