I’m trying to start VM instances without CPU limit. I was looking at how the qemu config gets generated in lxd/instance/drivers/driver_qemu.go
and based on that I was using this:
lxc config set $instancename limits.cpu 0-$(($(nproc)-1))
(Yes, this is not very good, because nproc
needs to be executed on the same host where the instance is running and limits.cpu
needs to be set again after moving the instance to a machine with different number of CPUs. But this was the best solution I could come up with.)
The problem is today it stopped working:
root@oth-node1:~# lxc start oth-ipsec
Error: Failed to run: forklimits limit=memlock:unlimited:unlimited fd=3 -- /snap/lxd/23243/bin/qemu-system-x86_64 -S -name oth-ipsec -uuid 39ea0d17-f911-4801-872e-5608dd0c697e -daemonize -cpu host,hv_passthrough,topoext -nographic -serial chardev:console -nodefaults -no-user-config -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=allow,resourcecontrol=deny -readconfig /var/snap/lxd/common/lxd/logs/oth-ipsec/qemu.conf -spice unix=on,disable-ticketing=on,addr=/var/snap/lxd/common/lxd/logs/oth-ipsec/qemu.spice -pidfile /var/snap/lxd/common/lxd/logs/oth-ipsec/qemu.pid -D /var/snap/lxd/common/lxd/logs/oth-ipsec/qemu.log -smbios type=2,manufacturer=Canonical Ltd.,product=LXD -runas lxd: : Process exited with non-zero value 1
Try `lxc info --show-log oth-ipsec` for more info
root@oth-node1:~# lxc info --show-log oth-ipsec
Name: oth-ipsec
Status: STOPPED
Type: virtual-machine
Architecture: x86_64
Location: oth-node1
Created: 2022/05/04 16:51 +07
Last Used: 2022/06/24 07:02 +07
Log:
qemu-system-x86_64:/var/snap/lxd/common/lxd/logs/oth-ipsec/qemu.conf:224: CPU is already assigned to node-id: 0
If I remove the limits.cpu
setting then the instance starts:
root@oth-node1:~# before="$(lxc config show oth-ipsec )"
root@oth-node1:~# lxc config unset oth-ipsec limits.cpu
root@oth-node1:~# diff -U1 <(echo "$before") <(lxc config show oth-ipsec)
--- /dev/fd/63 2022-07-06 12:04:27.076003913 +0700
+++ /dev/fd/62 2022-07-06 12:04:27.076003913 +0700
@@ -9,3 +9,2 @@
image.variant: salt
- limits.cpu: 0-47
limits.memory: 2GB
root@oth-node1:~# lxc start oth-ipsec
But that takes me back to the default 1CPU limit:
$ ssh oth-ipsec nproc
1
What is the best way to start qemu VM instances without limiting the number of CPUs?
(When starting LXC container instances, the default is to not limit the CPUs, that’s great, this problem is only with VM instances.)