Create vm with x11 forwarding

Hi
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!]

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

How can I solve this issue ?

Thanks a lot

Julia

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

Julia

1 Like