HOO八卦
妖魔鬼怪快离开

Proxmox VE支持嵌套虚拟化

  1. cat /sys/module/kvm_intel/parameters/nested
  2. N

可见默认状态下是未开启的,下面让我们来打开嵌套虚拟化,首先需要关闭所有虚拟机

列出所有虚拟机:

  1. qm list

关闭虚拟机:

  1. qm stop <vmid>
以上操作也可以在PVE网页控制台操作

开启内核支持:

  1. modprobe r kvm_intel
  2. modprobe kvm_intel nested=1
执行modprobe -r kvm_intel时如果报错Module kvm_intel is in use,请检查你的虚拟机是否全部关闭

现在再看看nested是否已开启:

  1. cat /sys/module/kvm_intel/parameters/nested
  2. Y
编辑配置文件:
  1. echo “options kvm_intel nested=1” >> /etc/modprobe.d/modprobe.conf
这样系统重启也会自动加载netsted

查看虚拟机启动命令行,下面以我的环境中vmid为100的虚拟机为列:

  1. # qm showcmd 100
  2. /usr/bin/kvm id 100 chardev socket,id=qmp,path=/var/run/qemuserver/100.qmp,server,nowait mon chardev=qmp,mode=control pidfile /var/run/qemuserver/100.pid daemonize smbios type=1,uuid=a1f4fefc3d1441c7aeb1bf9b79ef03df name opstest172.16.30.20 smp 2,sockets=1,cores=2,maxcpus=2 nodefaults boot menu=on,strict=on,reboottimeout=1000,splash=/usr/share/qemuserver/bootsplash.jpg vga cirrus vnc unix:/var/run/qemuserver/100.vnc,x509,password cpu kvm64,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce m 4096 k enus device pcibridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e device pcibridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f device piix3usbuhci,id=uhci,bus=pci.0,addr=0x1.0x2 device usbtablet,id=tablet,bus=uhci.0,port=1 device virtioballoonpci,id=balloon0,bus=pci.0,addr=0x3 iscsi initiatorname=iqn.199308.org.debian:01:6775cf970ba drive file=/var/lib/vz/template/iso/CentOS7x86_64DVD1611.iso,if=none,id=driveide2,media=cdrom,aio=threads device idecd,bus=ide.1,unit=0,drive=driveide2,id=ide2,bootindex=200 device virtioscsipci,id=scsihw0,bus=pci.0,addr=0x5 drive file=/dev/pve/vm100disk1,if=none,id=drivescsi0,format=raw,cache=none,aio=native,detectzeroes=on device scsihd,bus=scsihw0.0,channel=0,scsiid=0,lun=0,drive=drivescsi0,id=scsi0,bootindex=100 netdev type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemuserver/pvebridge,downscript=/var/lib/qemuserver/pvebridgedown,vhost=on device virtionetpci,mac=D2:15:25:81:73:BD,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300
找到-cpu kvm64,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce

在后面加上+vmx,表示开启vmx

-cpu kvm64,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,+vmx,enforce

关闭虚拟机:

  1. qm stop 100
重新启动虚拟机:
  1. /usr/bin/kvm id 100 chardev socket,id=qmp,path=/var/run/qemuserver/100.qmp,server,nowait mon chardev=qmp,mode=control pidfile /var/run/qemuserver/100.pid daemonize smbios type=1,uuid=a1f4fefc3d1441c7aeb1bf9b79ef03df name opstest172.16.30.20 smp 2,sockets=1,cores=2,maxcpus=2 nodefaults boot menu=on,strict=on,reboottimeout=1000,splash=/usr/share/qemuserver/bootsplash.jpg vga cirrus vnc unix:/var/run/qemuserver/100.vnc,x509,password cpu kvm64,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,+vmx,enforce m 4096 k enus device pcibridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e device pcibridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f device piix3usbuhci,id=uhci,bus=pci.0,addr=0x1.0x2 device usbtablet,id=tablet,bus=uhci.0,port=1 device virtioballoonpci,id=balloon0,bus=pci.0,addr=0x3 iscsi initiatorname=iqn.199308.org.debian:01:6775cf970ba drive file=/var/lib/vz/template/iso/CentOS7x86_64DVD1611.iso,if=none,id=driveide2,media=cdrom,aio=threads device idecd,bus=ide.1,unit=0,drive=driveide2,id=ide2,bootindex=200 device virtioscsipci,id=scsihw0,bus=pci.0,addr=0x5 drive file=/dev/pve/vm100disk1,if=none,id=drivescsi0,format=raw,cache=none,aio=native,detectzeroes=on device scsihd,bus=scsihw0.0,channel=0,scsiid=0,lun=0,drive=drivescsi0,id=scsi0,bootindex=100 netdev type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemuserver/pvebridge,downscript=/var/lib/qemuserver/pvebridgedown,vhost=on device virtionetpci,mac=D2:15:25:81:73:BD,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300
列出虚拟机:
  1. qm list
发现vmid为100的虚拟机状态已变更为running

进入该虚拟机,使用命令验证是否已开启vmx:

  1. #egrep “vmx|svm” /proc/cpuinfo
  2. flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl pni vmx cx16 x2apic hypervisor lahf_lm tpr_shadow vnmi flexpriority ept vpid
  3. flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl pni vmx cx16 x2apic hypervisor lahf_lm tpr_shadow vnmi flexpriority ept vpid
至此,成功在PVE中开启了嵌套虚拟化
https://blog.wxhbts.com/proxmox-ve%e6%94%af%e6%8c%81%e5%b5%8c%e5%a5%97%e8%99%9a%e6%8b%9f%e5%8c%96.html
赞(0)
未经允许不得转载:HOO八卦 » Proxmox VE支持嵌套虚拟化
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

Find More Interest

Contactsthrough