Our solution in getting Gnome Boxes to work on Kali Linux (which is a Debian-derived Linux distribution just like Ubuntu) is the following:
First install Gnome Boxes along with all needed virtualization software:
sudo apt-get install -y gnome-boxes qemu-kvm libvirt0 virt-manager bridge-utils;
Then, edit the file /etc/libvirt/qemu.conf
to uncomment the following line:
#user = "root"
Finally, restart the host machine and your Gnome Boxes will be ready to use.
Long story
Recently, we were setting up a Kali Linux machine and one of the requirements was to add virtualization support so that the user could execute virtual machines doing.. other stuff. We started by installing gnome-boxes
only (hoping that would be enough)
sudo apt-get install -y gnome-boxes;
.. but we got an error:
Boxes cannot access the virtualization backend
Apparently, installing gnome-boxes
only, the dependency system did not automatically assume we would need to install an engine to handle the virtual machines, so we had to install the following as well:
sudo apt-get install -y qemu-kvm libvirt0 virt-manager bridge-utils;
After the installation, we tried to create a new virtual machine but it would fail when we tried to start it. After looking into the logs we found the following useful information:
State: GVIR_DOMAIN_STATE_SHUTOFF
It seems that our user (even if it was root) could not start the QEMU
process. To fix this issue we had to modify the file /etc/libvirt/qemu.conf
and uncomment the following line:
#user = "root"
from this section
# The user for QEMU processes run by the system instance. It can be # specified as a user name or as a user id. The qemu driver will try to # parse this value first as a name and then, if the name doesn't exist, # as a user id. # # Since a sequence of digits is a valid user name, a leading plus sign # can be used to ensure that a user id will not be interpreted as a user # name. # # Some examples of valid values are: # # user = "qemu" # A user named "qemu" # user = "+0" # Super user (uid=0) # user = "100" # A user named "100" or a user with uid=100 # #user = "root" # The group for QEMU processes run by the system instance. It can be # specified in a similar way to user. #group = "root"
After doing this change and restarting the host machine we were able to start and use any virtual machine in Gnome Boxes.
Extra information
In this case, we were using Kali Linux, where people usually operate it using the root
account only.
On other installations, like on an Ubuntu
installation you would need to handle differently the last step that requires you to edit the /etc/libvirt/qemu.conf
file.
Specifically, the best way to handle this issue on a multi-user environment (like Ubuntu) would be to replace the following line:
#group = "root"
with this
group = "kvm"
and then add yourself to the kvm
group before restarting the host machine
sudo usermod -a -G kvm $USER;
Doing so, it allows you to enable access to the virtualization services to multiple users of you choice instead of limiting it to one account.
This post is also available in: Greek