LXC is a userspace interface for the Linux kernel containment features. Through a powerful API and simple tools, it lets Linux users easily create and manage system or application containers. LXC devices can run lava tests within a container without disturbing the dispatcher host. The prime advantage of having LXC device in LAVA is the ability to provide a transparent, sandboxed environment with support for different OS types, enabling testing in different platforms.
Ensure that LXC is installed in your LAVA dispatcher host, if not use the following command to install LXC in Debian:
$ sudo apt install lxc
Refer the following links in order to setup networking for LXC in Debian:
LXC protocol is used for Android testing use-cases which removes the need for writing complex job definitions using Multinode. This is made possible by adding the usb path of the DUT that is attached to the dispatcher. The device configuration takes a special parameter called device_path with which the usb path of the DUT is exposed to LXC for Android testing. The device_path takes a list of paths (the path can be a symlink) which will get exposed to LXC.
Note
Do not run adb daemon on the dispatcher host, which will grab the DUT and will hinder exposing it to LXC. Similarly, remove fastboot packages from the dispatcher host.
commands:
connect: telnet localhost 0000
hard_reset: /usr/bin/pduclient --daemon services --hostname pdu00 --command reboot --port 00
power_off: /usr/bin/pduclient --daemon services --hostname pdu00 --command off --port 00
power_on: /usr/bin/pduclient --daemon services --hostname pdu00 --command on --port 00
pre_power_command: /usr/local/lab-scripts/usb_hub_control -p 0000 -m sync -u 00
adb_command: adb -s 12312BA123B123B1
fastboot_command: fastboot -u -s 12312BA123B123B1
device_type: hi6220-hikey
adb_serial_number: 12312BA123B123B1
fastboot_serial_number: 12312BA123B123B1
device_path: ['/dev/hikey01'] # This is a symlink created for HiKey using a
# udev rule.
actions:
deploy:
methods:
lxc:
fastboot:
connections:
lxc:
serial:
boot:
connections:
lxc:
serial:
methods:
uefi-menu:
parameters:
interrupt_prompt: "Android Fastboot mode"
interrupt_string: 'x'
item_markup:
- "["
- "]"
item_class: '0-9'
separator: ' '
label_class: 'a-zA-Z0-9\s\:'
bootloader_prompt: 'Start:'
boot_message: "Booting Linux Kernel..."
send_char: True
character_delay: 10
fastboot:
- select:
items:
- 'boot from eMMC'
timeouts:
actions:
apply-overlay-image:
seconds: 120
umount-retry:
seconds: 45
lava-test-shell:
seconds: 600
power_off:
seconds: 10
This is the recommended configuration for running your LXC devices within a LAVA dispatcher. In this configuration the containers will run as unprivileged user started by root user.
Allocate additional uids and gids to root:
$ sudo usermod --add-subuids 100000-165536 root
$ sudo usermod --add-subgids 100000-165536 root
Then edit /etc/lxc/default.conf
and append lxc.uidmap entry like below:
lxc.id_map = u 0 100000 65536
lxc.id_map = g 0 100000 65536
With the above in place any container created as root will be an unprivileged container.
Note
To apply configurations system wide for all LXC devices attached to
the dispatcher use /etc/lxc/default.conf
file.
For advanced LXC configurations and usage refer the following links: