Create vm with x11 forwarding

I am trying to get a vm. My launch command is:

lxc launch ubuntu:22.04 ubuntu2204vm --vm --profile default --profile x11

and I get this error:

Error: Failed instance creation: Failed creating instance record: Failed initialising instance: Invalid devices: Device validation failed for “PASocket”: Only NAT mode is supported for proxies on VM instances

The problem seems to be in my x11 profile. This x11 profile works well with containers though (obtained from: [Running X11 software in LXD containers – Mi blog lah!]

  environment.DISPLAY: :0
  environment.PULSE_SERVER: tcp:
  raw.idmap: both 1000 1000
  user.user-data: |
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
      - 'echo export PULSE_SERVER=tcp: | tee --append /home/ubuntu/.profile'
      - x11-apps
      - mesa-utils
      - pulseaudio
      - v4l-utils
description: GUI LXD profile
    bind: container
    connect: tcp:
    listen: tcp:
    type: proxy
    bind: container
    connect: unix:@/tmp/.X11-unix/X0
    listen: unix:@/tmp/.X11-unix/X0
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
    gid: "1000"
    type: gpu
    gid: "1000"
    path: /dev/video1
    type: unix-char
name: x11
used_by: []

How can I solve this issue ?

Thanks a lot


The proxy device only works for TCP/UDP connections using nat=true mode for VMs (as opposed to containers).

See Type: proxy - LXD documentation

thank you so much for your answer. However I don’t how to apply the recommended settings.

Should I launch the vm with only the default profile. Add a new proxy device with nat=true, and finaly add the x11 profile to the VM? How the lxc config add device… line should look like ?

You cannot pass an x11 unix socket from host to a VM currently. You would need to use something like x11 forwarding over ssh I think.

Thanks again ! It worked now . I am able to do a ssh -X to the virtual machine and launch x11 apps


1 Like