kvm的nested嵌套

关键点是
[color=red][b]modprobe kvm_intel nested=1[/b]
使用qemu的时候 cpu透传设置 -cpu host
或者libvert的virsh命令的xml设置
<cpu mode='host-passthrough'></cpu>
[/color]
###############################
kvm嵌套是只相同cpu的嵌套,64位编程32位的不行

在kvm启动的vm上启动kvm建立vm的vm

在没有vm启动的情况下操作
lsmod|grep kvm
如果什么都没有说明没有加载kvm模块
cat /sys/module/kvm_intel/parameters/nested
No such file or directory

不加nest启动内核模块


modprobe kvm
modprobe kvm_intel


cat /sys/module/kvm_intel/parameters/nested
N

nested并没有打开

[b]设置内核模块的nest[/b]

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


[code="java"]#
lsmod|grep kvm
kvm_intel 162153 0
kvm 525409 1 kvm_intel
#
[/code]


##############################
附录:
完整的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>

virsh start jslinux
启动的mv里面也可以使用kvm
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值