I am trying to better understand how libvirt communicates with KVM in order to be able to spin up KVM instances from a single process on the host machine that I am developing.
Does it use ioctl like qemu-kvm? Does it use some sort of remote messaging like dbus or direct messaging to a local socket (I'm leaning away from local socket) ? Or does it have direct binding into the kernel ABI for KVM?
Is it possible (as in possible above the kernel, not in the kernel) (and not the worst idea) to bypass libvirt and talk directly to KVM through the manner of which libvirt is using? (This part is just more of a curiosity)
Technically speaking, libvirt itself does not talk to KVM at all. KVM is a kernel module used by QEMU to provide CPU virtualization. Libvirt manages QEMU and lets QEMU deal with KVM. It is possible to write different userspace apps to use KVM - kvmtool is one such alternative to QEMU that uses the KVM kernel module. Libvirt talks to QEMU via QEMU's monitor protocol after launching the initial process.