zlacker

[parent] [thread] 12 comments
1. Muffin+(OP)[view] [source] 2023-07-10 15:10:45
> virtual machine monitor

Is it good to think of libvirt as a virtual machine mointor, or is that more "virtual machine management"?

replies(2): >>zbroze+83 >>adql+zg
2. zbroze+83[view] [source] 2023-07-10 15:24:01
>>Muffin+(OP)
I'd love to get a clear explanation of what libvirt actually does. As far as I can tell it's a qemu argument assembler and launcher. For my own use-case, I just launch qemu from systemd unit files:

https://wiki.archlinux.org/title/QEMU#With_systemd_service

replies(2): >>Muffin+Y8 >>bonzin+nc
◧◩
3. Muffin+Y8[view] [source] [discussion] 2023-07-10 15:49:40
>>zbroze+83
> As far as I can tell it's a qemu argument assembler

Raises a few questions to me:

Can you use KVM/do KVM stuff without QEMU?

Can you do libvirt stuff without QEMU?

Hoping the answers to both aren't useless/"technically, but why would you want to?"

replies(5): >>simcop+4b >>jonono+Lc >>zokier+5f >>adql+0h >>yjftsj+Y0b
◧◩◪
4. simcop+4b[view] [source] [discussion] 2023-07-10 15:59:11
>>Muffin+Y8
> Can you use KVM/do KVM stuff without QEMU?

Yes there's a few things out there like Firecracker that use KVM without using QEMU. I'm not completely aware of all of them but they do exist

> Can you do libvirt stuff without QEMU?

Yes it can also manager LXC containers and a few other types like Xen and Bhyve and Virtuozzo, like QEMU without KVM. The without KVM part is important to letting you run VMs that are emulating other architectures than the native one.

For a good bit of this, it is "why would you want to" but there are definitely real cases where you'd want to be able to do this. Like the LXC or Virtuozzo support means that you can run lighter weight containers (same underlying tech as Docker essentially) through the same orchestration/management that you use for virtual machines. And the Bhyve support lets you do the same thing for running things on top of FreeBSD (though I've never used it this way) so that a heterogeneous mix of hosts is managed through the same interfaces.

◧◩
5. bonzin+nc[view] [source] [discussion] 2023-07-10 16:06:54
>>zbroze+83
The main important point is that Libvirt takes care of privilege separation.

It makes sure that if your VM and/or QEMU are broken out of, there are extra layers to prevent getting access to the whole physical machine. For example it runs QEMU as a very limited user and, if you're using SELinux, the QEMU process can hardly read any file other than the vm image file.

By contrast the method in the arch wiki runs QEMU as root. QEMU is exposed to all sort of untrusted input, so you really don't want it to run as root.

Libvirt also handles cross machine operations such as live migration, and makes it easier to query a bunch of things from QEMU.

For more info see https://www.redhat.com/en/blog/all-you-need-know-about-kvm-u...

replies(1): >>zbroze+I61
◧◩◪
6. jonono+Lc[view] [source] [discussion] 2023-07-10 16:08:14
>>Muffin+Y8
libvirt supports other hypervisors than QEMU, such as VirtualBox, Xen and LXC.
replies(1): >>Muffin+4e
◧◩◪◨
7. Muffin+4e[view] [source] [discussion] 2023-07-10 16:13:46
>>jonono+Lc
I know ChatGPT responses get downvoted here but I fed it this to help me better understand this:

> is KVM a hypervisor? is it type 1 or type 2? is QEMU a hypervisor, is it type 1 or type 2? if QEMU is using KVM, is QEMU then not a hypervisor in that use case?

Yes, KVM (Kernel-Based Virtual Machine) is indeed a hypervisor. It's a type 1 hypervisor, also known as a "bare metal" hypervisor. This is because KVM directly runs on the host's hardware to control the hardware and to manage guest operating systems. The fact that it's a Linux kernel module that allows the Linux kernel to function as a hypervisor makes it very efficient.

QEMU (Quick Emulator) is a bit more complex. By itself, it is technically a type 2 or "hosted" hypervisor, meaning it runs within a conventional operating system environment. QEMU is a generic, open-source machine emulator and virtualizer that can emulate a variety of hardware types and host a range of guest operating systems.

However, when QEMU is used with KVM, the picture changes somewhat. In this case, KVM provides the hardware virtualization where it allows the host machine to call CPU instructions of full virtualization. Then, QEMU emulates the hardware resources and provides the user interface for the VM, thus allowing for better performance and usability. It's this combination of KVM's hardware acceleration capabilities and QEMU's emulation capabilities that makes them often used together.

In this case, QEMU is not acting purely as a hypervisor; it's providing hardware emulation and user interface for the VMs, while KVM is the part providing the hypervisor functionality. However, we often refer to the combination of "QEMU/KVM" as a unit when talking about this mode of operation.

◧◩◪
8. zokier+5f[view] [source] [discussion] 2023-07-10 16:17:54
>>Muffin+Y8
There is cute article from lwn demoing using kvm directly without anything else: https://lwn.net/Articles/658511/
replies(1): >>mrweas+ZM
9. adql+zg[view] [source] 2023-07-10 16:22:48
>>Muffin+(OP)
It's a lot of glue to present a consistent interface but it also does the management part.

"API to virtualization system" would probably be closest approximation but it also does some more advanced stuff like coordinating cross-host VM migration

◧◩◪
10. adql+0h[view] [source] [discussion] 2023-07-10 16:24:50
>>Muffin+Y8
> Can you use KVM/do KVM stuff without QEMU?

There are projects doing that althought qemu is the de facto standard and best bet if you don't need to boot your machines in 20ms

> Can you do libvirt stuff without QEMU?

Libvirt have many backends so yes. IIRC it can even manage virtualbox, althought I'm, not sure why anyone would want to

> Hoping the answers to both aren't useless/"technically, but why would you want to?"

...why? Is there a problem kvm+qemu+libvirt doesn't solve for you?

◧◩◪◨
11. mrweas+ZM[view] [source] [discussion] 2023-07-10 18:15:05
>>zokier+5f
That is really neat, it never occurred to me that you could just use KVM as a sort of sandbox.
◧◩◪
12. zbroze+I61[view] [source] [discussion] 2023-07-10 19:39:07
>>bonzin+nc
Thank you, this is the best explanation of the utility that I've seen. I appreciate it.
◧◩◪
13. yjftsj+Y0b[view] [source] [discussion] 2023-07-13 14:42:05
>>Muffin+Y8
> Can you use KVM/do KVM stuff without QEMU?

Here's a post of someone using KVM from Python (raw, without needing a kvm library or anything): https://www.devever.net/~hl/kvm

[go to top]