kvm的nested嵌套
关键点是
modprobekvm_intelnested=1
使用qemu的时候cpu透传设置-cpuhost
或者libvert的virsh命令的xml设置
<cpumode='host-passthrough'></cpu>
###############################
kvm嵌套是只相同cpu的嵌套,64位编程32位的不行
在kvm启动的vm上启动kvm建立vm的vm
在没有vm启动的情况下操作
lsmod|grepkvm
如果什么都没有说明没有加载kvm模块
cat/sys/module/kvm_intel/parameters/nested
Nosuchfileordirectory
不加nest启动内核模块
modprobe kvm modprobe kvm_intel
cat/sys/module/kvm_intel/parameters/nested
N
nested并没有打开
设置内核模块的nest
rmmod kvm_intel modprobe kvm_intel nested=1 cat /sys/module/kvm_intel/parameters/nested Y
当显示Y的时候才确实设置成功
测试:
libvirt建立vm的时候
配置文件加
<cpu mode='host-passthrough'> </cpu>
透传cpu
建立的vm里面测试使用
/usr/libexec/qemu-kvm已经可以建vm成功
普通的qemu建立vm
/usr/libexec/qemu-kvm -kernel bzImage -drive file=hda.qcow2,if=ide,cache=none -append "console=ttyS0 root=/dev/sda rw rdinit=/sbin/init notsc=1" -boot order=dc,menu=on -net nic,vlan=0,macaddr=52:54:00:12:34:22,model=e1000,addr=08 -net tap,name=haha,ifname=tap1,script=no,downscript=no -vnc 0.0.0.0:1 -monitor stdio
[root@jslinux test_migration]# lsmod|grep kvm kvm_intel 162153 0 kvm 525409 1 kvm_intel [root@jslinux test_migration]#
##############################
附录:
完整的jslinux.xml文件为
<domain type='kvm'> <name>jslinux</name> <uuid>d16d7501-9b0d-f26e-f52a-77a81225242e</uuid> <memory unit='KiB'>33554432</memory> <currentMemory unit='KiB'>33554432</currentMemory> <vcpu placement='static'>16</vcpu> <cpu mode='host-passthrough'> </cpu> <os> <type arch='x86_64' machine='pc'>hvm</type> <boot dev='hd'/> <bootmenu enable='yes'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/home/hao/jslinux.img'/> <target dev='vda' bus='virtio'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/home/CentOS-7-x86_64-DVD-1503-01.iso'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'> <mac address='50:52:11:aa:12:35'/> <source bridge='br0'/> <model type='virtio'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5918' autoport='no' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> <sound model='ich6'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> </domain>
virshstartjslinux
启动的mv里面也可以使用kvm
相关推荐
成长路上 2020-07-29
zhangsyi 2020-07-28
82911234 2020-07-20
leeham 2020-07-05
81550996 2020-06-07
leeham 2020-06-06
82143754 2020-05-31
zhangsyi 2020-05-31
82911234 2020-05-31
hnllei 2020-05-30
82911234 2020-05-27
辛佳雨 2020-05-16
82143754 2020-05-15
81550996 2020-05-12
81550996 2020-04-30
82911234 2020-04-29
82143754 2020-04-29
成长路上 2020-04-23