libvirt xml 模板

<domain type='kvm'>
    <name>node-br0</name> //虚拟机名称
    <memory unit='GiB'>2</memory> //最大内存,单位M
    <currentMemory unit='GiB'>2</currentMemory> //可用内存,单位M
    <vcpu>2</vcpu> //虚拟cpu个数
    <os>
        <type arch='x86_64' machine='pc'>hvm</type>
        <boot dev='cdrom'/> //ISO文件启动
    </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/bin/qemu-system-x86_64</emulator> //KVM启动程序,ubuntu版本
        <disk type='file' device='disk'>
            <driver name='qemu' type='qcow2'/>
            <source file='/home/prj1/ubuntu2.qcow2'/> //目的镜像路径
            <target dev='sda' bus='scsi'/>
            <address type='drive' controller='0' bus='0' target='0' unit='0'/> //硬盘使用virtio-scsi驱动,模拟scsi硬盘,建议使用
        </disk>
        <controller type='scsi' index='0' model='virtio-scsi'/> //使用virtio-scsi配置,必须
        <disk type='file' device='cdrom'>
            <driver name='qemu' type='raw'/>
	    <source file='/root/vm_prj1/ubuntu.iso'/>
            <target dev='hda' bus='ide'/>
            <readonly/>
            <address type='drive' controller='0' bus='1' target='0' unit='0'/>
        </disk>
        <interface type='bridge'> 
	    <source bridge='br0'/>
            <model type='virtio'/>
            <mac address='00:17:3E:64:01:00'/> //为虚拟机分配mac地址,务必唯一,否则dhcp获得同样ip,引起冲突
            <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> 
        </interface>
        <input type='mouse' bus='ps2'/>
        <graphics type='vnc' port='5900' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>//vnc方式登录,端口号自动分配,自动加1,可以通过virsh vncdisplay来查询
        <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='0x05' function='0x0'/>
        </memballoon>
        <serial type='pty'>
            <target port='0'/>
        </serial>
        <console type='pty'>
            <target type='serial' port='0'/>
        </console>
    </devices>
</domain>
``

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值