[qemu][kvm] 在一个vmware虚拟机里安装qemu-kvm虚拟机

时间:2023-03-10 07:00:25
[qemu][kvm] 在一个vmware虚拟机里安装qemu-kvm虚拟机

说起来这个需求,简直是傻傻的。但却实实在在的摆在我的面前。。。。

VM无外乎就是为了模拟场景:我现在要的场景就是一台很多个core的linux主机。但是我只有一个装了windows的笔记本。上边有一个VMware,而VMware又不能模拟超过hostCPU个数的guestCPU数。

所以,用KVM在VMware里模拟一下。

CentOS 安装 qemu:

[root@D128 VM]# yum install qemu qemu-kvm

首先,默认情况下,vmware没有开启虚拟化支持。在guest里运行kvm会报错:

[root@D128 j]# ./start.sh 

(process:): GLib-WARNING **: gmem.c:: custom memory allocation vtable not supported
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory

可以在VMware的软件外部设置里,开启虚拟化支持,如图:

[qemu][kvm] 在一个vmware虚拟机里安装qemu-kvm虚拟机

最后,晒一下我的启动脚本:

[root@D128 j]# cat start.sh
qemu-system-x86_64 -enable-kvm \
-m 2G \
-cpu Nehalem -smp cores=,threads=,sockets= \
-numa node,mem=1G,cpus=-,nodeid= \
-numa node,mem=1G,cpus=-,nodeid= \
-display vnc=0.0.0.0: \
-net nic,vlan=,model=virtio,macaddr='00:00:00:01:00:01' \
-net nic,vlan=,model=virtio,macaddr='00:00:00:01:00:02' \
-net tap,vlan=,ifname=tap-,script=no,downscript=no \
-net tap,vlan=,ifname=tap-,script=no,downscript=no \
-drive file=disk.img,if=virtio \
& ip link set tap- up
brctl addif br0 tap- #-device vfio-pci,host='0000:00:19.0' \
# -cdrom /root/CentOS--x86_64-DVD-.iso \
# -boot order=d