Qemu Script

This will be updated...

Summary

Using Qemu from the command line can be a real pain. It either requires very long commands or maintaining many different scripts. Normally people just use something like libvirt or another set of programs to make it easier. I like doing things the hard way. I prefer minimizing the amount of programs running in general and especially on a dedicated machine hosting my VMs. This Qemu Script helps do that.

QS is a work in progress. It's at a state where it is very usable, but not well documented. It also requires manually copying files to install. That was on purpose since it's possible you might blow away your NFTables firewall if you weren't paying attention. In the future I plan to make a debian package for ease of use.

Download and Install

QS is available on GitHub at https://github.com/Hack-Char/qs

Overview

Qemu Script (QS) has a main Bash script /usr/bin/qs used to start, stop and interact with your virtual machines. It also tightly interacts with NFTables to allow virtual machines access to each other and/or the Internet. There are a couple other scripts that can be used as examples to pass virtual-IO PCI devices to your vm - for example /usr/sbin/qs-wifi-before.sh which will connect my wifi and ethernet devices directly to the vm.

Virtual machines are defined by a storage file as well as characteristics such as the number of CPUs, amount of memory, etc. VMware solutions rely on OVA (Open Virtual Machine Archive) and OVF (Open Virtual Machine File). The OVF defines characteristics and is tar'd into an OVA along with the VMDK (Virtual Machine Disk). For QS, the storage is either a qcow2 or raw file and the characteristics are defined in a file located in ${HOME}/.qs or /etc/qs. An example of such a file is:

vm debian
        cores 2
        mem 4
        image /var/vm/debian.qcow2
        internet 192.168.100.1

To use this example VM, it would be started with qs up debian, the memory and cpu usage can be checked with qs info and if required you can issue an ACPI power down (similar to pushing your power button) using qs down 1 (where 1 is the index of the VM reported by qs info).

Creating a VM

  1. Create the disk storage using qemu-img
  2. Create the description, for example in ${HOME}/.qs/newvm
  3. Run the install ISO using qs up newvm bootonce /var/iso/debian-install.iso

In the future you can just run qs up newvm to boot after the ISO installed.

Basic VM interaction

TO DO

Using alt-f1 and other send-key type messages. Introduce using TCP ports for interacting with the VM. Mention integration into pass password manager.

Configuring for Virtual IO

TO DO

Explain how to find your virt-io groups and the process to figure out which modules need to be unloaded before reassigning to your VM.

More things to explain

TO DO

Explain qemu group, sudo, auto-boot VM, ARCHITECTURE: nftables, bridge/tap, masquerade