Running virtual machines with LXD 4.0

That’s an issue with your Linux distribution, your build of qemu wasn’t built with spice support.
I believe I had the LXD maintainer on Arch mention that to us earlier so there may be an open bug report against qemu in Arch to have this fixed.

Hello. I am trying build windows image, but stuck with this error.

[Error: Failed to run: forklimits limit=memlock:unlimited:unlimited fd=3 – /usr/bin/qemu-system-x86_64 -S -name win10 -uuid d648ea55-a11d-4bed-b07a-7e4721319ae4 -daemonize -cpu host -nographic -serial chardev:console -nodefaults -no-reboot -no-user-config -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny -readconfig /var/log/lxd/win10/qemu.conf -pidfile /var/log/lxd/win10/qemu.pid -D /var/log/lxd/win10/qemu.log -chroot /var/lib/lxd/virtual-machines/win10 -smbios type=2,manufacturer=Canonical Ltd.,product=LXD -runas nobody -drive file=/run/media/BIG/DWN/Win10_20H2_v2_Russian_x64.iso,index=0,media=cdrom,if=ide -drive file=/run/media/BIG/DWN/virtio-win-0.1.173.iso,index=1,media=cdrom,if=ide: [242623] aa-exec: ERROR: AppArmor interface not available
: Process exited with a non-zero value
Try lxc info --show-log win10 for more info

lxc --version 4.9
Any advice?

Looks like AppArmor isn’t available on your host system. What OS are you running and are you using LXD from the snap package?

ManjaroLinux 20.2.1. LXD from official Repositories.

That’s an issue with your Linux distribution, your build of qemu wasn’t built with spice support.
I believe I had the LXD maintainer on Arch mention that to us earlier so there may be an open bug report against qemu in Arch to have this fixed.

This is upstream qemu 5.2.0 bug. I spent a few hours to isolate the first bad comit.

Does your kernel have appamor support? As we check for the existence of /sys/kernel/security/apparmor and the aa-exec command as indicating that AppArmor is supported.

What’s the content of /sys/module/apparmor/parameters/enabled?

What kernel version are you using and can you supply the output of sudo aa-enabled?

[d@tired ~]$ cat /sys/module/apparmor/parameters/enabled
Y
[d@tired ~]$ sudo aa-enabled
[sudo] password for d:
Yes

What version of AppAmor do you have?

apparmor 3.0.1-1

So it looks like there is some issue with AppArmor on your OS, as its reporting that AppArmor is available and enabled, but when we try to run qemu via apparmor using aa-exec the command fails. Might be worth opening an issue with your distribution as this might be a known issue.

i switched kernel to 5.10, it help thanks, no more AppArmor error. Unfortunately there is another error, i guess its also problem with linux distro.

[tired d]# lxc start win10 --console
^[^[^[^[^[^[^[^[^[^[^[^[^[Error: Failed to run: forklimits limit=memlock:unlimited:unlimited fd=3 – /usr/bin/qemu-system-x86_64 -S -name win10 -uuid d648ea55-a11d-4bed-b07a-7e4721319ae4 -daemonize -cpu host -nographic -serial chardev:console -nodefaults -no-reboot -no-user-config -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny -readconfig /var/log/lxd/win10/qemu.conf -pidfile /var/log/lxd/win10/qemu.pid -D /var/log/lxd/win10/qemu.log -chroot /var/lib/lxd/virtual-machines/win10 -smbios type=2,manufacturer=Canonical Ltd.,product=LXD -runas nobody -drive file=/run/media/BIG/DWN/Win10_20H2_v2_Russian_x64.iso,index=0,media=cdrom,if=ide -drive file=/run/media/BIG/DWN/virtio-win-0.1.173.iso,index=1,media=cdrom,if=ide: qemu-system-x86_64:/var/log/lxd/win10/qemu.conf:27: There is no option group ‘spice’

this is /var/log/lxd/win10/qemu.conf

Graphical console

[spice]
unix = “on”
addr = “/var/log/lxd/win10/qemu.spice”
disable-ticketing = “on”

See further up this thread for that error:

Someone could help me, a month ago I went back to playing with linux after 10 years. how can I resolve the issue of VM resolution. just a driver?

You can’t, just use RDP instead of a VGA console.

There currently aren’t native VGA drivers for virtio-gpu on Windows, so you’re stuck with the generic VGA at 800x600 until then.

So RDP is the way to go at least until then.

1 Like

Hi, I’m having an issue with setting my ISOs, I’ve tried adding them as disk devices but that’s not working as well as the hostfs workaround but that folder is empty for some reason. I’m using the snap version of LXD 4.0 stables on Ubuntu 20.04 LTS. Would love it if you could help thanks.

We need to publish a new guide for Windows in LXD VMs as things got a lot easier recently. The short version of it is:

  • snap install distrobuilder --classic --edge
  • sudo distrobuilder repack-windows /path/to/origin/windows.iso /path/to/new/win.iso
  • lxc init win10 --empty --vm -c security.secureboot=false
  • lxc config device override win10 root size=50GiB
  • lxc config device add win10 iso disk source=/path/to/new/win.iso boot.priority=10
  • lxc start win10 --console=vga

No more need for any of that raw.qemu hackery, distrobuiler spits out an installation ISO which already includes all the needed drivers, so you can just attach it to LXD and run the installation.

1 Like

There is no repack-windows option unless I simply have the wrong version. Here are the available commands though

Available Commands:
  build-dir   Build plain rootfs
  build-lxc   Build LXC image from scratch
  build-lxd   Build LXD image from scratch
  help        Help about any command
  pack-lxc    Create LXC image from existing rootfs
  pack-lxd    Create LXD image from existing rootfs

Ah yeah, we need to put out a new version…
Run snap refresh distrobuilder --edge

I updated the instructions above to install it directly from edge too.