在Ubuntu 18.04上使用gnome boxes

gnome boxes是一个QEMU-KVM虚拟化的前端。由于一些依赖问题,在Ubuntu 18.04上使用此程序需要一些额外步骤。

$ sudo apt -y install gnome-boxes --install-recommends

安装gnome-boxes后,运行它会报出类似"无法访问虚拟化后端"的错误,可以创建虚拟机但无法运行。经如下步骤后可修复。

// 安装并配置所需要的依赖
$ sudo apt install qemu-kvm libvirt-bin libvirt-clients
$ sudo echo 'group=kvm' >> /etc/modprobe.d/qemu-system-x86.conf 
$ sudo adduser $USER kvm
// 解决box storage pool的权限问题
$ sudo chown -R $USER /home/$USER/.local/share/gnome-boxes/images/
// 重启
$ sudo reboot

重启后,尽管gnome-boxes --checks的输出仍有报错,但创建并运行虚拟机不会出问题。

$ gnome-boxes --checks

(gnome-boxes:24806): Boxes-WARNING **: 17:24:23.381: util-app.vala:250: Failed to execute child process ?restorecon? (No such file or directory)
• The CPU is capable of virtualization: yes
• The KVM module is loaded: yes
• Libvirt KVM guest available: yes
• Boxes storage pool available: no
    Could not get “gnome-boxes” storage pool information from libvirt. Make sure “virsh -c qemu:///session pool-dumpxml gnome-boxes” is working.
• The SELinux context is default: no

Report bugs to <https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-boxes>.
Boxes home page: <https://wiki.gnome.org/Apps/Boxes>.

References