Best pulseaudio setup for LXD container with full desktop GPU (Nvidia) support

It is been a few days since I converted my lxc+nvidia+desktop support to lxd.
I have ubuntu 20.04 desktop/server with gdm running on tty1 and tty2. Archlinux desktop container running simultaneously on tty8 and tty7. gdm is on tty8 and the gnome desktop is in tty7(it is actually variable it can be on any of the tty3-tty7. The two gdm managers seem to respect each other territory). Everything seems to work, except for pulseaudio. Using the pulseaudio proxy that was suggested on multiple posts does not work. I think because of dependence on dbus/gnome. It does not work because the container has its own desktop and does not share the host desktop.

Mounting the host /dev/dsp is working but not consistently. I have to kill and restart pulseaudio in the container and host multiple time, until it does work. I am not an expert on gnome/dbus/pulseaudio interaction. I think it is because of access to the sound devices.
Any ideas how to have a more consistent pulseaudio support.

Why doesn’t the PulseAudio proxy device work?

I am not an expert on pulseaudio, but I think it is tied up to the local dbus (it seems like that when doing strace). For example (not excatly like my issue). if I remote login to a container (As in your example in [https://blog.simos.info/running-x11-software-in-lxd-containers/](http://Running X11 software in LXD containers) The proxy audio does not work (on the guest or the host). It is only working when you run the guest container in the desktop of the host.

In my situation (a separate guest desktop) I noticed that the guest container ignores the PULSE_SERVER and it uses the local /run/user/1000/pulse directory. This is why I had to mount /dev/dsp. This is probably causing conflicting access issues.

I would like add that before the upgrade to gnome 3.6 (on Arch) and ubuntu 20.04. Pulseaudio was working though the module module-x11-publish and using the environment variable PULSE_SERVER=host-ip. This stopped working after the upgrades.

Once you have instructions on getting the X server work in another container (so I can follow), I can have a look at the audio issue.

The following is from my github page the README file attached bellow summarize my setup. The config file is in the github above.

lxd Archlinux container with X11 server sharing GPU with host

Running arch Xserver container alongside Ubuntu Desktop sharing the Nvidia gpu

attchated config file (there is some redundances that I need to fix)
The host is ubuntu 20.04. I installed the full set of nvidia drives which come with the cuda. (I do not need to install the nvidia-cuda-toolkit)

After staring the privileged arch container:

  1. Install X11 and the nvidia Driver (It has to be the exact version as it is in the host)
  2. recompile gdm with the following flag added “–with-initial-vt=8”
  3. create a systemd unit (I called it rc.local) that will run before gdm. It will do the follwing. see (rc.local attachment)
    1. Establish network connection (there some incompitability between systemd and arch containers) So networking needs to be setup manually
    2. Create /etc/resolv.conf for DNS resolution
    3. create /usr/share/X11/xorg.conf.d/10-lxc-input.conf This adds the evdev devices to X11

I did not include my setup for pulseaudio since it does not work well (in the config file I share /dev/snd with the host)

Work that needs to get done

  1. Switch to wayland
  2. fix pulseaudio.
  3. Guest share the host gdm instead of using the container gdm

I think I know what is the issue. Pulseaudio is tied up to the desktop user of the host. As soon as I switch desktop (to the container desktop) I loose the access to pulseaudio. I think the best thing would be to have a headless server for pulseaudio in my host. In this way it will not be tied up to a specific desktop. I need to figure out how to do that.

1 Like