KVM虚拟机典型配置文件xml

KVM虚拟机典型配置⽂件xml
<domain type='kvm'>
<name>vm64-1</name> //虚拟机名称
<memory unit='MiB'>2300</memory> //最⼤内存,单位M
<currentMemory unit='MiB'>2300</currentMemory> //可⽤内存,单位M
<vcpu>3</vcpu> //虚拟cpu个数
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/> //硬盘启动
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/kvm/images/vm64-1.raw'/> //⽬的镜像路径
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> /*硬盘使⽤virtio驱动识别为pci总线*/
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/kvm/images/ex.img'/> //⽬的镜像路径
<target dev='vdb' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/> /*硬盘使⽤virtio驱动后识别为pci总线*/
</disk>处方药与非处方药分类管理办法
<interface type='bridge'> //虚拟机⽹络连接⽅式
<source bridge='vm1_br_debug'/> //当前主机⽹桥的名称 vm-eth0
<virtualport type='openvswitch'/>
<model type='virtio'/>
<driver name='vhost' queues='8'/>
<mac address="00:16:3E:64:01:00"/> //为虚拟机分配mac地址,务必唯⼀,否则dhcp获得同样ip,引起冲突
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<interface type='bridge'> //虚拟机⽹络连接⽅式
<source bridge='vm1_br_protocol'/> //当前主机⽹桥的名称  vm-eth1
<virtualport type='openvswitch'/>
<model type='virtio'/>
<driver name='vhost' queues='8'/>
<mac address="00:16:3E:64:01:01"/> //为虚拟机分配mac地址,务必唯⼀,否则dhcp获得同样ip,引起冲突
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>//vnc⽅式登录,端⼝号⾃动分配,⾃动加1,可以通过virsh vncdisplay来查询  </devices>
</domain>
范例2河北科技大学学报
<domain type='kvm'>  //如果是Xen,则type=‘xen’
<name>vm0</name> //虚拟机名称,同⼀物理机唯⼀
<uuid>fd3535db-2558-43e9-b067-314f48211343</uuid>  //同⼀物理机唯⼀,可⽤uuidgen⽣成
<memory>524288</memory>
<currentMemory>524288</currentMemory>  //memory这两个值最好设成⼀样
<vcpu>2</vcpu>            //虚拟机可使⽤的cpu个数,查看物理机可⽤CPU个数:cat /proc/cpuinfo |grep processor | wc -l
<os>
<type arch='x86_64' machine='pc-i440fx-vivid'>hvm</type> //arch指出系统架构类型,machine 则是机器类型,查看机器类型:qemu-system-x86_64 -M ?  <boot dev='hd'/>  //启动介质,第⼀次需要装系统可以选择cdrom光盘启动
<bootmenu enable='yes'/>  //表⽰启动按F12进⼊启动菜单
</os>
<features>
<acpi/>  //Advanced Configuration and Power Interface,⾼级配置与电源接⼝
<apic/>  //Advanced Programmable Interrupt Controller,⾼级可编程中断控制器
<pae/>  //Physical Address Extension,物理地址扩展
</features>
<clock offset='localtime'/>  //虚拟机时钟设置,这⾥表⽰本地本机时间
<on_poweroff>destroy</on_poweroff>  //突发事件动作
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>  //设备配置
<emulator>/usr/bin/kvm</emulator> //如果是Xen则是/usr/lib/xen/binqemu-dm
<disk type='file' device='disk'> //硬盘
<driver name='qemu' type='raw'/>
<source file='/opt/vm/vmdev/fdisk.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> //域、总线、槽、功能号,slot值同⼀虚拟机上唯⼀
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/opt/vm/vmdev/fdisk2.img'/>
<target dev='vdb' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>//光盘
<driver name='qemu' type='raw'/>
<source file='/opt/vm/vmiso/ubuntu-15.10-server-amd64.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
/* 利⽤Linux⽹桥连接⽹络 */
<interface type='bridge'>
<mac address='fa:92:01:33:d4:fa'/>
<source bridge='br100'/>  //配置的⽹桥⽹卡名称
<target dev='vnet0'/>    //同⼀⽹桥下相同
<alias name='net0'/>      //别名,同⼀⽹桥下相同
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>  //注意slot值唯⼀
</interface>
天鹅湖音乐赏析/* 利⽤ovs⽹桥连接⽹络 */
<interface type='bridge'>
<source bridge='br-ovs0'/>
<virtualport type='openvswitch'/>
<target dev='tap0'/>
<model type='virtio'/>
</interface>
/
* 配置成pci直通虚拟机连接⽹络,SR-IOV⽹卡的VF场景 */
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</source>
</hostdev>
/* 利⽤vhostuser连接ovs端⼝ */
<interface type='vhostuser'>
<mac address='fa:92:01:33:d4:fa'/>
<source type='unix' path='/var/run/vhost-user/tap0' mode='client'/>
<model type='virtio'/>
<driver vringbuf='2048'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='network'>  //基于虚拟局域⽹的⽹络
<mac address='52:54:4a:e1:1c:84'/>  //可⽤命令⽣成,见下⾯的补充
<source network='default'/> //默认
<target dev='vnet1'/>  //同⼀虚拟局域⽹的值相同
<alias name='net1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>  //注意slot值
</interface>
<graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0' keymap='en-us'/>  //配置vnc,window
s下可以使⽤vncviewer登录,获取vnc端⼝号:virsh vncdisplay vm0  <listen type='address' address='0.0.0.0'/>
</graphics>
</devices>
</domain>
范例3
<domain type='kvm'>
<name>vm64-1</name> //虚拟机名称
<memory unit='MiB'>2300</memory> //最⼤内存,单位M
<currentMemory unit='MiB'>2300</currentMemory> //可⽤内存,单位M
<vcpu>3</vcpu> //虚拟cpu个数
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/> //硬盘启动
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
反侦察<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/kvm/images/vm64-1.raw'/> //⽬的镜像路径
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> /*硬盘使⽤virtio驱动后识别为pci总线*/
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/kvm/images/ex.img'/> //⽬的镜像路径
<target dev='vdb' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/> /*硬盘使⽤virtio驱动后识别为pci总线*/
</disk>
<interface type='bridge'> //虚拟机⽹络连接⽅式
<source bridge='vm1_br_debug'/> //当前主机⽹桥的名称 vm-eth0
<virtualport type='openvswitch'/>
<model type='virtio'/>
<driver name='vhost' queues='8'/>
<mac address="00:16:3E:64:01:00"/> //为虚拟机分配mac地址,务必唯⼀,否则dhcp获得同样ip,引起冲突
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<interface type='bridge'> //虚拟机⽹络连接⽅式
<source bridge='vm1_br_protocol'/> //当前主机⽹桥的名称  vm-eth1
<virtualport type='openvswitch'/>
<model type='virtio'/>
<driver name='vhost' queues='8'/>
<mac address="00:16:3E:64:01:01"/> //为虚拟机分配mac地址,务必唯⼀,否则dhcp获得同样ip,引起冲突
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>//vnc⽅式登录,端⼝号⾃动分配,⾃动加1,可以通过virsh vncdisplay来查询  </devices>
</domain>
<domain type='kvm'>
<name>vm64-1</name> //虚拟机名称
<memory unit='MiB'>2300</memory> //最⼤内存,单位M
<currentMemory unit='MiB'>2300</currentMemory> //可⽤内存,单位M
<vcpu>3</vcpu> //虚拟cpu个数
自由梦幻<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/> //硬盘启动
</os>
人体三维模型
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/kvm/images/vm64-1.raw'/> //⽬的镜像路径
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> /*硬盘使⽤virtio驱动后识别为pci总线*/
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/kvm/images/ex.img'/> //⽬的镜像路径
<target dev='vdb' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/> /*硬盘使⽤virtio驱动后识别为pci总线*/
</disk>
<interface type='bridge'> //虚拟机⽹络连接⽅式
<source bridge='vm1_br_debug'/> //当前主机⽹桥的名称 vm-eth0
<virtualport type='openvswitch'/>
<model type='virtio'/>
<driver name='vhost' queues='8'/>
<mac address="00:16:3E:64:01:00"/> //为虚拟机分配mac地址,务必唯⼀,否则dhcp获得同样ip,引起冲突
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<interface type='bridge'> //虚拟机⽹络连接⽅式
<source bridge='vm1_br_protocol'/> //当前主机⽹桥的名称  vm-eth1
<virtualport type='openvswitch'/>
<model type='virtio'/>
<driver name='vhost' queues='8'/>
<mac address="00:16:3E:64:01:01"/> //为虚拟机分配mac地址,务必唯⼀,否则dhcp获得同样ip,引起冲突
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>//vnc⽅式登录,端⼝号⾃动分配,⾃动加1,可以通过virsh vncdisplay来查询  </devices>
</domain>

本文发布于:2024-09-23 13:23:30,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/104025.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:配置   类型   驱动   识别
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议