Linux Hypervisor Setup (Libvirt/QEMU/KVM)
octetz.com
octetz.com
It’s good to see what this article details into it and how some can pull all this together … for free (or for a small sum).
I don't recall this being an issue before.
I ended up re-installing TrueNAS Scale beta, which I had installed and tried, but ran into a problem. Ended up finding the solution on the forums, something related to bridged or VLAN interfaces not coming up.
In the end I probably will just install Ubuntu and put Ganeti on these boxes, since that's been really reliable for me at work. I was actually hoping to try out Proxmox to possibly move to at work.
Has a pfSense/FreeBSD VM for a gateway and a bunch of VMs on a detached bridge. Also have several more bridges for test VMs for real-world airgapped network setup.
8 different OS distros. Also am tweaking a MIPS and a M1 QEMUs outside of Proxmox .
runs very quiet.
so now it’s my home datacenter.
One thing I had to do recently though is swap pfsense for Untangle because of drastically better FQ-CoDel implementation in Untangle.
Not sure why would one even do that.
:-(However, the YouTube breakdown by Battle(non)sense was conclusive (and is confirmed in my case in undeniable ways) so I switched.
Thing is it's hard to re-allocate this partition, and that's where all the iso images, and the backups go.
I tried to migrate a vm and boom - it filled up.
I tried to figure out how to reallocate it, but in the end, I found this (sort of hacky) solution documented:
https://pve.proxmox.com/wiki/Logical_Volume_Manager_(LVM)
basically:
# lvcreate -n vz -V 200G pve/data
# mkfs.ext4 /dev/pve/vz
# echo '/dev/pve/vz /var/lib/vz ext4 defaults 0 2' >> /etc/fstab
you migrate the stuff from /var/lib/vz to the new location and you have 200G for iso images/etcWhy this has to fight for storage from the root system, or why it's not easily expandable is a head-scratcher. I think it might be better to have a dedicated boot debian partition, a resizable/easily growable pve partition, then storage that can be allocated to vms/containers.
but yeah - that stopped me in my tracks, and when I'm doing it on a home machine you just don't have the time to chase this stuff down.
Made more sense to have a second drive or second but largest LVM to play with and store all things VM.
So confident that I disabled the Proxmox 'local' drive.
If you want full control of the disk layout and maybe want to do some more custom stuff, consider installing a base Debian and then install Proxmox VE on top of it [1].
The PVE installer makes it easy to get a system up and running quickly but is opinionated what the disk layout should be. That of course might not be working for everyone.
[0] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#advanc... [1] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#_insta...
I haven't had much luck with terraform with libvirt, and I miss Vagrant but don't want to lock myself into its syntax. Maybe I should just start using it again but I feel like there has got to be a good libvirt-based way.
Provisioning new test vms with userdata embedded into an kickstart-or-whatever iso that is provided to libvirt also seems clunky. docker-machine is no longer maintained so I can't use it as a vagrant replacement to just bring up sshable hosts. Multipass?
Curious as to how others have solved this.
Do you just manually run a huge virt-install command each time?
I started looking at this mock EC2 metadata service, but never did anything with it: https://github.com/sjjf/md_server
Ninja-edit: It seems like virt-install rencently abstracted the whole NoCloud-provider, this changes a lot of things: https://blog.wikichoon.com/2020/09/virt-install-cloud-init.h...
The tricky part is intercepting the requests and redirecting them to your service
Other than a working Proxmox install, you'll need to create a cloud-init template, which is documented here: https://pve.proxmox.com/wiki/Cloud-Init_Support
(For others, it's a simple-to-use CLI that provisions Ubuntu instances.)
virt-install -n centos -r 1024 --cpu=host -l http://mirror.cogentco.com/pub/linux/centos/6/os/x86_64/ --disk path=/var/lib/libvirt/images/centos.img,size=10,bus=virtio --boot kernel_args="console=/dev/ttyS0" -w network=internal,model=virtio --initrd-inject=centos.ks -x "ks=file:/centos.ks console=ttyS0" --graphics none
Setting up the serial console requires some configuration on the host part, too, unfortunately, depending on the OS.
As for what it “gives”, I suppose I’ve never migrated a VM outside of libvirt, though I’m not 100% sure if that’s not possible with plain old qemu+kvm
https://www.redhat.com/en/blog/all-you-need-know-about-kvm-u... (fixed now)
Recently, a new protocol to replace virtio has been defined. It is modeled on vfio ioctls and currently only can forward to another user space process, so we're calling it vfio-user. With this protocol, it's possible to emulate any PCI device rather than only virtio devices. Projects like SPDK (what I work on) can now use this to present fully emulated NVMe devices into guests and back them with whatever actual storage is available (a file, something over the network, a real NVMe SSD, etc). This allows an OS, including Windows, to boot from the virtual disk using it's in-box NVMe driver. This hasn't quite made it into a QEMU release yet, but it's close!
https://www.reddit.com/r/VFIO/comments/9iaj7x/smt_not_suppor...
So I guess, it worked, didn't look into raw qemu. I also use it infrequently enough that I would have to relearn the CLI all the time.
- I can get a list of the host machines in my cluster and how much memory and storage they have available.
- I can easily move VMs between hosts if I want to evacuate a host for hardware/software/firmware maintenance.
- It has the ability to set up DRBD backed VMs and live migrate between the host nodes.
- List what machines are running and on what hosts.
- Start and stop commmands don't require me to remember the settings on individual VMs, the qemu commands that get run are something like 700 characters long.
Shouldn't be the case. I put my VM args into a script, but it's only like 20 lines?
qemu-system-x86_64 -enable-kvm -name hostname.domain -m 4096 -smp 2 -pidfile /var/run/ganeti/kvm-hypervisor/pid/hostname.domain-device virtio-balloon -daemonize -D /var/log/ganeti/kvm/hostname.domain.com.log -machine pc-i440fx-bionic -monitor unix:/var/run/ganeti/kvm-hypervisor/ctrl/hostname.domain.com.monitor,server,nowait -serial unix:/var/run/ganeti/kvm-hypervisor/ctrl/hostname.domain.com.serial,server,nowait -usb -usbdevicetablet -vnc 127.0.0.1:5156 -chroot /var/run/ganeti/kvm-hypervisor/chroot/hostname.domain.com -uuid 3d9ea1c9-33ce-4e06-81d3-a97005b89e4b -netdev type=tap,id=nic-19f31fbd-f5de-4b57,fd=9 -device virtio-net-pci,bus=pci.0,id=nic-19f31fbd-f5de-4b57,addr=0xd,netdev=nic-19f31fbd-f5de-4b57,mac=aa:00:00:XX:XX:XX -netdev type=tap,id=nic-0e7f0c3a-e19b-4ae2,fd=12 -device virtio-net-pci,bus=pci.0,id=nic-0e7f0c3a-e19b-4ae2,addr=0xe,netdev=nic-0e7f0c3a-e19b-4ae2,mac=aa:00:00:XX:XX:XX -qmp unix:/var/run/ganeti/kvm-hypervisor/ctrl/hostname.domain.com.qmp,server,nowait -qmp unix:/var/run/ganeti/kvm-hypervisor/ctrl/hostname.domain.com.kvmd,server,nowait -bootc -device virtio-blk-pci,bus=pci.0,id=disk-066d688d-9f5a-4ca5,addr=0xc,drive=disk-066d688d-9f5a-4ca5 -drivefile=/var/run/ganeti/instance-disks/hostname.domain.com:0,format=raw,if=none,id=disk-066d688d-9f5a-4ca5 -S -runas kvm37
In production you probably want the host-vm and vm-vm confinement provided by svirt https://libvirt.org/drvqemu.html#driver-security-architectur...
virtualbox hacked bridge-mode and made it working well all the time, with libvirt/qemu/kvm you will need write a lot of scripts and click around to set this up.
This is the sole reason I had to stick with virtualbox these years.
- Simple OpenGL accelerated guest graphics (alternatives: intel gvt-g, card passthrough, virgl in qemu (not generally available), SPICE+qxl in qemu (not nearly as performant))
- bridged networking "just works"
- open-vm-tools enable quite an interesting array of comfortable guest integration
- disk image format can be handled by qemu-img for conversion purposes, so it's easy to migrate vmware <> virtualbox <> qemu+kvm.
The graphics part is why for desktop VMs, I prefer the vmware solution at the moment.
1. https://wiki.archlinux.org/index.php/QEMU#Network_sharing_be...
2. https://wiki.archlinux.org/index.php/Network_bridge#Wireless...
3. https://wiki.debian.org/BridgeNetworkConnections#Bridging_wi...
Another small thing but big quality of life improvement is exporting LIBVIRT_DEFAULT_URI='qemu:///system', so that everything you execute uses the correct connection.
On debian add backports then it's as simple as "apt-get install cockpit-machines" then point your browser to http://localhost:9090
It makes my firewall pop up constantly.
Example? For Networking, you probably want the virtio driver for maximum throughput if it is supported on the guest (even Windows has drivers now), using the emulated realtek device/e1000 is very slow. That means you should probably also use the virtio block devices, right? Nope, wrong, work on that was abandoned years ago, use SATA!
However, I am not an expert and would love to learn more. Intuitively though I wouldn't expect emulated SATA to be better than paravirt of any kind.
- using Vagrant with the Libvirt plugin. Then there's vagrant-mutate for converting Virtualbox boxes to KVM images.
- VM snapshots with virsh