Skip to content

Commit 94a82b3

Browse files
authored
Excluded unsupported Hyper-v modules in hv_modules tests for CVMs. (#4512)
CVMs do not surface emulated input devices or framebuffer/DRM over VMBus, so the corresponding kernel modules are intentionally absent in CVMs. Reference: https://elixir.bootlin.com/linux/v7.0/source/drivers/hv/channel_mgmt.c#L31 In the above file only modules with ".allowed_in_isolated = true," are available in CVMs. Below are modules that are not exposed to a guest when running as a Confidential VM. - hid_hyperv - hyperv_keyboard - hyperv_fb - hyperv_drm These modules should be skipped in checks for module presence and in reload tests on CVMs.
1 parent 9f6fbdf commit 94a82b3

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

lisa/features/security_profile.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,23 @@ def enabled(self) -> bool:
166166
security_profile=search_space.SetSpace(True, [SecurityProfileType.CVM]),
167167
encrypt_disk=True,
168168
)
169+
170+
171+
def is_cvm(node: Any) -> bool:
172+
"""
173+
Returns True if the node is provisioned as a Confidential VM.
174+
175+
Falls back to False when the platform does not expose a SecurityProfile
176+
feature (e.g. ready / hyperv platforms), so callers can use this as a
177+
guard without extra checks.
178+
"""
179+
try:
180+
settings = Feature.get_feature_settings(
181+
node.features[SecurityProfile].get_settings()
182+
)
183+
except Exception:
184+
return False
185+
return (
186+
isinstance(settings, SecurityProfileSettings)
187+
and settings.security_profile == SecurityProfileType.CVM
188+
)

lisa/microsoft/testsuites/core/hv_module.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,33 @@
1515
TestSuiteMetadata,
1616
simple_requirement,
1717
)
18+
from lisa.features.security_profile import is_cvm
1819
from lisa.operating_system import BSD, Redhat
1920
from lisa.sut_orchestrator import AZURE, HYPERV, READY
2021
from lisa.sut_orchestrator.azure.platform_ import AzurePlatform
2122
from lisa.tools import KernelConfig, LisDriver, Lsinitrd, Lsmod, Modinfo, Modprobe
2223
from lisa.tools.kernel_config import ModulesType
2324
from lisa.util import LisaException, SkippedException
2425

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+
2545

2646
@TestSuiteMetadata(
2747
area="core",
@@ -95,6 +115,11 @@ def verify_initrd_modules(self, environment: Environment) -> None:
95115
"hyperv_keyboard": "hyperv-keyboard.ko",
96116
}
97117
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)
98123
hv_modules_file_names = {
99124
k: v
100125
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:
194219

195220
if isinstance(environment.platform, AzurePlatform):
196221
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)
197227
if not ("hyperv_fb" in missing_modules and "hyperv_drm" in missing_modules):
198228
# as long as both of these modules are not missing, we are OK to pass.
199229
missing_modules.discard("hyperv_fb")
@@ -237,8 +267,15 @@ def verify_reload_hyperv_modules(self, log: Logger, node: Node) -> None:
237267
loadable_modules = set(
238268
self._get_modules_by_type(node, module_type=ModulesType.MODULE)
239269
)
270+
node_is_cvm = is_cvm(node)
240271

241272
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
242279
if module not in loadable_modules:
243280
log.debug(f"{module} is not a reloadable module")
244281
skipped_modules.append(module)

0 commit comments

Comments
 (0)