tiny-container-user-device-sharing automated


Image Types:
tiny-lxc-armhf / tiny-lxc-arm64 / tiny-lxc-amd64
Image Deployment:


Test of device sharing between host and Tiny unprivileged container started as user

Pre Conditions

  1. Clone the tests repository from another computer (Note that the branch being tested may change depending on the release, please make sure to clone the correct branch for the release in question):
  2. $ git clone --branch apertis/v2025dev2 https://gitlab.apertis.org/infrastructure/tiny-image-recipes.git
  3. Copy the test directory tiny-image-recipes to the target device:
  4. $ DUT_IP=<device-ip>
    $ scp -r tiny-image-recipes user@$DUT_IP:
  5. Log into the target device:
  6. $ ssh user@$DUT_IP

Execution Steps

  1. Enter test directory:
  2. $ cd tiny-image-recipes
  3. Ensure we allow user mapping:
  4. $ sysctl -w kernel.unprivileged_userns_clone=1
  5. Setup the AppArmor profile for container:
  6. $ sed s/__NAMESPACE_PLACEHOLDER__/lxc-apertis-tiny-userns/g lxc/lxc-tiny-connectivity-profile-template | apparmor_parser -qr
  7. Ensure we have loop device:
  8. $ modprobe loop
  9. Create the random file and map it to loop0 device on host:
  10. $ busybox dd if=/dev/urandom of=/var/test.img bs=1M count=1
    $ losetup /dev/loop0 /var/test.img
  11. Make sure user have correct mappings for test:
  12. $ usermod --add-subuids 1000-1000 user
    $ usermod --add-subuids 100000-165535 user
    $ usermod --add-subgids 6-6 user
    $ usermod --add-subgids 100000-165535 user
  13. Add user to group 'disk' for accessing to '/dev/loop0' device:
  14. $ usermod -a -G disk user
  15. Check that a simple loop device created on the host can be shared with the container and accessed from inside it:
  16. $ sudo -u user -H lavatests/test-device-sharing --ospack "$OSPACK" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-userns"
  17. Release the loop0 device on host after the test:
  18. $ losetup -d /dev/loop0


Test command should report "pass".