說起來這個需求,簡直是傻傻的。但卻實實在在的擺在我的面前。。。。
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:2651): GLib-WARNING **: gmem.c:483: 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的軟件外部設置里,開啟虛擬化支持,如圖:

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