• virsh — This[1] is libvirt's shell interface; and gives you access to the rich set of libvirt APIs.
• virt-builder — Use this for rapidly building minimal or customized virtual machines; it's greatly flexible; check out its man page[2]. And here's[3] a quick example that connects both virt-builder and virsh together.
• virt-install — Use this if you don't like the default build of the template images from virt-builder; it lets you create "headless" servers via 'kickstart' and Linux OS trees from the command-line.
• guestfish and libguestfs suite[4] — This rich set of tools help you in a variety of use-cases: repairing your broken disk images, editing, cloning, debugging disk images, and more. It has saved my behind a lot of times.
• qemu-img[5] – This Swiss Army knife lets you powerfully manipulate disk images (QCOW2, raw, et al) offline. Example operations include: create images, backing chains, offline snapshots, disk image merging, ability to convert disk images from one format to another, and more.
[1] https://libvirt.org/manpages/virsh.html
[2] https://libguestfs.org/virt-builder.1.html
[3] https://developer.fedoraproject.org/tools/virt-builder/about...
[5] https://qemu.readthedocs.io/en/latest/tools/qemu-img.html
Terraform is dog slow sometimes due to cloud provisioning. Would be nice to just be able to build the VM locally then push the AMI/VHD into AWS or Azure.
$ virt-builder fedora-33
[ 1.5] Downloading: http://builder.libguestfs.org/fedora-33.xz
[ 2.3] Planning how to build this image
[ 2.3] Uncompressing
[ 8.6] Opening the new disk
[ 13.8] Setting a random seed
[ 13.8] Setting passwords
virt-builder: Setting random password of root to mZbPJw9d1ZHgowBk
[ 14.8] Finishing off
Output file: fedora-33.img
Output size: 6.0G
Output format: raw
Total usable space: 6.0G
Free space: 4.7G (79%)
By the way, interesting virt-builder factoid: It uses a STRIPS-based planner to optimize the order of steps when building the image, so it doesn't waste time doing multiple copies.
https://en.wikipedia.org/wiki/Stanford_Research_Institute_Pr...
https://github.com/rwmjones/guestfs-tools/blob/0cffcbb7848af...
https://github.com/libguestfs/libguestfs-common/blob/74bc5c5...
https://github.com/libguestfs/libguestfs-common/blob/74bc5c5... $ virt-builder fedora-32 --size 10G --format qcow2
Then the (xz-compressed) template Fedora 32 image will be cached under ~/.cache/virt-builder. So your subsequent Fedora 32 image provisioning will be much faster.You might want to give it a whirl and see if it satisfies your needs; `virt-builder` should be available on most major Linux distributions.
https://drewdevault.com/2018/09/10/Getting-started-with-qemu...
I stopped bothering with libvirt and other frontends for local dev environments. Now I use shell scripts to start my VMs. I only create one per month or two so it isn't that much of a hassle.
I also have just a few 20 line scripts to run my VMs, and that's all. Works with no changes/hassle for 5 years already or more. No extra SW to learn. Man qemu gives me all the answers. Easy.
I guess if you want to manage some complicated setup and dynamically add/remove disks, network cards, or whatever, all the time, migrate machines, etc., some solution like virsh would be good, but for having everything on one bridge, in one subnet, to run some throwaway VM with Windows/browsers for web testing, the simpler setup is so nice.
If your want high level networking stuff, use virsh or virt-manager GUI. Or maybe proxmox if you want a whole distribution for it.
Larger virtualization installations will already have a management layer, something like oVirt or vSphere, that has similar tools available.
I wrote a script that pulled some info from a sourced-in bash "config file" for a given VM (such as amount of CPUs, RAM, and where the disks were), executed the appropriate ip commands to create the taps needed for network access (including a private inter-VM network), and then built/ran the long QEMU command with it in a screen session.
Which file is the ISO for the virtual CD ROM is just another QEMU command line parameter.
I had my own bind running in a VM and created a view on the same subnet as the private VM network. Since this was only a few VMs I didn't bother with DHCP, I just statically assigned IPv4s. I used VNC to setup the OS in them.
https://www.packer.io/docs/builders/qemu
https://github.com/dmacvicar/terraform-provider-libvirt
https://blog.ruanbekker.com/blog/2020/10/08/using-the-libvir...
I include the blog link because there is some nuance in how to get the path right for community Terraform providers that aren't in the Hashicorp registry. The documentation on the GitHub project isn't quite up to date with respect to how the latest versions of Terraform expect the plugin paths to be set up.
I've done this pretty successfully with all the major Linux distros minus Arch, which requires some bootstrapping to get an iso that Packer can work with (no such thing as an answers file for Arch). It's not that big a deal, though. Just find some instructions on how to create and mount a cloud-init iso in addition to the installer iso and use that to add an ssh public key so you can script the installation steps externally. I actually think Packer can do this, but I just haven't gotten it to work yet and have relied on shell scripts.
Hyper-V actually has a very comprehensive PowerShell module that is pretty well documented, by the way: https://docs.microsoft.com/en-us/powershell/module/hyper-v/?.... I've found it pretty easy to use and actually got the Arch auto-provision working on Hyper-V in Windows before I got it working in KVM in Linux.
Another thing is you can just use the cloud images and cloud-init for bootstrapping everything pretty easily, even on-prem. cloud-init has a "no cloud" config option, as mentioned above, where you just mount an iso with the config data as a DVD drive and cloud-init will find it automatically when the distro iso boots.
This guy has a pretty comprehensive example of how to set up a kubernetes homelab entirely using the libvirt Terraform provider from Ubuntu cloud images bootstrapped with cloud-init: https://github.com/zloeber/k8s-lab-terraform-libvirt
I use Hyper-v for years and I rarely create new VMs, this is why I use GUI, it is convenient if you don't do this often enough to remember the syntax and params. Most people that I know are in the same boat, but for mass deployments or automated deployments PowerShell is the way to go.
Is there good CLI tooling available for virtualization? I would say that I'm looking for the "on-prem" experience where I start by configuring a virtual network, download some unmodified ISOs directly from the operating system vendor, provision my headless virtual machines with a combination of Powershell, Answer files, Bash and Kickstart. I then provide services like DHCP and DNS using my virtual machines rather than the built-in mechanism provided by the virtualization tooling.