Skip to content

Add devices support on services

What does this MR do?

This MR is a rebased copy of !1753 (closed)

Adds support docker executor to expose host devices to services. A new service_devices mapping in the runner config controls which devices are exposed to services based on the service images name.

Example: Expose /dev/kvm and /dev/dri to all images named "emulator" with any tag.

[runners.docker]
  [runners.docker.services_devices]
      "emulator:*" = ["/dev/kvm", "/dev/dri"]

Why was this MR needed?

Services that require hardware resources have no access to the host and do not work. Here are several use-cases.

  • Hardware-acceleration with /dev/kvm for qemu commonly used in Android Emulator (and a lot more).
  • Device farms with /dev/bus/usb for STF (Smartphone testing farm) can be used for integration testing mobile apps with other IoT devices; something no other commercial product offers AFIAK.
  • Containers that require GPU access such as nvidia-docker images.

What's the best way to test this MR?

CI Tests. There is only a test that checks the config. I am not sure what more tests could/should be added.

The more complete test I did with a runner I compiled was to run an Android emulator in a service container, which requires /dev/kvm to work. I can confirm this works after applying this change, and does not work without this change.

What are the relevant issue numbers?

Closes #6208

Edited by Frederik Carlier

Merge request reports