tmt icon indicating copy to clipboard operation
tmt copied to clipboard

Add KVM device access support to Podman

Open skycastlelily opened this issue 3 months ago • 2 comments

Fixes: #4327

Pull Request Checklist

  • [x] implement the feature
  • [ ] write the documentation
  • [x] extend the test coverage
  • [ ] update the specification
  • [ ] adjust plugin docstring
  • [ ] modify the json schema
  • [ ] mention the version
  • [ ] include a release note

skycastlelily avatar Nov 18 '25 08:11 skycastlelily

I would recommend making this feature more generic.

if self.kvm_device_access:
    additional_args.extend(['--device=/dev/kvm'])

Let's say I want to also expose /dev/ttyS3 and /dev/drm_dp_aux5, what would the tmt answer be in that case, --ttyS3-device-access, --drm_dp_aux5-device-access?

Use case: tests which use qemu, being able to use kvm speeds up things alot. Podman just needs --device=/dev/kvm to make that work.

Complete podman command line (use Ctrl-A x to stop qemu and quit container):

We have several options how to proceed:

  1. Add --kvm-device-access, solve that single use case, letting podman use /dev/kvm, and nothing else.
  2. We could treat the request more generic, can we maybe enable /dev/kvm every time when it's available? If it's safe and beneficial, maybe it could be new default, and we can always offer --no-kvm option to disable the feature in case of trouble.
  3. Podman's --device is quite generic, should we offer something similar? E.g. device key that would propagate its values to podman's --device - now that would probably unblock all devices, including /dev/kvm.

From these options, 1. seems like the least pleasing one, as it leaves every other device unavailable, and treats /dev/kvm in an exceptional way.

happz avatar Nov 18 '25 08:11 happz

I would recommend making this feature more generic.

if self.kvm_device_access:
    additional_args.extend(['--device=/dev/kvm'])

Let's say I want to also expose /dev/ttyS3 and /dev/drm_dp_aux5, what would the tmt answer be in that case, --ttyS3-device-access, --drm_dp_aux5-device-access?

Use case: tests which use qemu, being able to use kvm speeds up things alot. Podman just needs --device=/dev/kvm to make that work. Complete podman command line (use Ctrl-A x to stop qemu and quit container):

We have several options how to proceed:

  1. Add --kvm-device-access, solve that single use case, letting podman use /dev/kvm, and nothing else.
  2. We could treat the request more generic, can we maybe enable /dev/kvm every time when it's available? If it's safe and beneficial, maybe it could be new default, and we can always offer --no-kvm option to disable the feature in case of trouble.
  3. Podman's --device is quite generic, should we offer something similar? E.g. device key that would propagate its values to podman's --device - now that would probably unblock all devices, including /dev/kvm.

From these options, 1. seems like the least pleasing one, as it leaves every other device unavailable, and treats /dev/kvm in an exceptional way.

go with 2: https://github.com/teemtee/tmt/pull/4333/commits/6d553318063df9ce1c6d3078e195d67f53ce4450 :saluting_face:

skycastlelily avatar Nov 18 '25 09:11 skycastlelily