Debian

Debian has different instructions for different Debian stable images. You should always follow their main documentation here: https://wiki.debian.org/KVM

Debian Stretch 9

Install the Packages

For Debian 9, the instruction to install the QEMU and KVM are:

$ sudo apt install qemu-kvm libvirt-clients qemu-utils libvirt-daemon-system msr-tools samba

This is for installing the packages, kvm modules, and libvirt client command line utilities.


Add User to Libvirt User Group

By default, the qemu has a special user group for managing the virtual machine. Hence, you'll need to add yourself into that user group.

$ sudo adduser $USER libvirt
$ sudo adduser $USER libvirt-qemu


Auto-start the Network

By default, QEMU network is disabled. You need to mark it to "enable with auto-start".

$ sudo virsh net-autostart default


Add QEMU URI to bashrc

To use QEMU and libvirt without root, you need is to export the LIBVIRT_DEFAULT_URI variable into your $HOME/.bashrc.

$ export LIBVIRT_DEFAULT_URI=qemu:///system

This way, when virsh picks up the environment variable, it knows which qemu URI to interface with.


Restart

Restart your system. Although you can logout then login to make things work but there are plenty of things requires configurations under the hood.


Check Intel VT-x or AMD AMD-V Enabling

Once you login into your system, be sure to check whether the VT-x / AMD-V is activated. You can do this in an ad-hoc manner by:

1. Load the module

$ sudo modprobe msr

2. Then, check the return bits

$ sudo rdmsr 0x3a
5

A return value of 3 or 5 means the hardware virtualization is activated.


Setup Samba File Sharing System

Unfortunately, sharing file system as a drive into the Guest is still under development using 9p channel. For now, the most effective way is to setup internal Samba (host to guest). Here is the full guide for Samba setup.

That's all about it.