Can't to forward a sound card to container LXC.

Yashalta

Member
Feb 26, 2018
8
0
6
25
I'm trying to forward a sound card to container LXC and get error.
Code:
mknod: snd/controlC0: Operation not permitted
mknod: snd/controlC2: Operation not permitted
mknod: snd/controlC1: Operation not permitted
mknod: snd/hwC2D0: Operation not permitted
mknod: snd/pcmC0D0p: Operation not permitted
mknod: snd/pcmC0D0c: Operation not permitted
mknod: snd/pcmC0D1p: Operation not permitted
mknod: snd/pcmC2D3p: Operation not permitted
mknod: snd/pcmC1D0p: Operation not permitted
mknod: snd/timer: Operation not permitted
mknod: snd/seq: Operation not permitted

if i right understand "Unprivileged containers are not allowed to create device nodes."!
Then how do I organize sound support in a container LXC?

"Debian 10" is installed in the container.
 
hi,

I'm trying to forward a sound card to container LXC and get error.
what's the process you're following to forward the card? what changes have you made?

if i right understand "Unprivileged containers are not allowed to create device nodes."!
Then how do I organize sound support in a container LXC?
if it's necessary to create device nodes, then you can use a privileged CT or just a VM with pci passthrough
 
hi,

what's the process you're following to forward the card? what changes have you made?
...
Thanks for answer!
I do according to this instruction https://forum.proxmox.com/threads/forward-alsa-audio-to-lxc-container.45310/#post-215942
After this instruction, appear a sound devices in the LXC container!
Code:
root@Sound:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Dummy [Dummy], device 0: Dummy PCM [Dummy PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: NVidia [HDA NVidia], device 0: CX20561 Analog [CX20561 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@Sound:~#
And started to work an alsamixer!
123.png
But, there is no sound from the LXC container!
...

if it's necessary to create device nodes, then you can use a privileged CT or just a VM with pci passthrough
How to make a privileged LXC container?
Can you give more details about it!

PS - And even no sound in the host, where is installed Proxmox itself! I tried to run some files for testing, files like .mp3, .wav.
 
hi,

PS - And even no sound in the host, where is installed Proxmox itself! I tried to run some files for testing, files like .mp3, .wav.
that seems suspicious. first make sure you have sound working on the host

How to make a privileged LXC container?
Can you give more details about it!
backup the container, and then restore it. while restoring it, deactivate the "unprivileged" setting
 
hi,
that seems suspicious. first make sure you have sound working on the host
Done!
Everything works fine on the host .mp3 and so on!
But, if I login by ssh to container by user root and run command alsamixer everything is looked fine! I can see and select any sound card from the list available! But user root cannot run pulseaudio! And and therefore it can't listen .mp3 files!
Ok, I created a user "sound", logged by user "sound" and run command alsamixer.
As a result, I have an error:
Code:
sound@player:~$ alsamixer
Failed to load cookie file from cookie: Permission denied
Failed to load cookie file from cookie: Permission denied
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection terminated

cannot open mixer: Connection refused

see attached file.
What am I doing wrong?
 

Attachments

  • 2020-04-23_19-57.png
    2020-04-23_19-57.png
    164.6 KB · Views: 6
did you convert the container to privileged?

also what is your container config like? can you post it here?

maybe the second post in the thread you mentioned is a better solution
 
also what is your container config like? can you post it here?
Here is my container config, witch one located on the host.
Code:
arch: amd64
cores: 2
hostname: player
memory: 1024
net0: name=eth0,bridge=vmbr0,firewall=1,gw=192.168.18.1,hwaddr=76:6B:A1:1A:84:E$
ostype: debian
rootfs: local-lvm:vm-104-disk-0,size=15G
swap: 1024
unprivileged: 0
lxc.mount.entry: /dev/snd dev/snd none bind,create=dir,optional 0 0
lxc.cgroup.devices.allow: c 116:* rwm

maybe the second post in the thread you mentioned is a better solution

Yes, I do according to this instruction https://forum.proxmox.com/threads/forward-alsa-audio-to-lxc-container.45310/#post-215942
I have no other options!

I think, I guess what my problem is, but I don’t know how to solve it!
The problem is privileges!
If I run a container with a value "unprivileged: 0" then i see this

Code:
sound@player:~$ ls -all /dev/snd/
total 0
drwxr-xr-x 3 root root      280 Apr 25 07:16 .
drwxr-xr-x 7 root root      480 Apr 25 08:23 ..
drwxr-xr-x 2 root root       80 Apr 25 07:16 by-path
crw-rw---- 1 root audio 116,  4 Apr 25 07:16 controlC0
crw-rw---- 1 root audio 116, 10 Apr 25 07:16 controlC1
crw-rw---- 1 root audio 116,  8 Apr 25 07:16 hwC1D0
crw-rw---- 1 root audio 116,  9 Apr 25 07:16 hwC1D3
crw-rw---- 1 root audio 116,  3 Apr 25 07:16 pcmC0D0c
crw-rw---- 1 root audio 116,  2 Apr 25 07:16 pcmC0D0p
crw-rw---- 1 root audio 116,  6 Apr 25 07:16 pcmC1D0c
crw-rw---- 1 root audio 116,  5 Apr 25 07:43 pcmC1D0p
crw-rw---- 1 root audio 116,  7 Apr 25 07:16 pcmC1D3p
crw-rw---- 1 root audio 116,  1 Apr 25 07:16 seq
crw-rw---- 1 root audio 116, 33 Apr 25 07:16 timer
user is "root" and groop is "audio"!

and if, I run a container with a value "unprivileged: 1" then i see this
Code:
sound@player:~$ ls -all /dev/snd/
total 0
drwxr-xr-x 3 nobody nogroup     280 Apr 25 07:16 .
drwxr-xr-x 6 root   root        460 Apr 25 08:45 ..
drwxr-xr-x 2 nobody nogroup      80 Apr 25 07:16 by-path
crw-rw---- 1 nobody nogroup 116,  4 Apr 25 07:16 controlC0
crw-rw---- 1 nobody nogroup 116, 10 Apr 25 07:16 controlC1
crw-rw---- 1 nobody nogroup 116,  8 Apr 25 07:16 hwC1D0
crw-rw---- 1 nobody nogroup 116,  9 Apr 25 07:16 hwC1D3
crw-rw---- 1 nobody nogroup 116,  3 Apr 25 07:16 pcmC0D0c
crw-rw---- 1 nobody nogroup 116,  2 Apr 25 07:16 pcmC0D0p
crw-rw---- 1 nobody nogroup 116,  6 Apr 25 07:16 pcmC1D0c
crw-rw---- 1 nobody nogroup 116,  5 Apr 25 07:43 pcmC1D0p
crw-rw---- 1 nobody nogroup 116,  7 Apr 25 07:16 pcmC1D3p
crw-rw---- 1 nobody nogroup 116,  1 Apr 25 07:16 seq
crw-rw---- 1 nobody nogroup 116, 33 Apr 25 07:16 timer

user is "nobody" and groop is "nogroup"!

And, I can’t to change the privileges!
Code:
sound@player:~$ sudo chown root:audio /dev/snd/*
chown: changing ownership of '/dev/snd/by-path': Operation not permitted
chown: changing ownership of '/dev/snd/controlC0': Operation not permitted
chown: changing ownership of '/dev/snd/controlC1': Operation not permitted
chown: changing ownership of '/dev/snd/hwC1D0': Operation not permitted
chown: changing ownership of '/dev/snd/hwC1D3': Operation not permitted
chown: changing ownership of '/dev/snd/pcmC0D0c': Operation not permitted
chown: changing ownership of '/dev/snd/pcmC0D0p': Operation not permitted
chown: changing ownership of '/dev/snd/pcmC1D0c': Operation not permitted
chown: changing ownership of '/dev/snd/pcmC1D0p': Operation not permitted
chown: changing ownership of '/dev/snd/pcmC1D3p': Operation not permitted
chown: changing ownership of '/dev/snd/seq': Operation not permitted
chown: changing ownership of '/dev/snd/timer': Operation not permitted

Or it should be like this?