• kvm 虚拟机XML文件


    <domain type='kvm' id='29'>
    //domain 是一个所有虚拟机都需要的根元素,它有两个属性,
    //type定义使用哪个虚拟机管理程序,值可以是:xen、kvm、qemu、lxc、kqemu,
    //第二个参数是id,它唯一的标示一个运行的虚拟机,不活跃的客户端没有id。
      <name>i-000039</name>
    //name参数为虚拟机定义了一个简短的名字,必须唯一。
    
      <uuid>d59b03ce-2e78-4d35-b731-09d9ca9653af</uuid>
    //uid为虚拟机定义了一个全球唯一的标示符,uuid的格式必须遵循RFC 4122指定的格式,当创建虚拟机没有指定uuid时会随机的生成一个uuid。
    
      <memory unit='KiB'>4194304</memory>
      <currentMemory unit='KiB'>4194304</currentMemory>
      <memtune>
        <hard_limit unit='KiB'>4194304</hard_limit>
      </memtune>
        //memory 定义客户端启动时可以分配到的最大内存,内存单位由unit定义,单位可以是:K、KiB、M、MiB、G、GiB、T、TiB。默认是KiB。
      
      
      <vcpu placement='static'>1</vcpu>
      //vcpu的内容是为虚拟机最多分配几个cpu,值处于1~maxcpu之间,可选参数:cpuset参数指定虚拟cpu可以映射到那些物理cpu上,物理 cpu用逗号分开,单个数字的标示单个cpu,
      //也可以用range符号标示多个cpu,数字前面的脱字符标示排除这个cpu,current参数指定虚拟 机最少,placement参数指定一个domain的cpu的分配模式,值可以是static、auto。
      
      
      <cputune>
        <shares>1024</shares>
        <period>100000</period>
        <quota>-1</quota>
      </cputune>
      <resource>
        <partition>/machine</partition>
      </resource>
      
      
     //操作系统启动介绍
      <os>
        <type arch='x86_64' machine='pc-i440fx-2.8'>hvm</type>
        //type参数指定了虚拟机操作系统的类型,内容:hvm表明该OS被设计为直接运行在裸金属上面,需要全虚拟化,
        //而linux(一个不好的名字)指OS支 持XEN3hypervisor的客户端ABI,
        //type同样有两个可选参数:arch指定虚拟机的CPU构架,machine指定机器的类型。
        //<boot dev='hd'/>dev属性的值可以是:fd、hd、cdrom、network,它经常被用来指定下一次启动。boot的元素可以被设置多个用来建立一个启动优先规则。
        <bootmenu enable='yes' timeout='0'/>
        <bios useserial='yes'/>
      </os>
      
      Hypervisor的特性
      <features>
        <acpi/>
        <apic/>
        <pae/>
      </features>
      Hypervisors允许特定的CPU/机器特性打开或关闭,所有的特性都在fearures元素中,以下介绍一些在全虚拟化中常用的标记:
    pae:扩展物理地址模式,使32位的客户端支持大于4GB的内存
    acpi:用于电源管理
    hap:Enable use of Hardware Assisted Paging if available in the hardware.
      
      
      
      //cpu分配
      <cpu>
        <topology sockets='1' cores='1' threads='1'/>
        <numa>
          <cell id='0' cpus='0' memory='4194304' unit='KiB'/>
        </numa>
      </cpu>
      
      时间设置
      <clock offset='variable' adjustment='0' basis='utc'>
        <timer name='rtc' track='guest'/>
      </clock>
      客户端的时间初始化来自宿主机的时间,大多数操作系统期望硬件时钟保持UTC格式,UTC也是默认格式,然而Windows机器却期望它是’localtime’
    clock的offset属性支持四种格式的时间:UTC localtime timezone variable
    UTC:当引导时客户端时钟同步到UTC时钟
    localtime:当引导时客户端时钟同步到主机时钟所在的时区
    timezone:The guest clock will be synchronized to the requested timezone using the timezone attribute.
    
      
      //控制周期:
      <on_poweroff>destroy</on_poweroff>
      <on_reboot>restart</on_reboot>
      <on_crash>preserve</on_crash>
      <on_lockfailure>poweroff</on_lockfailure>
      //当一个客户端的OS触发lifecycle时,它将采取新动作覆盖默认操作,具体状态参数如下:
     //on_poweroff:当客户端请求poweroff时执行特定的动作
      //on_reboot:当客户端请求reboot时执行特定的动作
      // on_crash:当客户端崩溃时执行的动作
       //每种状态下可以允许指定如下四种行为:
        //destory:domain将会被完全终止,domain的所有资源会被释放
        //restart:domain会被终止,然后以相同的配置重新启动
        //preserver:domain会被终止,它的资源会被保留用来分析
        //rename-restart:domain会被终止,然后以一个新名字被重新启动
      
      
      <devices>
      //所有的设备都是一个名为devices元素的子设备(All devices occur as children of the main devices element.),以下是一个简单的配置:
    //<emulator>/usr/bin/kvm</emulator>
    //emulator元素指定模拟设备二进制文件的全路径
        <emulator>/usr/libexec/qemu-kvm</emulator>
        <disk type='file' device='cdrom'>
          <backingStore/>
          <target dev='hdd' bus='ide'/>
          <readonly/>
          <boot order='2'/>
          <alias name='ide0-1-1'/>
          <address type='drive' controller='0' bus='1' target='0' unit='1'/>
        </disk>
        <disk type='file' device='disk'>
          <driver name='qemu' type='qcow2' cache='none'/>
          <source file='/datastore/6ee684f1-8b25-4f0a-9721-fe96540c1870/ae386362-eed6-43a8-b5a8-11a42fabc0ed'/>
          <backingStore/>
          <target dev='vda' bus='virtio'/>
          <boot order='1'/>
          <alias name='virtio-disk0'/>
          <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
        </disk>
        <controller type='usb' index='0' model='ich9-ehci1'>
          <alias name='usb'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
        </controller>
        <controller type='usb' index='1' model='pci-ohci'>
          <alias name='usb1'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
        </controller>
        <controller type='ide' index='0'>
          <alias name='ide'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
        </controller>
        <controller type='scsi' index='0' model='virtio-scsi'>
          <alias name='scsi0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
        </controller>
        <controller type='virtio-serial' index='0'>
          <alias name='virtio-serial0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
        </controller>
        <controller type='pci' index='0' model='pci-root'>
          <alias name='pci.0'/>
        </controller>
        <controller type='pci' index='1' model='pci-bridge'>
          <model name='pci-bridge'/>
          <target chassisNr='1'/>
          <alias name='pci.1'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
        </controller>
        <lease>
          <lockspace>6ee684f1-8b25-4f0a-9721-fe96540c1870</lockspace>
          <key>ae386362-eed6-43a8-b5a8-11a42fabc0ed</key>
          <target path='/datastore/6ee684f1-8b25-4f0a-9721-fe96540c1870/.6ee684f1-8b25-4f0a-9721-fe96540c1870/.leases' offset='4194304'/>
        </lease>
        
        
        网络接口:
    有好几种网络接口访问客户端:Virtual network、Bridge to LAN、Userspace SLIRP stack、Generic ethernet connection、Direct attachment to physical interface。
    Virtual network:这种推荐配置一般是对使用动态/无线网络环境访问客户端的情况。
    Bridge to LAN:这种推荐配置一般是使用静态有限网络连接客户端的情况。
        <interface type='bridge'>
          <mac address='00:16:3e:bd:8e:f3'/>
          <source bridge='vxlansw-000003'/>
          <virtualport type='openvswitch'>
            <parameters interfaceid='1fb6d3e0-c0c0-4fdd-9edb-c64b1327763f'/>
          </virtualport>
          <target dev='vnd59b03ce0'/>
          <model type='virtio'/>
          <boot order='3'/>
          <alias name='net0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
        </interface>
        <interface type='bridge'>
          <mac address='00:16:3e:59:09:2d'/>
          <source bridge='vxlansw-000003'/>
          <virtualport type='openvswitch'>
            <parameters interfaceid='f8a225e1-028f-4396-8107-879f5b77152c'/>
          </virtualport>
          <target dev='vnd59b03ce1'/>
          <model type='rtl8139'/>
          <alias name='net1'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
        </interface>
        <interface type='bridge'>
          <mac address='00:16:3e:97:5b:c0'/>
          <source bridge='vxlansw-000003'/>
          <virtualport type='openvswitch'>
            <parameters interfaceid='f688fbc6-c4e3-4348-9408-12dc903dab06'/>
          </virtualport>
          <target dev='vnd59b03ce2'/>
          <model type='virtio'/>
          <alias name='net2'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
        </interface>
        
        //串行端口
        <serial type='pty'>
          <source path='/dev/pts/14'/>
          <target port='0'/>
          <alias name='serial0'/>
        </serial>
        在每组指令中,最顶层的指令(parallel, serial, console, channel)描述设备怎样出现在客户端中,客户端接口通过target配置。
    The interface presented to the host is given in the type attribute of the top-level element. The host interface is configured by the source element
    
    
        <console type='pty' tty='/dev/pts/14'>
          <source path='/dev/pts/14'/>
          <target type='serial' port='0'/>
          <alias name='serial0'/>
        </console>
        <channel type='unix'>
          <source mode='bind' path='/var/lib/libvirt/qemu/channels/i-000039.com.inspur.ics.vmtools'/>
          <target type='virtio' name='com.inspur.ics.vmtools' state='disconnected'/>
          <alias name='channel0'/>
          <address type='virtio-serial' controller='0' bus='0' port='1'/>
        </channel>
        <channel type='unix'>
          <source mode='bind' path='/var/lib/libvirt/qemu/channels/i-000039.com.inspur.ics.agent'/>
          <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
          <alias name='channel1'/>
          <address type='virtio-serial' controller='0' bus='0' port='2'/>
        </channel>
        
        
        <input type='tablet' bus='usb'>
          <alias name='input0'/>
          <address type='usb' bus='0' port='1'/>
        </input>
        <input type='mouse' bus='ps2'>
          <alias name='input1'/>
        </input>
        <input type='keyboard' bus='ps2'>
          <alias name='input2'/>
        </input>
        输入设备:
    输入设备允许使用图形化界面和虚拟机交互,当有图形化framebuffer的时候,输入设备会被自动提供的。
    <input type='mouse' bus='ps2'/>
    input元素:input元素含有一个强制的属性,type属性的值可以是mouse活tablet,前者使用想对运动,后者使用绝对运动。bus属性指定一个明确的设备类型,值可以是:xen、ps2、usb。
    
        
        <graphics type='vnc' port='5905' autoport='yes' listen='0.0.0.0' keymap='en-us' sharePolicy='force-shared'>
          <listen type='address' address='0.0.0.0'/>
        </graphics>
        graphics元素:graphics含有一个强制的属性type,type的值可以是:sdl、vnc、rdp、desktop。vnc则启动vnc 服务,port属性指定tcp端口,如果是-1,则表示自动分配,vnc的端口自动分配的话是从5900向上递增。listen属性提供一个IP地址给服 务器监听,可以单独在listen元素中设置。passwd属性提供一个vnc的密码。keymap属性提供一个keymap使用。
    Rather than putting the address information used to set up the listening socket for graphics types vnc and spice in the <graphics> listen attribute, a separate subelement of <graphics>, called <listen> can be specified (see the examples above)since 0.9.4. <listen> accepts the following attributes:
    listen元素:listen元素专门针对vnc和spice设置监听端口等。它包含以下属性:type、address、network。type的 值可以是address或network。如果设置了type=address,那么address属性设置一个ip地址或者主机名来监听。如果 type=network,则network属性设置一个网络名称在libvirt‘s的网络配置文件中。
    
    字符设备提供同虚拟机进行交互的接口,Paravirtualized consoles, serial ports, parallel ports and channels 都是字符设备,它们使用相同的语法。
        
        
        <video>
          <model type='cirrus' vram='16384' heads='1' primary='yes'/>
          <alias name='video0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
        </video>
        video元素:是描述声音设备的容器,为了向后完全兼容,如果没有设置video但是有graphics在xml配置文件中,这时libvirt会按照 客户端类型增加一个默认的video,。model元素有一个强制的type属性,它的值可以是:vga、cirrus、vmvga、xen、vbox、 qxl。例如一个客户端类型为kvm,那么默认的type值是cirrus。
        
        
        
        <memballoon model='virtio'>
          <alias name='balloon0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
        </memballoon>
        <panic model='isa'>
          <address type='isa' iobase='0x505'/>
        </panic>
      </devices>
      
      
      <seclabel type='none' model='none'/>
      <seclabel type='dynamic' model='dac' relabel='yes'>
        <label>+0:+0</label>
        <imagelabel>+0:+0</imagelabel>
      </seclabel>
    </domain>
  • 相关阅读:
    C#按键打开文件选择对话框,并把选择好的路径保存/显示到textBox
    C#按钮打开浏览器,网址
    阅读笔记05
    进度条14
    冲刺4--10
    冲刺3
    冲刺2
    课堂训练书本
    进度条13
    课堂水王2
  • 原文地址:https://www.cnblogs.com/mrwuzs/p/8037058.html
Copyright © 2020-2023  润新知