[lxc-users] DVB - Card Passthrough

rob e redgerhoo at yahoo.com.au
Fri Jan 6 01:47:35 UTC 2017


Using Ubuntu Xenial, I pass USB DVB tuners through to MythTv running in 
an unprivileged LXD container. Not exactly the same but may provide some 
pointers

First you need to change ownership of adapters eg. “sudo chown -R 
root:video /dev/dvb”

then add <user> to video

===========================================================================

Next issue was how to grant unprivileged container access to host files 
(eg storage for recorded content), read this

https://gist.github.com/bloodearnest/ebf044476e70c4baee59c5000a10f4c8

For me the resulting profile looks like this

config:

   raw.lxc: |
     lxc.id_map = u 400000 1000 1
     lxc.id_map = g 400000 1000 1
   user.user-data: |
     #cloud-config
     users:
       - name: <your user id>
         primary-group: 400000
         uid: 400000  # only works in xenial
         groups: sudo
         shell: /bin/bash
         sudo: ['ALL=(ALL) NOPASSWD:ALL']
description: ""
devices: {}

===========================================================================

Then the container setup / definition looks like this (note the cgroup 
definitions, plus I copied the user and group mappings across from the 
above profile because the profile sometimes seemed to be unapplied - 
really needed for initial container definition though). I also tend to 
limit CPU and memory access of VMs

### This is a yaml representation of the configuration.
### Any line starting with a '# will be ignored.
###
### A sample configuration looks like:
### name: container1
### profiles:
### - default
### config:
###   volatile.eth0.hwaddr: 00:16:3e:e9:f8:7f
### devices:
###   homedir:
###     path: /extra
###     source: /home/user
###     type: disk
### ephemeral: false
###
### Note that the name is shown but cannot be changed

name: xenial-mythserver
profiles:
- <your base profile for access to host id resources>
- default
config:
   boot.autostart: "1"
   limits.cpu: 1,2,3
   limits.memory: 6GB
   raw.lxc: |
     lxc.cgroup.devices.allow= c 212:* rwm
     lxc.cgroup.devices.allow= c 189:* rwm
     lxc.cgroup.devices.allow= c 13:* rwm
     lxc.id_map= u 400000 1000 1
     lxc.id_map= g 400000 1000 1
   volatile.base_image: 
f452cda3bccb2903e56d53e402b9d35334b4276783d098a879be5d74b04e62e2
   volatile.eth0.hwaddr: xx:xx:xx:xx:xx:xx
   volatile.last_state.idmap: 
'[{"Isuid":true,"Isgid":false,"Hostid":165536,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":165536,"Nsid":0,"Maprange":65536}]'
devices:
   dvb0_demux:
     gid: "44"
     major: "212"
     minor: "0"
     path: /dev/dvb/adapter0/demux0
     type: unix-char
   dvb0_dvr:
     gid: "44"
     major: "212"
     minor: "1"
     path: /dev/dvb/adapter0/dvr0
     type: unix-char
   dvb0_frontend:
     gid: "44"
     major: "212"
     minor: "3"
     path: /dev/dvb/adapter0/frontend0
     type: unix-char
   dvb0_net:
     gid: "44"
     major: "212"
     minor: "2"
     path: /dev/dvb/adapter0/net0
     type: unix-char
   dvb1_demux:
     gid: "44"
     major: "212"
     minor: "4"
     path: /dev/dvb/adapter1/demux0
     type: unix-char
   dvb1_dvr:
     gid: "44"
     major: "212"
     minor: "5"
     path: /dev/dvb/adapter1/dvr0
     type: unix-char
   dvb1_frontend:
     gid: "44"
     major: "212"
     minor: "7"
     path: /dev/dvb/adapter1/frontend0
     type: unix-char
   dvb1_net:
     gid: "44"
     major: "212"
     minor: "6"
     path: /dev/dvb/adapter1/net0
     type: unix-char
   dvb2_demux:
     gid: "44"
     major: "212"
     minor: "8"
     path: /dev/dvb/adapter2/demux0
     type: unix-char
   dvb2_dvr:
     gid: "44"
     major: "212"
     minor: "9"
     path: /dev/dvb/adapter2/dvr0
     type: unix-char
   dvb2_frontend:
     gid: "44"
     major: "212"
     minor: "11"
     path: /dev/dvb/adapter2/frontend0
     type: unix-char
   dvb2_net:
     gid: "44"
     major: "212"
     minor: "10"
     path: /dev/dvb/adapter2/net0
     type: unix-char
   dvb3_demux:
     gid: "44"
     major: "212"
     minor: "12"
     path: /dev/dvb/adapter3/demux0
     type: unix-char
   dvb3_dvr:
     gid: "44"
     major: "212"
     minor: "13"
     path: /dev/dvb/adapter3/dvr0
     type: unix-char
   dvb3_frontend:
     gid: "44"
     major: "212"
     minor: "15"
     path: /dev/dvb/adapter3/frontend0
     type: unix-char
   dvb3_net:
     gid: "44"
     major: "212"
     minor: "14"
     path: /dev/dvb/adapter3/net0
     type: unix-char
   dvd_data:
     path: /mnt/xxx
     source: /mnt/xxxx
     type: disk
   eth0:
     name: eth0
     nictype: bridged
     parent: <your bridge name>
     type: nic
   music_data:
     path: /mnt/xxx
     source: /mnt/xxx
     type: disk
   root:
     path: /
     type: disk
   video_data:
     path: /mnt/xxxx
     source: /mnt/xxxx
     type: disk
ephemeral: false

===========================================================================

Now you can start the container and configure the network, recorder and 
whatever else you want to run


Rob



On 03/01/17 08:38, John Gubert wrote:
> Hello everyone,
>
> I am setting up my next container (Ubuntu Xenial) on my host (Ubuntu 
> Xenial), this one is supposed to stream TV from a dvb-s2 card to my 
> network.
>
> I intend to use TvHeadend software for this purpose, which I was able 
> to install inside the container and I tried to pass through the /dev 
> components of my dvb card:
>
> lxc config device add tv bridge0 unix-char path=/dev/ddbridge/card0
>
> lxc config device add tv demux0 unix-char path=/dev/dvb/adapter0/demux0
> lxc config device add tv dvr0 unix-char path=/dev/dvb/adapter0/dvr0
> lxc config device add tv frontend0 unix-char 
> path=/dev/dvb/adapter0/frontend0
> lxc config device add tv net0 unix-char path=/dev/dvb/adapter0/net0
>
> lxc config device add tv demux1 unix-char path=/dev/dvb/adapter1/demux0
> lxc config device add tv dvr1 unix-char path=/dev/dvb/adapter1/dvr0
> lxc config device add tv frontend1 unix-char 
> path=/dev/dvb/adapter1/frontend0
> lxc config device add tv net1 unix-char path=/dev/dvb/adapter1/net0
>
> As far as I can see, all those devices are available inside the host, 
> yet tvheadend does not find them.
>
> The former setup was a virtual machine based on kvm/qemu with pci 
> passthrough. I was hoping to increase responsiveness and decrease load 
> with a switch to LXD.
>
> Does one of you use a similar setup and know about some caveats I need 
> to look into? Or how to check inside the container, whether it is a 
> tvheadend or a container problem?
>
> kind regards,
>
> John
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20170106/2652c1a6/attachment.html>


More information about the lxc-users mailing list