Gentoo 虚拟化

硬件

大多数现代计算机架构都包括对硬件级别虚拟化的支持:

  • AMD 的 AMD-V (svm): grep --color -E "svm" /proc/cpuinfo

  • Intel 的 Vt-x (vmx): grep --color -E "vmx" /proc/cpuinfo

虚拟化扩展必须受处理器支持并在系统固件(通常是主板的固件菜单)中启用,以便可由 Guest 操作系统访问

软件

Kernel

to be continue…

USE flags

QEMU

Libvirt虚拟机管理器

备注

If policykit USE flag is not enabled for libvirt package, the libvirt group will not be created when app-emulation/libvirt is emerged. If this is the case, another group, such as wheel must be used for unix_sock_group.

virt-manager

/etc/portage/package.use/virtual
net-dns/dnsmasq script
net-libs/gnutls tools pkcs11

# virt-manager
app-emulation/virt-manager gui
net-misc/spice-gtk usbredir
sys-apps/dbus X

# qemu: enable the usbredir and spice USE flags on the qemu package for virt-manager
app-emulation/qemu usbredir spice

# libvirt: policykit USE flag , libvirt group will created
app-emulation/libvirt policykit

安装

安装
emerge --ask app-emulation/libvirt app-emulation/qemu app-emulation/virt-manager

安装了netcat 出现 virt-manager 但由于包被阻止而失败:

virt-manager 但由于包被阻止而失败
[blocks B      ] net-analyzer/netcat ("net-analyzer/netcat" is soft blocking net-analyzer/openbsd-netcat-1.219_p1)

emerge virt-manager failed with block package (Solved) : 删除 netcat

删除 netcat
emerge -acv net-analyzer/netcat

启动

  • 用户添加到libvirt组:

用户添加到libvirt组
usermod -a -G libvirt huatai

从 libvirtd 配置文件中取消注释以下行:

/etc/libvirt/libvirtd.conf
auth_unix_ro = "none"
auth_unix_rw = "none"
unix_sock_group = "libvirt"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
  • Virt-manager 使用 libvirt 作为管理虚拟机的后端: 需要启动 libvirt 守护进程

Refer