Skip to content

Commit 954d165

Browse files
committed
qm-oci-hooks: various fixes
Split seat and devices hooks as otherwise the annotations were not matching correctly to execute the hooks when they should. Also, fix the package to add a missing dependency to include udevadm application. Signed-off-by: Albert Esteve <[email protected]>
1 parent e1d3d67 commit 954d165

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

oci-hooks/qm-device-manager/oci-qm-device-manager.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
},
66
"when": {
77
"annotations": {
8-
"^org\\.containers\\.qm\\.device\\..*$": "^.*$",
9-
"^org\\.containers\\.qm\\.wayland\\.seat": "^.*$"
8+
"^org\\.containers\\.qm\\.device\\..*$": "^.*$"
109
}
1110
},
1211
"stages": ["precreate"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "1.0.0",
3+
"hook": {
4+
"path": "/usr/libexec/oci/hooks.d/oci-qm-device-manager"
5+
},
6+
"when": {
7+
"annotations": {
8+
"^org\\.containers\\.qm\\.wayland\\.seat": "^.*$"
9+
}
10+
},
11+
"stages": ["precreate"]
12+
}

oci-hooks/tests/test_hook_configs.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ def test_hook_executable_exists(self, hook_configs, hook_name):
242242
# If absolute path fails, try relative to config file
243243
hook_path = config_path.parent / hook_path.name
244244

245+
# Special case: seat manager uses the shared device manager executable
246+
if not hook_path.exists() and hook_name == "oci-qm-seat-manager":
247+
hook_path = (
248+
config_path.parent.parent
249+
/ "qm-device-manager"
250+
/ hook_path.name
251+
)
252+
245253
assert hook_path.exists(), f"Hook executable not found: {hook_path}"
246254
assert hook_path.is_file(), f"Hook executable not a file: {hook_path}"
247255

@@ -262,12 +270,6 @@ def test_device_manager_annotations(self, hook_configs):
262270
device_patterns
263271
), "Device manager should support device annotations"
264272

265-
# Check that wayland patterns exist
266-
wayland_patterns = [p for p in annotations.keys() if "wayland" in p]
267-
assert (
268-
wayland_patterns
269-
), "Device manager should support Wayland annotations"
270-
271273
# Test that device patterns match expected device types
272274
test_annotations = [
273275
"org.containers.qm.device.audio",
@@ -402,6 +404,17 @@ def test_hook_config_integration(self, hook_configs, hook_name):
402404
# If absolute path fails, try relative to config directory
403405
full_hook_path = config_path.parent / Path(hook_path).name
404406

407+
# Special case: seat manager uses the shared device manager executable
408+
if (
409+
not full_hook_path.exists()
410+
and hook_name == "oci-qm-seat-manager"
411+
):
412+
full_hook_path = (
413+
config_path.parent.parent
414+
/ "qm-device-manager"
415+
/ Path(hook_path).name
416+
)
417+
405418
# Check that executable exists
406419
assert full_hook_path.exists(), (
407420
f"Hook executable not found: {full_hook_path} "

rpm/oci-hooks/qm-oci-hooks.spec

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ BuildRequires: git-core
1212

1313
# Runtime dependencies
1414
Requires: jq
15+
Requires: systemd-udev
16+
Requires: findutils
1517

1618
%description
1719
This package provides OCI hooks for QM containers that enable dynamic
@@ -21,6 +23,7 @@ This package is independent and can be installed within the qm container.
2123

2224
Included hooks:
2325
- qm-device-manager: Dynamic device mounting based on container annotations
26+
- qm-seat-manager: Wayland seat device management for systemd-logind integration
2427
- wayland-client-devices: GPU hardware acceleration for Wayland clients
2528

2629
The hooks are installed in standard locations:
@@ -46,6 +49,10 @@ install -m 755 oci-hooks/qm-device-manager/oci-qm-device-manager \
4649
install -m 644 oci-hooks/qm-device-manager/oci-qm-device-manager.json \
4750
%{buildroot}%{_datadir}/containers/oci/hooks.d/oci-qm-device-manager.json
4851

52+
# Install QM Seat Manager hook
53+
install -m 644 oci-hooks/qm-seat-manager/oci-qm-seat-manager.json \
54+
%{buildroot}%{_datadir}/containers/oci/hooks.d/oci-qm-seat-manager.json
55+
4956
# Install Wayland Client Devices hook
5057
install -m 755 oci-hooks/wayland-client-devices/oci-qm-wayland-client-devices \
5158
%{buildroot}%{_libexecdir}/oci/hooks.d/oci-qm-wayland-client-devices
@@ -84,6 +91,7 @@ install -m 644 oci-hooks/wayland-client-devices/README.md \
8491
%dir %{_datadir}/containers/oci
8592
%dir %{_datadir}/containers/oci/hooks.d
8693
%{_datadir}/containers/oci/hooks.d/oci-qm-device-manager.json
94+
%{_datadir}/containers/oci/hooks.d/oci-qm-seat-manager.json
8795
%{_datadir}/containers/oci/hooks.d/oci-qm-wayland-client-devices.json
8896

8997

subsystems/qm-oci-hooks/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dist: ## - Creates the QM OCI hooks package
2222
../qm/CODE-OF-CONDUCT.md \
2323
../qm/oci-hooks/qm-device-manager/oci-qm-device-manager \
2424
../qm/oci-hooks/qm-device-manager/oci-qm-device-manager.json \
25+
../qm/oci-hooks/qm-seat-manager/oci-qm-seat-manager.json \
2526
../qm/oci-hooks/qm-device-manager/README.md \
2627
../qm/oci-hooks/wayland-client-devices/oci-qm-wayland-client-devices \
2728
../qm/oci-hooks/wayland-client-devices/oci-qm-wayland-client-devices.json \

0 commit comments

Comments
 (0)