A suckless QEMU wrapper written in shell
Find a file
2024-05-06 09:53:57 +02:00
bin qemush : version 1.0.0 ! 2024-05-06 09:53:57 +02:00
etc/sudoers.d Suppression : service runit virtiofsd 2024-03-26 10:01:15 +01:00
qemu launchers/kvm : manière plus portable de récupérer la mémoire libre 2024-04-17 11:29:09 +02:00
LICENSE.txt LICENSE : GPL -> MIT 2024-03-13 09:42:00 +01:00
Makefile Makefile : oups 2024-04-17 11:28:56 +02:00
README.md README : suppression de deux mentions inutiles dans les dépendances 2024-03-31 16:46:23 +02:00

qemush - A suckless QEMU wrapper written in shell

Please don't upload to GitHub

How does it work

qemush allows to run commands as Unix user qemu to manage virtual machines and their disks associated.

Why

qemush is daemonless: no bloaty long running process is needed for qemush to work.

qemush is lightweight: it only consists in a shell script to automate repeated tasks and force good practices.

qemush needs few dependencies: see section Dependencies for details.

qemush is hackable: you can write your own launching scripts to make it work as intended.

qemush is easy to setup: you can make it work in a few steps, see section Installation instructions.

Good practices?

Here is a list of good practices forced by qemush.

  • Processes running as user qemu: members of group qemu can manage the same virtual machines
  • Modularization: qemush launching scripts are intended to be stackable to reuse common qemu parameters in all virtual machines needing them keep track of them
  • Copy-on-write: images are formatted using qcow2 to use less space on disk
  • Process detachment: you can log out and have your virtual machines still running, control them via Unix sockets

Is it better than libvirt ?

No. qemush and libvirt are for different use cases. qemush will allow you to spin up virtual machines really fast and with as little setup as possible, and aims to be nothing more than a QEMU wrapper, while libvirt will offer better out-of-the-box experience, with already existing pre-configurations, associated tools like the virt-manager GUI and a friendlier process supervision. You should use qemush if you care about controlling every aspect of your virtual machines, and are already used to using bare QEMU without an abstraction layer.

Dependencies

From version 0.9.0, qemush is written in pure POSIX shell! The previous dependency on bash was removed in consequence.

All dependencies are common packages for a distribution, you'll be able to grab them from your favorite packages sources.

  • qemu - this is literally a QEMU wrapper so there's a chance you'll need it
  • coreutils - used for basic OS operations
  • sudo - execute commands as qemu
  • socat - monitor machines via Unix sockets

Installation instructions

QEMU user and group

qemush acts as Unix user qemu to manage virtual machines. You need to create a system user qemu that cannot login, with any home directory, in an Unix group of the same name. Example:

# Example if the qemu user doesn't exist
# Make sure /etc/shells contains /bin/nologin
useradd -r -s /bin/nologin qemu

For ease of use, you need to grant every user in the qemu group via sudo the right to execute commands as qemu. You can find an example sudoers rule in this repo's etc/sudoers.d folder.

Just run the following command at the root of this repository to install qemush (previous step is mandatory) :

make

And what if I don't want to bindly run this obscure Makefile ???

You'd be right. The next section is the exhaustive list of steps handled by the Makefile for the installation process.

Manual installation (what does the Makefile do)

  • Create disks, launchers, shared, sockets/monitors, socket/spice and bin directories in ~qemu
  • Copy qemush scripts parts from qemu/bin in ~qemu/bin with mode 740
  • Compile C programs from src in ~qemu/bin with mode 740
  • Copy the default launching scripts to ~qemu/launchers with mode 740 ; this is optional but the one called kvm is the reference qemush launching script!
  • Copy bin/qemush to /usr/local/bin/qemush with mode 755

Usage

Writing a launching script

The default text editor used by qemush is vi, but it can be overriden by the EDITOR environment variable.

Run the following command to start editing a launching script by the name of your choice:

qemush edit "$name"

Example scripts are available in this repo's qemu/launchers folder.

Launching a virtual machine

Virtual machines are identified by the name of their launching scripts. You can launch any machine with the following command:

qemush start "$name"

You can also list all available virtual machines by running this command:

qemush ls

Other uses

You can show the full list of possible actions by running this command:

qemush help