Skip to content

CentOS 7安装qemu[未成功]

查看是否支持虚拟化:

bash
egrep -o '(vmx|svm)' /proc/cpuinfo
# 输出很多vmx即可认为支持

安装qemu和virt系列软件包:

bash
yum groupinstall "Virtualization Host"
bash
yum install qemu-kvm qemu-img virt-manager libvirt virt-install virt-viewer

配置libvirtd服务:

bash
# 配置开机启动
systemctl enable libvirtd
# 启动libvirtd
systemctl start libvirtd
# 查看启动状态
systemctl status libvirtd

安装KVM / QEMU虚拟机的命令行客户端:

bash
yum install virt-install

创建虚拟机

创建虚拟机硬盘:

bash
mkdir -p /root/qemu
qemu-img create -f qcow2 /root/qemu/ky10.qcow2 40G

安装虚拟机:

bash
virt-install -n ky10 --memory 8192 --arch armv7 --vcpus 8 \
     --disk /root/qemu/ky10.qcow2,device=disk,bus=virtio \
     --os-type generic \
     --boot /root/kylin/QEMU_EFI.fd \
     --graphics vnc,port=5999 \
     --noreboot \
     --cdrom /root/kylin/Kylin-Server-10-SP2-Release-Build09-20210524-arm64.iso

报错:ERROR 主机不支持 任意虚拟化选项 架构 'aarch64'

CentOS编译qemu 8.0.4

没编成功。

安装gcc 11:

bash
yum install centos-release-scl devtoolset-11-gcc-c+ -y

# 写入~/.bashrc末尾以持久生效
source /opt/rh/devtoolset-11/enable

安装ninja:https://github.com/ninja-build/ninja/releases

安装pixman:https://www.cairographics.org/releases/ (configure、make、make install)

下载qemu-8.0.4:https://download.qemu.org/qemu-8.0.4.tar.xz

bash
tar xvJf qemu-8.0.4.tar.xz

装依赖:

bash
yum install glib2 glib2-devel python3 zlib-devel pixman-devel librbd1-devel librados2-devel -y

编译:

./configure --target-list=arm-softmmu,aarch64-softmmu --enable-kvm --enable-rbd --enable-vnc --prefix=/usr/local
# 会报错,很不好解决