1. <domain type='kvm' id='29'>
  2. //domain 是一个所有虚拟机都需要的根元素,它有两个属性,
  3. //type定义使用哪个虚拟机管理程序,值可以是:xen、kvm、qemu、lxc、kqemu,
  4. //第二个参数是id,它唯一的标示一个运行的虚拟机,不活跃的客户端没有id。
  5. <name>i-000039</name>
  6. //name参数为虚拟机定义了一个简短的名字,必须唯一。
  7.  
  8. <uuid>d59b03ce-2e78-4d35-b731-09d9ca9653af</uuid>
  9. //uid为虚拟机定义了一个全球唯一的标示符,uuid的格式必须遵循RFC 4122指定的格式,当创建虚拟机没有指定uuid时会随机的生成一个uuid。
  10.  
  11. <memory unit='KiB'>4194304</memory>
  12. <currentMemory unit='KiB'>4194304</currentMemory>
  13. <memtune>
  14. <hard_limit unit='KiB'>4194304</hard_limit>
  15. </memtune>
  16. //memory 定义客户端启动时可以分配到的最大内存,内存单位由unit定义,单位可以是:K、KiB、M、MiB、G、GiB、T、TiB。默认是KiB。
  17.  
  18. <vcpu placement='static'>1</vcpu>
  19. //vcpu的内容是为虚拟机最多分配几个cpu,值处于1~maxcpu之间,可选参数:cpuset参数指定虚拟cpu可以映射到那些物理cpu上,物理 cpu用逗号分开,单个数字的标示单个cpu,
  20. //也可以用range符号标示多个cpu,数字前面的脱字符标示排除这个cpu,current参数指定虚拟 机最少,placement参数指定一个domain的cpu的分配模式,值可以是static、auto。
  21.  
  22. <cputune>
  23. <shares>1024</shares>
  24. <period>100000</period>
  25. <quota>-1</quota>
  26. </cputune>
  27. <resource>
  28. <partition>/machine</partition>
  29. </resource>
  30.  
  31. //操作系统启动介绍
  32. <os>
  33. <type arch='x86_64' machine='pc-i440fx-2.8'>hvm</type>
  34. //type参数指定了虚拟机操作系统的类型,内容:hvm表明该OS被设计为直接运行在裸金属上面,需要全虚拟化,
  35. //而linux(一个不好的名字)指OS支 持XEN3hypervisor的客户端ABI,
  36. //type同样有两个可选参数:arch指定虚拟机的CPU构架,machine指定机器的类型。
  37. //<boot dev='hd'/>dev属性的值可以是:fd、hd、cdrom、network,它经常被用来指定下一次启动。boot的元素可以被设置多个用来建立一个启动优先规则。
  38. <bootmenu enable='yes' timeout='0'/>
  39. <bios useserial='yes'/>
  40. </os>
  41.  
  42. Hypervisor的特性
  43. <features>
  44. <acpi/>
  45. <apic/>
  46. <pae/>
  47. </features>
  48. Hypervisors允许特定的CPU/机器特性打开或关闭,所有的特性都在fearures元素中,以下介绍一些在全虚拟化中常用的标记:
  49. pae:扩展物理地址模式,使32位的客户端支持大于4GB的内存
  50. acpi:用于电源管理
  51. hap:Enable use of Hardware Assisted Paging if available in the hardware.
  52.  
  53. //cpu分配
  54. <cpu>
  55. <topology sockets='1' cores='1' threads='1'/>
  56. <numa>
  57. <cell id='0' cpus='0' memory='4194304' unit='KiB'/>
  58. </numa>
  59. </cpu>
  60.  
  61. 时间设置
  62. <clock offset='variable' adjustment='0' basis='utc'>
  63. <timer name='rtc' track='guest'/>
  64. </clock>
  65. 客户端的时间初始化来自宿主机的时间,大多数操作系统期望硬件时钟保持UTC格式,UTC也是默认格式,然而Windows机器却期望它是’localtime’
  66. clock的offset属性支持四种格式的时间:UTC localtime timezone variable
  67. UTC:当引导时客户端时钟同步到UTC时钟
  68. localtime:当引导时客户端时钟同步到主机时钟所在的时区
  69. timezone:The guest clock will be synchronized to the requested timezone using the timezone attribute.
  70.  
  71. //控制周期:
  72. <on_poweroff>destroy</on_poweroff>
  73. <on_reboot>restart</on_reboot>
  74. <on_crash>preserve</on_crash>
  75. <on_lockfailure>poweroff</on_lockfailure>
  76. //当一个客户端的OS触发lifecycle时,它将采取新动作覆盖默认操作,具体状态参数如下:
  77. //on_poweroff:当客户端请求poweroff时执行特定的动作
  78. //on_reboot:当客户端请求reboot时执行特定的动作
  79. // on_crash:当客户端崩溃时执行的动作
  80. //每种状态下可以允许指定如下四种行为:
  81. //destory:domain将会被完全终止,domain的所有资源会被释放
  82. //restart:domain会被终止,然后以相同的配置重新启动
  83. //preserver:domain会被终止,它的资源会被保留用来分析
  84. //rename-restart:domain会被终止,然后以一个新名字被重新启动
  85.  
  86. <devices>
  87. //所有的设备都是一个名为devices元素的子设备(All devices occur as children of the main devices element.),以下是一个简单的配置:
  88. //<emulator>/usr/bin/kvm</emulator>
  89. //emulator元素指定模拟设备二进制文件的全路径
  90. <emulator>/usr/libexec/qemu-kvm</emulator>
  91. <disk type='file' device='cdrom'>
  92. <backingStore/>
  93. <target dev='hdd' bus='ide'/>
  94. <readonly/>
  95. <boot order='2'/>
  96. <alias name='ide0-1-1'/>
  97. <address type='drive' controller='0' bus='1' target='0' unit='1'/>
  98. </disk>
  99. <disk type='file' device='disk'>
  100. <driver name='qemu' type='qcow2' cache='none'/>
  101. <source file='/datastore/6ee684f1-8b25-4f0a-9721-fe96540c1870/ae386362-eed6-43a8-b5a8-11a42fabc0ed'/>
  102. <backingStore/>
  103. <target dev='vda' bus='virtio'/>
  104. <boot order='1'/>
  105. <alias name='virtio-disk0'/>
  106. <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
  107. </disk>
  108. <controller type='usb' index='0' model='ich9-ehci1'>
  109. <alias name='usb'/>
  110. <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
  111. </controller>
  112. <controller type='usb' index='1' model='pci-ohci'>
  113. <alias name='usb1'/>
  114. <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
  115. </controller>
  116. <controller type='ide' index='0'>
  117. <alias name='ide'/>
  118. <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
  119. </controller>
  120. <controller type='scsi' index='0' model='virtio-scsi'>
  121. <alias name='scsi0'/>
  122. <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
  123. </controller>
  124. <controller type='virtio-serial' index='0'>
  125. <alias name='virtio-serial0'/>
  126. <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  127. </controller>
  128. <controller type='pci' index='0' model='pci-root'>
  129. <alias name='pci.0'/>
  130. </controller>
  131. <controller type='pci' index='1' model='pci-bridge'>
  132. <model name='pci-bridge'/>
  133. <target chassisNr='1'/>
  134. <alias name='pci.1'/>
  135. <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
  136. </controller>
  137. <lease>
  138. <lockspace>6ee684f1-8b25-4f0a-9721-fe96540c1870</lockspace>
  139. <key>ae386362-eed6-43a8-b5a8-11a42fabc0ed</key>
  140. <target path='/datastore/6ee684f1-8b25-4f0a-9721-fe96540c1870/.6ee684f1-8b25-4f0a-9721-fe96540c1870/.leases' offset='4194304'/>
  141. </lease>
  142.  
  143. 网络接口:
  144. 有好几种网络接口访问客户端:Virtual network、Bridge to LAN、Userspace SLIRP stack、Generic ethernet connection、Direct attachment to physical interface。
  145. Virtual network:这种推荐配置一般是对使用动态/无线网络环境访问客户端的情况。
  146. Bridge to LAN:这种推荐配置一般是使用静态有限网络连接客户端的情况。
  147. <interface type='bridge'>
  148. <mac address='00:16:3e:bd:8e:f3'/>
  149. <source bridge='vxlansw-000003'/>
  150. <virtualport type='openvswitch'>
  151. <parameters interfaceid='1fb6d3e0-c0c0-4fdd-9edb-c64b1327763f'/>
  152. </virtualport>
  153. <target dev='vnd59b03ce0'/>
  154. <model type='virtio'/>
  155. <boot order='3'/>
  156. <alias name='net0'/>
  157. <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
  158. </interface>
  159. <interface type='bridge'>
  160. <mac address='00:16:3e:59:09:2d'/>
  161. <source bridge='vxlansw-000003'/>
  162. <virtualport type='openvswitch'>
  163. <parameters interfaceid='f8a225e1-028f-4396-8107-879f5b77152c'/>
  164. </virtualport>
  165. <target dev='vnd59b03ce1'/>
  166. <model type='rtl8139'/>
  167. <alias name='net1'/>
  168. <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
  169. </interface>
  170. <interface type='bridge'>
  171. <mac address='00:16:3e:97:5b:c0'/>
  172. <source bridge='vxlansw-000003'/>
  173. <virtualport type='openvswitch'>
  174. <parameters interfaceid='f688fbc6-c4e3-4348-9408-12dc903dab06'/>
  175. </virtualport>
  176. <target dev='vnd59b03ce2'/>
  177. <model type='virtio'/>
  178. <alias name='net2'/>
  179. <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
  180. </interface>
  181.  
  182. //串行端口
  183. <serial type='pty'>
  184. <source path='/dev/pts/14'/>
  185. <target port='0'/>
  186. <alias name='serial0'/>
  187. </serial>
  188. 在每组指令中,最顶层的指令(parallel, serial, console, channel)描述设备怎样出现在客户端中,客户端接口通过target配置。
  189. 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
  190.  
  191. <console type='pty' tty='/dev/pts/14'>
  192. <source path='/dev/pts/14'/>
  193. <target type='serial' port='0'/>
  194. <alias name='serial0'/>
  195. </console>
  196. <channel type='unix'>
  197. <source mode='bind' path='/var/lib/libvirt/qemu/channels/i-000039.com.inspur.ics.vmtools'/>
  198. <target type='virtio' name='com.inspur.ics.vmtools' state='disconnected'/>
  199. <alias name='channel0'/>
  200. <address type='virtio-serial' controller='0' bus='0' port='1'/>
  201. </channel>
  202. <channel type='unix'>
  203. <source mode='bind' path='/var/lib/libvirt/qemu/channels/i-000039.com.inspur.ics.agent'/>
  204. <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
  205. <alias name='channel1'/>
  206. <address type='virtio-serial' controller='0' bus='0' port='2'/>
  207. </channel>
  208.  
  209. <input type='tablet' bus='usb'>
  210. <alias name='input0'/>
  211. <address type='usb' bus='0' port='1'/>
  212. </input>
  213. <input type='mouse' bus='ps2'>
  214. <alias name='input1'/>
  215. </input>
  216. <input type='keyboard' bus='ps2'>
  217. <alias name='input2'/>
  218. </input>
  219. 输入设备:
  220. 输入设备允许使用图形化界面和虚拟机交互,当有图形化framebuffer的时候,输入设备会被自动提供的。
  221. <input type='mouse' bus='ps2'/>
  222. input元素:input元素含有一个强制的属性,type属性的值可以是mouse活tablet,前者使用想对运动,后者使用绝对运动。bus属性指定一个明确的设备类型,值可以是:xen、ps2、usb。
  223.  
  224. <graphics type='vnc' port='5905' autoport='yes' listen='0.0.0.0' keymap='en-us' sharePolicy='force-shared'>
  225. <listen type='address' address='0.0.0.0'/>
  226. </graphics>
  227. graphics元素:graphics含有一个强制的属性type,type的值可以是:sdl、vnc、rdp、desktop。vnc则启动vnc 服务,port属性指定tcp端口,如果是-1,则表示自动分配,vnc的端口自动分配的话是从5900向上递增。listen属性提供一个IP地址给服 务器监听,可以单独在listen元素中设置。passwd属性提供一个vnc的密码。keymap属性提供一个keymap使用。
  228. 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:
  229. listen元素:listen元素专门针对vnc和spice设置监听端口等。它包含以下属性:type、address、network。type的 值可以是address或network。如果设置了type=address,那么address属性设置一个ip地址或者主机名来监听。如果 type=network,则network属性设置一个网络名称在libvirt‘s的网络配置文件中。
  230.  
  231. 字符设备提供同虚拟机进行交互的接口,Paravirtualized consoles, serial ports, parallel ports and channels 都是字符设备,它们使用相同的语法。
  232.  
  233. <video>
  234. <model type='cirrus' vram='16384' heads='1' primary='yes'/>
  235. <alias name='video0'/>
  236. <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
  237. </video>
  238. video元素:是描述声音设备的容器,为了向后完全兼容,如果没有设置video但是有graphics在xml配置文件中,这时libvirt会按照 客户端类型增加一个默认的video,。model元素有一个强制的type属性,它的值可以是:vga、cirrus、vmvga、xen、vbox、 qxl。例如一个客户端类型为kvm,那么默认的type值是cirrus。
  239.  
  240. <memballoon model='virtio'>
  241. <alias name='balloon0'/>
  242. <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
  243. </memballoon>
  244. <panic model='isa'>
  245. <address type='isa' iobase='0x505'/>
  246. </panic>
  247. </devices>
  248.  
  249. <seclabel type='none' model='none'/>
  250. <seclabel type='dynamic' model='dac' relabel='yes'>
  251. <label>+0:+0</label>
  252. <imagelabel>+0:+0</imagelabel>
  253. </seclabel>
  254. </domain>

kvm 虚拟机XML文件的更多相关文章

  1. OpenStack+kvm虚拟机xml格式解析

    配置说明 首先介绍一下配置结构: xml配置遵循<keyword> xxxxxx </keyword>的格式,即一个配置段以<keyword>开头,以</ke ...

  2. openstack学习(二)虚拟机XML文件

    1 , XML文件 <domain type='kvm'> //如果是Xen,则type=‘xen’ <name>ubuntu</name> //虚拟机名称,同一物 ...

  3. kvm xxx.xml文件的位置

    /var/run/libvirt/qemu/xxx.xml /etc/libvirt/qemu/xxx.xml

  4. 在KVM虚拟机中使用spice系列之二(USB映射,SSL,密码,多客户端支持)

    在KVM虚拟机中使用spice系列之二(USB映射,SSL,密码,多客户端支持) 发布时间: 2015-02-27 00:16 1.spice的USB重定向 1.1 介绍 使用usb重定向,在clie ...

  5. KVM虚拟机无法启动

    一.启动虚拟机报错: [root@KVM ~]# virsh start node-mssql-test01 error: Failed to start domain node-mssql-test ...

  6. CentOS 6.9下KVM虚拟机通过virt-clone克隆虚拟机(转)

    一.virt-clone概述 1.virt-clone作用简介 virt-clone主要是用来克隆kvm虚拟机,并且通过Options.General Option.Storage Configura ...

  7. kvm虚拟机在线调整硬件配置

    #centos5.x版本不支持动态调整内存,CPU,以下是在centos6.x上测试 1.查看虚拟机信息 shell> virsh dumpxml cos_v1 | head -n 10 < ...

  8. 6、安装kvm虚拟机

    6.1.虚拟机开启虚拟化: 6.2.检查linux虚拟机cpu是否开启了虚拟化: egrep -o 'vmx|svm' /proc/cpuinfo vmx 6.3.安装kvm管理和安装kvm虚拟机的软 ...

  9. KVM虚拟机的xml配置文件

    在RHEL6中,用于从磁盘启动的XML文件 这里以dcs01.xml为例: <domain type='kvm'><name>dcs01</name><uui ...

随机推荐

  1. C99标准的柔性数组 (Flexible Array)

    [什么是柔性数组(Fliexible Array)] 柔性数组在C99中的定义是: 6.7.2.1 Structure and union specifiers As a special case, ...

  2. IDEA将项目上传至码云/GitHub托管

    怎么将本地的项目放到码云或者GitHub去托管了?(以码云为例) 一.创建远程项目 第一步:点击创建项目 第二步:填写项目相关信息 第三步:复制远程的项目地址,注意:此处码云官方已经给出上传项目方法, ...

  3. day 7-14 数据库完整性约束

    一. 介绍 约束条件与数据类型的宽度一样,都是可选参数 作用:用于保证数据的完整性和一致性 主要分为: PRIMARY KEY 标示该字段为表的主键,可以唯一的标示记录 FOREIGN KEY 标示该 ...

  4. 转《基于Ionic3实现微信支付和支付宝支付》

    在Ionic应用里实现支付并不难,但是有的坑真是不爬不知道. 一:支付宝支付 网上关于支付宝支付cordova插件真是非常多,但是大多会报一些让你很无语的错误.比如sdk早已过时不是最新的,或者没有出 ...

  5. python爬虫之初始scrapy

    简介: Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中. 其最初是为了 页面抓取 (更确切来说, 网络抓取 )所设 ...

  6. RBAC模型

    1.RBAC(Role-Based Access Control,基于角色的访问控制),就是用户通过角色与权限进行关联.简单地说,一个用户拥有若干角色,每一个角色拥有若干权限.这样,就构造成“用户-角 ...

  7. python数学第五天【常用概率分布】

    1. 概率基本公式 思考题: 3. 两点分布 4. 二项分布 推论一: 5.柏松分布 6. 均匀分布 7. 指数分布 8. 正态分布 9.常见分布的总结

  8. 在delphi中生成GUID

    什么是 GUID ? 全球唯一标识符 (GUID) 是一个字母数字标识符,用于指示产品的唯一性安装.在许多流行软件应用程序(例如 Web 浏览器和媒体播放器)中,都使用 GUID. GUID 的格式为 ...

  9. springboot+jpa+mysql+redis+swagger整合步骤

    springboot+jpa+MySQL+swagger框架搭建好之上再整合redis: 在电脑上先安装redis: 一.在pom.xml中引入redis 二.在application.yml里配置r ...

  10. 三种bean创建方式