|
15 | 15 | TestSuiteMetadata, |
16 | 16 | simple_requirement, |
17 | 17 | ) |
| 18 | +from lisa.features.security_profile import is_cvm |
18 | 19 | from lisa.operating_system import BSD, Redhat |
19 | 20 | from lisa.sut_orchestrator import AZURE, HYPERV, READY |
20 | 21 | from lisa.sut_orchestrator.azure.platform_ import AzurePlatform |
21 | 22 | from lisa.tools import KernelConfig, LisDriver, Lsinitrd, Lsmod, Modinfo, Modprobe |
22 | 23 | from lisa.tools.kernel_config import ModulesType |
23 | 24 | from lisa.util import LisaException, SkippedException |
24 | 25 |
|
| 26 | +# CVMs do not surface emulated input devices or framebuffer/DRM over VMBus, |
| 27 | +# so the corresponding kernel modules are intentionally absent in CVMs. |
| 28 | +# Reference: |
| 29 | +# https://elixir.bootlin.com/linux/v7.0/source/drivers/hv/channel_mgmt.c#L31 |
| 30 | +# In the above file only modules with ".allowed_in_isolated = true," are available |
| 31 | +# in CVMs. |
| 32 | +# Below are modules that are not exposed to a guest when running as a Confidential VM. |
| 33 | +# These modules should be skipped in checks for module presence and in reload tests on |
| 34 | +# CVMs. |
| 35 | + |
| 36 | +_CVM_UNAVAILABLE_MODULES = frozenset( |
| 37 | + { |
| 38 | + "hid_hyperv", |
| 39 | + "hyperv_keyboard", |
| 40 | + "hyperv_fb", |
| 41 | + "hyperv_drm", |
| 42 | + } |
| 43 | +) |
| 44 | + |
25 | 45 |
|
26 | 46 | @TestSuiteMetadata( |
27 | 47 | area="core", |
@@ -95,6 +115,11 @@ def verify_initrd_modules(self, environment: Environment) -> None: |
95 | 115 | "hyperv_keyboard": "hyperv-keyboard.ko", |
96 | 116 | } |
97 | 117 | skip_modules = self._get_built_in_modules(node) |
| 118 | + # CVMs do not have host-emulated input/display devices, so the |
| 119 | + # corresponding modules are legitimately absent from initrd. Treat |
| 120 | + # them as built-in for the purposes of this check. |
| 121 | + if is_cvm(node): |
| 122 | + skip_modules = list(set(skip_modules) | _CVM_UNAVAILABLE_MODULES) |
98 | 123 | hv_modules_file_names = { |
99 | 124 | k: v |
100 | 125 | for (k, v) in all_necessary_hv_modules_file_names.items() |
@@ -194,6 +219,11 @@ def verify_hyperv_modules(self, log: Logger, environment: Environment) -> None: |
194 | 219 |
|
195 | 220 | if isinstance(environment.platform, AzurePlatform): |
196 | 221 | missing_modules.discard("hid_hyperv") |
| 222 | + # CVMs legitimately do not load host-emulated input or framebuffer |
| 223 | + # modules, so absence is expected and must not fail this test. |
| 224 | + if is_cvm(node): |
| 225 | + for module in _CVM_UNAVAILABLE_MODULES: |
| 226 | + missing_modules.discard(module) |
197 | 227 | if not ("hyperv_fb" in missing_modules and "hyperv_drm" in missing_modules): |
198 | 228 | # as long as both of these modules are not missing, we are OK to pass. |
199 | 229 | missing_modules.discard("hyperv_fb") |
@@ -237,8 +267,15 @@ def verify_reload_hyperv_modules(self, log: Logger, node: Node) -> None: |
237 | 267 | loadable_modules = set( |
238 | 268 | self._get_modules_by_type(node, module_type=ModulesType.MODULE) |
239 | 269 | ) |
| 270 | + node_is_cvm = is_cvm(node) |
240 | 271 |
|
241 | 272 | for module in hv_modules: |
| 273 | + if node_is_cvm and module in _CVM_UNAVAILABLE_MODULES: |
| 274 | + log.debug( |
| 275 | + f"{module} is not available on Confidential VMs, skipping reload" |
| 276 | + ) |
| 277 | + skipped_modules.append(module) |
| 278 | + continue |
242 | 279 | if module not in loadable_modules: |
243 | 280 | log.debug(f"{module} is not a reloadable module") |
244 | 281 | skipped_modules.append(module) |
|
0 commit comments