-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
0037-Restore-support-for-detection-of-unsupported-hardwar.patch
497 lines (481 loc) · 19.5 KB
/
0037-Restore-support-for-detection-of-unsupported-hardwar.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
From 748643a2811b5ea7896ae9be7e6886c4146a4605 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<marmarek@invisiblethingslab.com>
Date: Sat, 2 Sep 2023 23:36:10 +0200
Subject: [PATCH] Restore support for detection of unsupported hardware
This reverts commit 027ba76bd5c8e715451803b375661c7e0f07c571.
---
data/anaconda.conf | 6 +
data/profile.d/rhel.conf | 5 +
pyanaconda/core/configuration/system.py | 10 ++
pyanaconda/core/constants.py | 14 ++
pyanaconda/core/util.py | 72 +++++++++-
.../gui/spokes/lib/unsupported_hardware.glade | 126 ++++++++++++++++++
.../ui/gui/spokes/lib/unsupported_hardware.py | 48 +++++++
pyanaconda/ui/gui/spokes/welcome.py | 13 ++
.../ui/tui/spokes/unsupported_hardware.py | 57 ++++++++
.../pyanaconda_tests/ui/test_simple_ui.py | 2 +
10 files changed, 352 insertions(+), 1 deletion(-)
create mode 100644 pyanaconda/ui/gui/spokes/lib/unsupported_hardware.glade
create mode 100644 pyanaconda/ui/gui/spokes/lib/unsupported_hardware.py
create mode 100644 pyanaconda/ui/tui/spokes/unsupported_hardware.py
diff --git a/data/anaconda.conf b/data/anaconda.conf
index 351952bd00..d9c5553845 100644
--- a/data/anaconda.conf
+++ b/data/anaconda.conf
@@ -29,6 +29,12 @@ optional_modules =
# FIXME: This is a temporary solution.
type = UNKNOWN
+# Should the installer show a warning about unsupported hardware?
+can_detect_unsupported_hardware = False
+
+# Should the installer show a warning about removed support for hardware?
+can_detect_support_removed = False
+
# Should the installer show a warning about enabled SMT?
can_detect_enabled_smt = False
diff --git a/data/profile.d/rhel.conf b/data/profile.d/rhel.conf
index b0f316a01a..238a1c949b 100644
--- a/data/profile.d/rhel.conf
+++ b/data/profile.d/rhel.conf
@@ -9,6 +9,11 @@ profile_id = rhel
os_id = rhel
[Installation System]
+# The detection is disabled since #1645686.
+# can_detect_unsupported_hardware = True
+# can_detect_support_removed = True
+
+# Show a warning if SMT is enabled.
can_detect_enabled_smt = True
[Network]
diff --git a/pyanaconda/core/configuration/system.py b/pyanaconda/core/configuration/system.py
index caedd1e5fa..889e5c1d7f 100644
--- a/pyanaconda/core/configuration/system.py
+++ b/pyanaconda/core/configuration/system.py
@@ -147,6 +147,16 @@ class SystemSection(Section):
"""Can we configure the network?"""
return self._is_boot_iso or self._is_booted_os
+ @property
+ def can_detect_unsupported_hardware(self):
+ """Can we try to detect unsupported hardware?"""
+ return self._get_option("can_detect_unsupported_hardware", bool)
+
+ @property
+ def can_detect_support_removed(self):
+ """Can we try to detect removed support for hardware"""
+ return self._get_option("can_detect_support_removed", bool)
+
@property
def can_detect_enabled_smt(self):
"""Can we try to detect enabled SMT?"""
diff --git a/pyanaconda/core/constants.py b/pyanaconda/core/constants.py
index 06ff8cb041..5409536016 100644
--- a/pyanaconda/core/constants.py
+++ b/pyanaconda/core/constants.py
@@ -146,6 +146,20 @@ GEOLOC_CONNECTION_TIMEOUT = 5
ANACONDA_ENVIRON = "anaconda"
FIRSTBOOT_ENVIRON = "firstboot"
+# Tainted hardware
+TAINT_SUPPORT_REMOVED = 27
+TAINT_HARDWARE_UNSUPPORTED = 28
+
+WARNING_SUPPORT_REMOVED = N_(
+ "Support for this hardware has been removed in this major OS release. Please check the "
+ "removed functionality section of the release notes."
+)
+
+WARNING_HARDWARE_UNSUPPORTED = N_(
+ "This hardware (or a combination thereof) is not supported by Red Hat. For more information "
+ "on supported hardware, please refer to http://www.redhat.com/hardware."
+)
+
# Storage messages
WARNING_NO_DISKS_DETECTED = N_(
"No disks detected. Please shut down the computer, connect at least one disk, and restart "
diff --git a/pyanaconda/core/util.py b/pyanaconda/core/util.py
index 537201995d..fbe811cf90 100644
--- a/pyanaconda/core/util.py
+++ b/pyanaconda/core/util.py
@@ -40,9 +40,12 @@ from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.path import make_directories, open_with_perm, join_paths
from pyanaconda.core.process_watchers import WatchProcesses
from pyanaconda.core.constants import DRACUT_SHUTDOWN_EJECT, \
- IPMI_ABORTED, X_TIMEOUT, PACKAGES_LIST_FILE
+ IPMI_ABORTED, X_TIMEOUT, PACKAGES_LIST_FILE, \
+ TAINT_HARDWARE_UNSUPPORTED, TAINT_SUPPORT_REMOVED, \
+ WARNING_HARDWARE_UNSUPPORTED, WARNING_SUPPORT_REMOVED
from pyanaconda.core.live_user import get_live_user
from pyanaconda.errors import RemovedModuleError
+from pyanaconda.flags import flags
from pyanaconda.anaconda_logging import program_log_lock
from pyanaconda.anaconda_loggers import get_module_logger, get_program_logger
@@ -596,6 +599,73 @@ def vtActivate(num):
return ret == 0
+def get_kernel_taint(flag):
+ """Get a value of a kernel taint.
+
+ :param flag: a kernel taint flag
+ :return: False if the value of taint is 0, otherwise True
+ """
+ try:
+ tainted = int(open("/proc/sys/kernel/tainted").read())
+ except (OSError, ValueError):
+ tainted = 0
+
+ return bool(tainted & (1 << flag))
+
+
+def find_hardware_with_removed_support():
+ """Find hardware with removed support.
+
+ :return: a list of hardware specifications
+ """
+ pattern = "Warning: (.*) - Support for this device has been removed in this major release."
+ hardware = []
+
+ for line in execReadlines("journalctl", ["-b", "-k", "-g", pattern, "-o", "cat"]):
+ matched = re.match(pattern, line)
+
+ if matched:
+ hardware.append(matched.group(1))
+
+ return hardware
+
+
+def detect_unsupported_hardware():
+ """Detect unsupported hardware.
+
+ :return: a list of warnings
+ """
+ warnings = [] # pylint: disable=redefined-outer-name
+
+ if flags.automatedInstall or not conf.target.is_hardware:
+ log.info("Skipping detection of unsupported hardware.")
+ return []
+
+ # Check TAINT_HARDWARE_UNSUPPORTED
+ if not conf.system.can_detect_unsupported_hardware:
+ log.debug("This system doesn't support TAINT_HARDWARE_UNSUPPORTED.")
+ elif get_kernel_taint(TAINT_HARDWARE_UNSUPPORTED):
+ warnings.append(WARNING_HARDWARE_UNSUPPORTED)
+
+ # Check TAINT_SUPPORT_REMOVED
+ if not conf.system.can_detect_support_removed:
+ log.debug("This system doesn't support TAINT_SUPPORT_REMOVED.")
+ elif get_kernel_taint(TAINT_SUPPORT_REMOVED):
+ warning = WARNING_SUPPORT_REMOVED
+ hardware = find_hardware_with_removed_support()
+
+ if hardware:
+ warning += "\n\n" + "\n".join(hardware)
+
+ warnings.append(warning)
+
+ # Log all warnings.
+ for msg in warnings:
+ log.warning(msg)
+
+ return warnings
+
+
def xprogressive_delay():
""" A delay generator, the delay starts short and gets longer
as the internal counter increases.
diff --git a/pyanaconda/ui/gui/spokes/lib/unsupported_hardware.glade b/pyanaconda/ui/gui/spokes/lib/unsupported_hardware.glade
new file mode 100644
index 0000000000..576f635003
--- /dev/null
+++ b/pyanaconda/ui/gui/spokes/lib/unsupported_hardware.glade
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.6"/>
+ <object class="GtkTextBuffer" id="logBuffer"/>
+ <object class="GtkDialog" id="unsupportedHardwareDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="default_width">550</property>
+ <property name="type_hint">dialog</property>
+ <property name="decorated">False</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="uhd-vbox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="uhd-action_area">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="quitButton">
+ <property name="label" translatable="yes" context="GUI|Welcome|Unsupported Hardware Dialog">_Quit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="continueButton">
+ <property name="label" translatable="yes" context="GUI|Welcome|Unsupported Hardware Dialog">_Continue</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="uhd-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="unsupportedHardwareTitle">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Unsupported Hardware Detected</property>
+ <attributes>
+ <attribute name="font-desc" value="Cantarell Bold 12"/>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="uhd-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">dialog-warning</property>
+ <property name="icon_size">6</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="messageLabel">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="wrap">True</property>
+ <attributes>
+ <attribute name="font-desc" value="Cantarell 12"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">quitButton</action-widget>
+ <action-widget response="1">continueButton</action-widget>
+ </action-widgets>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="unsupportedHardwareDialog-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes">Unsupported Hardware</property>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/pyanaconda/ui/gui/spokes/lib/unsupported_hardware.py b/pyanaconda/ui/gui/spokes/lib/unsupported_hardware.py
new file mode 100644
index 0000000000..d4542be054
--- /dev/null
+++ b/pyanaconda/ui/gui/spokes/lib/unsupported_hardware.py
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2018 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+from pyanaconda.core.util import detect_unsupported_hardware
+from pyanaconda.ui.gui import GUIObject
+
+__all__ = ["UnsupportedHardwareDialog"]
+
+
+class UnsupportedHardwareDialog(GUIObject):
+ """Dialog for warnings about unsupported hardware.
+
+ Show this dialog if the unsupported hardware was detected.
+ """
+ builderObjects = ["unsupportedHardwareDialog"]
+ mainWidgetName = "unsupportedHardwareDialog"
+ uiFile = "spokes/lib/unsupported_hardware.glade"
+
+ def __init__(self, data):
+ super().__init__(data)
+ self._warnings = detect_unsupported_hardware()
+
+ @property
+ def supported(self):
+ return not self._warnings
+
+ def refresh(self):
+ message_label = self.builder.get_object("messageLabel")
+ message_label.set_label("\n\n".join(self._warnings))
+
+ def run(self):
+ rc = self.window.run()
+ self.window.destroy()
+ return rc
diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py
index ef5921622d..f66667c372 100644
--- a/pyanaconda/ui/gui/spokes/welcome.py
+++ b/pyanaconda/ui/gui/spokes/welcome.py
@@ -32,6 +32,8 @@ from pyanaconda.ui.gui.utils import setup_gtk_direction, escape_markup
from pyanaconda.core.async_utils import async_action_wait
from pyanaconda.ui.gui.spokes.lib.beta_warning_dialog import BetaWarningDialog
from pyanaconda.ui.gui.spokes.lib.lang_locale_handler import LangLocaleHandler
+from pyanaconda.ui.gui.spokes.lib.unsupported_hardware import UnsupportedHardwareDialog
+
from pyanaconda import localization
from pyanaconda.ui.helpers import get_distribution_text
from pyanaconda.core.product import get_product_is_final_release, get_product_name, \
@@ -285,6 +287,17 @@ class WelcomeLanguageSpoke(StandaloneSpoke, LangLocaleHandler):
ipmi_abort(scripts=self.data.scripts)
sys.exit(0)
+ dialog = UnsupportedHardwareDialog(self.data)
+ if not dialog.supported:
+
+ with self.main_window.enlightbox(dialog.window):
+ dialog.refresh()
+ rc = dialog.run()
+
+ if rc != 1:
+ ipmi_abort(scripts=self.data.scripts)
+ sys.exit(0)
+
StandaloneSpoke._on_continue_clicked(self, window, user_data)
@async_action_wait
diff --git a/pyanaconda/ui/tui/spokes/unsupported_hardware.py b/pyanaconda/ui/tui/spokes/unsupported_hardware.py
new file mode 100644
index 0000000000..97ad2e1488
--- /dev/null
+++ b/pyanaconda/ui/tui/spokes/unsupported_hardware.py
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+from simpleline.render.widgets import TextWidget
+
+from pyanaconda.ui.tui.spokes import StandaloneTUISpoke
+from pyanaconda.ui.tui.hubs.summary import SummaryHub
+from pyanaconda.core.i18n import N_
+from pyanaconda.core.util import detect_unsupported_hardware
+
+__all__ = ["UnsupportedHardwareSpoke"]
+
+
+class UnsupportedHardwareSpoke(StandaloneTUISpoke):
+ """Spoke for warnings about unsupported hardware.
+
+ Show this spoke if the unsupported hardware was detected.
+ """
+ preForHub = SummaryHub
+ priority = -10
+
+ @staticmethod
+ def get_screen_id():
+ """Return a unique id of this UI screen."""
+ return "unsupported-hardware-warning"
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.title = N_("Unsupported Hardware Detected")
+ self._warnings = detect_unsupported_hardware()
+
+ @property
+ def completed(self):
+ return not self._warnings
+
+ def refresh(self, args=None):
+ super().refresh(args)
+
+ for warning in self._warnings:
+ self.window.add_with_separator(TextWidget(warning))
+
+ def apply(self):
+ pass
diff --git a/tests/unit_tests/pyanaconda_tests/ui/test_simple_ui.py b/tests/unit_tests/pyanaconda_tests/ui/test_simple_ui.py
index db24bd7d75..cbd41774b9 100644
--- a/tests/unit_tests/pyanaconda_tests/ui/test_simple_ui.py
+++ b/tests/unit_tests/pyanaconda_tests/ui/test_simple_ui.py
@@ -167,6 +167,7 @@ class SimpleUITestCase(unittest.TestCase):
# Check the actions classes.
self._check_actions([
+ "unsupported-hardware-warning",
"kernel-warning",
"installation-summary",
"installation-progress",
@@ -197,6 +198,7 @@ class SimpleUITestCase(unittest.TestCase):
# Check the screens.
self._check_screens([
# Warnings
+ "unsupported-hardware-warning",
"kernel-warning",
# Installation
--
2.45.2