<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>

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. 【学习总结】GirlsInAI ML-diary day-16-pip install XX

    [学习总结]GirlsInAI ML-diary 总 原博github链接-day16 Pip pip是python 著名的包管理工具,在python开发过程必不可少. 本节带大家了解用pip实现的p ...

  2. sys模块进度条玩法笔记

    #! /user/bin/env python# -*- encoding:utf-8 -*-import time,sys for i in range(31): sys.stdout.write( ...

  3. C#设计模式之8:外观模式

    外观模式 外观模式和适配器模式一样,都实现了接口改变,适配器模式是让一个接口转化成另外一个接口,而外观模式是让接口变得更简单. 先来看一下需求: 外观模式没有封装子系统的类,外观只是提供一个统一的接口 ...

  4. laravel门面和服务提供者使用

      关于laravel门面和服务提供者使用的一点见解,门面之词,不足之处,还请多多指教. 在laravel中,我们可能需要用到自己添加的类时,可以建立一个文件夹专门存放类文件,也可以使用laravel ...

  5. 批量处理word所有回车行

    在WORD中点击CTRL+H,弹出对话框,输入如下替换符

  6. 关于Navicat连接虚拟机宝塔数据库

    1.由于虚拟机安装的宝塔面板,目前没找到数据库安全配置文件,所以没能用Navicat连接数据库 2.在宝塔面板=>安全下 放行 3306 端口 即可以 连接成功 跟将bind-address = ...

  7. maven+springmvc项目启动时,request mapping not found……

    springmvc项目跑的好好的,跑着跑着,出现request mapping not found的问题. 第一波,网上查问题,stackoverflow上面的各种配置说明,但是我本地就是没查出问题 ...

  8. hadoop的缺点

    Hadoop的限制 Hadoop只能执行批量处理,并且只以顺序方式访问数据.这意味着必须搜索整个数据集,即使是最简单的搜索工作.

  9. python爬虫之git的使用(origin说明)

    1.首先我们回忆两个命令 #git remote add origin 远程仓库链接 #git push -u origin master 我们一起看看这个命令,git是git的一级命令,push就是 ...

  10. Django数据库操作中You are trying to add a non-nullable field 'name' to contact without a default错误处理

    name = models.CharField(max_length=50) 执行:python manage.py makemirations出现以下错误: You are trying to ad ...