Comparing libvirt vs LXD

Hey, have anyone used libvirt? How’s your experience compared to LXD? Is it true that libvirt is more configurable than LXD and allows to more customize VMs? Can I use LXC containers together with libvirt?

Hello :slight_smile:

I used Libvirt previously in my homelab before discovering LXD. My experience with LXD is way more pleasant on how you can manage containers and VMs. IMHO, Libvirt is too low-level as an API for using it directly as human. Yes you have some nice tools to interact with it, but I prefer what LXD provides, it feels much simpler and pleasant to use.

Yes for VM, Libvirt is almost unlimited in terms of configurability for your machines compared to LXD, but in the end you will finish with a command-line for virt-install with dozens of lines (if not more) :smiley: Is it needed ? Personally, I don’t need it, I just need sane defaults with a spice of configuration (vCPU, memory, additional disks…etc). For the containers, the experience is way more pleasant than with Libvirt, with LXD you have this kind of image/template store integration with the storage backend to easily boot your containers (and VM too). I missed this so much with Libvirt…

LXD feels like a small local cloud on your machines where you can boot VM and containers in seconds without spending a lot of time knowing all the configurations you need to add to your virt-install command to boot your VM. Yes you can script it or using virt-manager, but using an LXD feature such as profile, you are good to go instantly once you have configured it.

How did you manage LXC containers when you used libvirt?

I almost never used it, I tried some times but I thought it was a bit annoying to play with (XML, XML, XML…bruh) and ended use VMs with Libvirt most of the time. For some times, I litteraly installed LXD co-located with Libvirt to use system containers (when VM support wasn’t a thing in LXD) but it wasn’t ideal (I used Libvirt on Red Hat with SELinux, and few years back, it was a bit a PITA to deal with snapd and SELinux sometimes). And other time, I used Podman as system containers with systemd as PID1 inside the containers, it was fun but not as great as LXD.

Since LXD brought VM support to the table, I ditched Libvirt completly. The main strength of LXD is to bring an unified “interface” for both VM and containers on storage and network side of things (much like what Proxmox is doing). It has been explained by @stgraber here :