首先使用 grep --color -E "vmx|svm" /proc/cpuinfo 检查 cpu 能不能支持虚拟化,注意 biso 里面要开启虚拟化。
内核开启相应选项
[*] Virtualization --->
<*> Kernel-based Virtual Machine (KVM) support
[*] Virtualization --->
<M> KVM for Intel processors support
[*] Virtualization --->
<M> KVM for AMD processors support
[*] Virtualization --->
<*> Host kernel accelerator for virtio net
Device Drivers --->
[*] Network device support --->
[*] Network core driver support
<*> Universal TUN/TAP device driver support
[*] Networking support --->
Networking options --->
<*> The IPv6 protocol
<*> 802.1d Ethernet Bridging
Kernel hacking --->
Compile-time checks and compiler options --->
[*] Debug Filesystem
File systems --->
<*> The Extended 4 (ext4) filesystem
[*] Ext4 Security Labels
然后根据需要 qemu 使用的客户端,修改 make.conf
QEMU_SOFTMMU_TARGETS="arm x86_64 i386"
QEMU_USER_TARGETS="x86_64 arm armeb i386"
增加 qemu 的 USE : accessibility gtk ncurses python sdl spice usbredir
然后安装 qemu: emerge --ask app-emulation/qemu
加入 kvm组: gpasswd -a kvm
安装 virt-manager: emerge -v virt-manager,注意开启 USE: gtk
配置让普通用户使用 qemu:
groupadd libvirt
usermod -a -G libvirt
vim /etc/libvirt/libvirtd.conf
unix_sock_group = "libvirt"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
退出重新登录后,rc-service libvirtd restart 重启服务.