Running virtual machines with LXD 4.0

OK thanks. I installed all these: qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager, and still get thesame error.

By the way does virtualization in LXD require hardware enabled VT-x?

That won’t do you any good, those are userspace packages, you’re missing kernel modules.

Show:

  • uname -a
  • modinfo kvm
  • modinfo kvm_intel

Yes, LXD requires hardware virtualization (VTx or SVM on Intel/AMD).

uname -a
Linux localhost 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

modinfo kvm
filename: /lib/modules/5.4.0-26-generic/kernel/arch/x86/kvm/kvm.ko
license: GPL
author: Qumranet
srcversion: 0406E6D7275BE2E610C1AA9
depends:
retpoline: Y
intree: Y
name: kvm
vermagic: 5.4.0-26-generic SMP mod_unload
sig_id: PKCS#7
signer: Build time autogenerated kernel key
sig_key: 2E:1C:6B:CE:DF:4D:6E:F0:5B:25:79:E8:B6:0E:F2:9A:9A:01:CB:AF
sig_hashalgo: sha512
signature: 42:29:AE:40:7C:BD:A2:D1:92:B3:60:48:31:BC:CA:B8:FA:4A:45:04:
38:B9:09:75:69:4A:84:B7:E3:FD:ED:07:EB:65:40:90:B5:BA:0E:84:
D0:A7:43:DA:37:69:F8:F3:FF:1D:8D:88
parm: nx_huge_pages:bool
parm: nx_huge_pages_recovery_ratio:uint
parm: ignore_msrs:bool
parm: report_ignored_msrs:bool
parm: min_timer_period_us:uint
parm: kvmclock_periodic_sync:bool
parm: tsc_tolerance_ppm:uint
parm: lapic_timer_advance_ns:int
parm: vector_hashing:bool
parm: enable_vmware_backdoor:bool
parm: force_emulation_prefix:bool
parm: pi_inject_timer:bint
parm: halt_poll_ns:uint
parm: halt_poll_ns_grow:uint
parm: halt_poll_ns_grow_start:uint
parm: halt_poll_ns_shrink:uint

modinfo kvm_intel
filename: /lib/modules/5.4.0-26-generic/kernel/arch/x86/kvm/kvm-intel.ko
license: GPL
author: Qumranet
srcversion: DCBB34BC10742394CDE65F8
alias: cpu:type:x86,venfammod*:feature:0085
depends: kvm
retpoline: Y
intree: Y
name: kvm_intel
vermagic: 5.4.0-26-generic SMP mod_unload
sig_id: PKCS#7
signer: Build time autogenerated kernel key
sig_key: 2E:1C:6B:CE:DF:4D:6E:F0:5B:25:79:E8:B6:0E:F2:9A:9A:01:CB:AF
sig_hashalgo: sha512
signature: 6A:A7:17:71:5B:B0:0A:D2:8F:B5:76:8A:FB:21:1E:7D:89:9D:4B:13:
DF:64:60:DA:16:9B:7C:87:D6:94:91:B8
parm: enable_shadow_vmcs:bool
parm: nested_early_check:bool
parm: vpid:bool
parm: vnmi:bool
parm: flexpriority:bool
parm: ept:bool
parm: unrestricted_guest:bool
parm: eptad:bool
parm: emulate_invalid_guest_state:bool
parm: fasteoi:bool
parm: enable_apicv:bool
parm: nested:bool
parm: pml:bool
parm: dump_invalid_vmcs:bool
parm: preemption_timer:bool
parm: ple_gap:uint
parm: ple_window:uint
parm: ple_window_grow:uint
parm: ple_window_shrink:uint
parm: ple_window_max:uint
parm: pt_mode:int
parm: enlightened_vmcs:bool

Ok, try modprobe kvm and modprobe kvm_intel

root@localhost:~# modprobe kvm
root@localhost:~# modprobe kvm_intel
modprobe: ERROR: could not insert ‘kvm_intel’: Operation not supported

The CPU is AMD Epic.

Maybe Linode has VT-x off and Digital Ocean has it on?

Thanks.

Ah right, if it’s an Epyc, then you’d want modprobe kvm_amd instead.

root@localhost:~# modprobe kvm_amd
modprobe: ERROR: could not insert ‘kvm_amd’: Operation not supported

I also did this:-

root@localhost:~# kvm-ok
INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used

Ok, so looks like Linode is stripping the virtualization extensions from their guests.
That explains why those modules didn’t auto-load and why this isn’t working for you.

On a system where virtualization is supported, the kernel will normally auto-load the needed modules so none of this is needed. Running the commands by hand is a good way to see why it’s not working though :slight_smile:

Thanks for solving this! And thanks for making such a great product that LXD is now with both containers and VMs running side-by-side :smile:

1 Like

I thought I’d be able to see all running kvm vms using virsh list but I guess they are in a different namespace.

virsh list only lists you virtual machines managed by libvirt.

When trying to launch a copy of the published image, I’m getting " Failed converting image to raw … … Device is too small".

I tried using a profile wherein I set the root size to 60GB but it doesn’t seem to be picking it up.

This happens when trying to use both init and launch .

Any tips for this?

What storage driver is that?

Apologies, ZFS

Ok, you’ll need to do lxc storage set default volume.size 30GB or some suitable size which is identical or larger than the size used for that image.

The default is 10GB but the instructions for Windows above do use a larger image as Windows is quite space hungry.

1 Like

That worked! Thanks

Question, I already have a QEMU KVM running MacOS for iMessages purposes, is there any way to get this managed by LXD without rebuilding it?

macOS isn’t something we can run right now due to LXD relying on virtio for all its devices and there not being a kext for virtio-scsi.

1 Like

Ahh yes, it uses emulated AHCI right now. Thanks anyway!

Can we get a section for migrating current VMs on KVM to LXD?

The details are lacking for anyone new to LXD.

1 Like