OpenStack+kvm虚拟机xml格式解析
配置说明
首先介绍一下配置结构:
xml配置遵循<keyword> xxxxxx </keyword>的格式,即一个配置段以<keyword>开头,以</keyword>结尾;
那么可知整个虚拟机的xml格式,为包在<domain></domain>配置段之间的一段配置,即:
domain配置段
<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>QEMU-fedora-i686</name>
<memory>219200</memory>
<os>
<type arch='i686' machine='pc'>hvm</type>
</os>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
</devices>
<qemu:commandline>
<qemu:arg value='-newarg'/>
<qemu:env name='QEMU_ENV' value='VAL'/>
</qemu:commandline>
</domain>
domain配置段为所有kvm虚拟机的根配置,有两项属性:
type:定义了使用什么管理程序进行管理实例运行,合法参数是驱动配置的,包含"xen","kvm","qemu","lxc"等等
id:定义了一个运行中的客户机的唯一标识符,未运行的虚拟机无id值。
在domain配置之内,还可以进行其他配置的定义:
<name>instance-0000d165</name>
<uuid>156917bc-debf-4515-97f7-8b7cfd9e16bd</uuid>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+0:+0</label>
<imagelabel>+0:+0</imagelabel>
</seclabel>
name:定义了虚拟机的名称,仅包含字母数字字符,在单宿主机上唯一不可重复,通常作为虚拟机的xml配置的文件名
uuid:定义了一个全局的虚拟机唯一id,必须遵循RFC 4122规范,如在创建中未指定,则会生成一个随机UUDID,
metadata配置段
<metadata>
<nova:instance xmlns:nova="http://openstack.org/xmlns/libvirt/nova/1.0">
<nova:package version="4.6.1-1.bc.el7"/>
<nova:name>ec-wb-test</nova:name>
<nova:creationTime>2021-02-05 09:50:44</nova:creationTime>
<nova:flavor name="ecloud-normalNetImprove-2vcpu-4G-20G-6248-2.0G">
<nova:memory>4096</nova:memory>
<nova:disk>0</nova:disk>
<nova:swap>0</nova:swap>
<nova:ephemeral>0</nova:ephemeral>
<nova:vcpus>2</nova:vcpus>
</nova:flavor>
<nova:owner>
<nova:user uuid="4d3ba0aa7c334e1ab8fc20f319f0ec2b">sre_isre_laishijie-EC</nova:user>
<nova:project uuid="5a107930ea384a03b1fbc5f16c4f6e44">sre_isre_laishijie</nova:project>
</nova:owner>
<nova:root type="image" uuid="952b0f1c-fd94-4a02-8881-799f7eac6888"/>
</nova:instance>
</metadata>
metadata配置段存储了(libvirt之外的)自定义的配置信息,通常由其他对接组件指定,如nova
如上述配置中,指定了再nova层面的一些信息,如nova版本,nova侧的云主机名称,创建时间,flavor名称,租户信息,image信息等等。
memory配置段
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<memoryBacking>
<hugepages>
<page size='1048576' unit='KiB' nodeset='0'/>
</hugepages>
</memoryBacking>
cpu配置段
<vcpu placement='static'>2</vcpu>
<cputune>
<shares>2048</shares>
<vcpupin vcpu='0' cpuset='0,5-19,40,45-59'/>
<vcpupin vcpu='1' cpuset='0,5-19,40,45-59'/>
<emulatorpin cpuset='0,5-19,40,45-59'/>
</cputune>
<numatune>
<memory mode='strict' nodeset='0'/>
<memnode cellid='0' mode='strict' nodeset='0'/>
</numatune>
<features>
<acpi/>
<apic/>
</features>
<cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>Skylake-Server-IBRS</model>
<vendor>Intel</vendor>
<topology sockets='2' cores='1' threads='1'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='clflushopt'/>
<feature policy='require' name='pku'/>
<feature policy='require' name='stibp'/>
<feature policy='require' name='ssbd'/>
<numa>
<cell id='0' cpus='0-1' memory='4194304' unit='KiB' memAccess='shared'/>
</numa>
</cpu>
resource配置段
<resource>
<partition>/machine</partition>
</resource>
smbios配置段
<sysinfo type='smbios'>
<system>
<entry name='manufacturer'>RDO</entry>
<entry name='product'>OpenStack Compute</entry>
<entry name='version'>4.6.1-1.bc.el7</entry>
<entry name='serial'>c883a8db-1dfe-438d-9a07-3e251f73c5cc</entry>
<entry name='uuid'>156917bc-debf-4515-97f7-8b7cfd9e16bd</entry>
<entry name='family'>Virtual Machine</entry>
</system>
</sysinfo>
os配置段
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type>
<boot dev='hd'/>
<smbios mode='sysinfo'/>
</os>
clock配置段
<clock offset='utc'>
<timer name='pit' tickpolicy='delay'/>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='hpet' present='no'/>
</clock>
device配置段
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='cdrom'>
...
</disk>
<controller type='scsi' index='0' model='virtio-scsi'>
...
</controller>
<interface type='vhostuser'>
...
</interface>
<serial type='pty'>
...
</serial>
<console type='pty' tty='/dev/pts/0'>
...
</console>
<channel type='unix'>
...
</channel>
<input type='mouse' bus='ps2'>
...
</input>
<graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0' keymap='en-us'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<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>
<watchdog model='i6300esb' action='none'>
<alias name='watchdog0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</watchdog>
<memballoon model='virtio'>
<stats period='10'/>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
一个完整的OpenStack+kvm虚拟机xml文件形同如下内容,仅供参考:
<domain type='kvm' id='30'>
<name>instance-0000d165</name>
<uuid>156917bc-debf-4515-97f7-8b7cfd9e16bd</uuid>
<metadata>
<nova:instance xmlns:nova="http://openstack.org/xmlns/libvirt/nova/1.0">
<nova:package version="4.6.1-1.bc.el7"/>
<nova:name>ec-wb-test</nova:name>
<nova:creationTime>2021-02-05 09:50:44</nova:creationTime>
<nova:flavor name="ecloud-normalNetImprove-2vcpu-4G-20G-6248-2.0G">
<nova:memory>4096</nova:memory>
<nova:disk>0</nova:disk>
<nova:swap>0</nova:swap>
<nova:ephemeral>0</nova:ephemeral>
<nova:vcpus>2</nova:vcpus>
</nova:flavor>
<nova:owner>
<nova:user uuid="4d3ba0aa7c334e1ab8fc20f319f0ec2b">sre_isre_laishijie-EC</nova:user>
<nova:project uuid="5a107930ea384a03b1fbc5f16c4f6e44">sre_isre_laishijie</nova:project>
</nova:owner>
<nova:root type="image" uuid="952b0f1c-fd94-4a02-8881-799f7eac6888"/>
</nova:instance>
</metadata>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<memoryBacking>
<hugepages>
<page size='1048576' unit='KiB' nodeset='0'/>
</hugepages>
</memoryBacking>
<vcpu placement='static'>2</vcpu>
<cputune>
<shares>2048</shares>
<vcpupin vcpu='0' cpuset='0,5-19,40,45-59'/>
<vcpupin vcpu='1' cpuset='0,5-19,40,45-59'/>
<emulatorpin cpuset='0,5-19,40,45-59'/>
</cputune>
<numatune>
<memory mode='strict' nodeset='0'/>
<memnode cellid='0' mode='strict' nodeset='0'/>
</numatune>
<resource>
<partition>/machine</partition>
</resource>
<sysinfo type='smbios'>
<system>
<entry name='manufacturer'>RDO</entry>
<entry name='product'>OpenStack Compute</entry>
<entry name='version'>4.6.1-1.bc.el7</entry>
<entry name='serial'>c883a8db-1dfe-438d-9a07-3e251f73c5cc</entry>
<entry name='uuid'>156917bc-debf-4515-97f7-8b7cfd9e16bd</entry>
<entry name='family'>Virtual Machine</entry>
</system>
</sysinfo>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type>
<boot dev='hd'/>
<smbios mode='sysinfo'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>Skylake-Server-IBRS</model>
<vendor>Intel</vendor>
<topology sockets='2' cores='1' threads='1'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='clflushopt'/>
<feature policy='require' name='pku'/>
<feature policy='require' name='stibp'/>
<feature policy='require' name='ssbd'/>
<numa>
<cell id='0' cpus='0-1' memory='4194304' unit='KiB' memAccess='shared'/>
</numa>
</cpu>
<clock offset='utc'>
<timer name='pit' tickpolicy='delay'/>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='hpet' present='no'/>
</clock>
<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='cdrom'>
<driver name='qemu' type='raw' cache='none'/>
<source file='/var/lib/nova/instances/156917bc-debf-4515-97f7-8b7cfd9e16bd/disk.config'/>
<backingStore/>
<target dev='hda' bus='ide'/>
<readonly/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='network' device='disk'>
<driver name='qemu' type='raw' cache='none' discard='unmap'/>
<source protocol='rbd' name='ebs_ceph_ssd_sys/volume-6347f0d3-b2b1-41b2-a2b4-e75c19a9cba9'>
<host name='10.203.135.1' port='6789'/>
<host name='10.203.135.8' port='6789'/>
<host name='10.203.135.15' port='6789'/>
</source>
<target dev='sda' bus='scsi'/>
<iotune>
<total_bytes_sec>146800640</total_bytes_sec>
<total_iops_sec>2800</total_iops_sec>
</iotune>
<serial>6347f0d3-b2b1-41b2-a2b4-e75c19a9cba9</serial>
<wwn>004439433801266d</wwn>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='virtio-scsi'>
<alias name='scsi0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' 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='virtio-serial' index='0'>
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</controller>
<controller type='usb' index='0' model='piix3-uhci'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<alias name='pci.0'/>
</controller>
<interface type='vhostuser'>
<mac address='fa:16:3e:95:e2:9a'/>
<source type='unix' path='/usr/local/var/run/openvswitch/vhub2f8a3fa-ff' mode='server'/>
<target dev='vhub2f8a3fa-ff'/>
<model type='virtio'/>
<driver name='vhost' queues='2' rx_queue_size='1024' tx_queue_size='1024'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/0'/>
<log file='/var/lib/nova/instances/156917bc-debf-4515-97f7-8b7cfd9e16bd/console.log' append='off'/>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/0'>
<source path='/dev/pts/0'/>
<log file='/var/lib/nova/instances/156917bc-debf-4515-97f7-8b7cfd9e16bd/console.log' append='off'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/org.qemu.guest_agent.0.instance-0000d165.sock'/>
<target type='virtio' name='org.qemu.guest_agent.0' state='connected'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</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>
<graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0' keymap='en-us'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<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>
<watchdog model='i6300esb' action='none'>
<alias name='watchdog0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</watchdog>
<memballoon model='virtio'>
<stats period='10'/>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+0:+0</label>
<imagelabel>+0:+0</imagelabel>
</seclabel>
</domain>
OpenStack+kvm虚拟机xml格式解析的更多相关文章
- 虚拟机VHD格式解析到NTFS文件系统解析
本来的需求是XEN下的镜像取证,但这篇仅包括他支持的一种格式,就是VHD,此项目从头开始大概用了两周时间,中间遇到了很多让人头大的问题,光是思考的笔记就写了十几页纸,不过实际上并没有那么难,主要是很久 ...
- kvm 虚拟机XML文件
<domain type='kvm' id='29'> //domain 是一个所有虚拟机都需要的根元素,它有两个属性, //type定义使用哪个虚拟机管理程序,值可以是:xen.kvm. ...
- openstack kvm 虚拟机磁盘差异衍生
1, openstack虚拟实例备份之--多镜像格式多镜像文件合并为一个镜像文件衍生-差异镜像文件 /var/lib/nova/instances/b0abc22f-1a73-4079-b1bc ...
- OpenStack Nova虚拟机创建流程解析
https://yikun.github.io/2017/09/27/OpenStack-Nova%E8%99%9A%E6%8B%9F%E6%9C%BA%E5%88%9B%E5%BB%BA%E6%B5 ...
- openStack kvm 虚拟机CPU颗粒化控制
前一篇理解cpu topology对CPU Topology进行了学习总结,这里想总结下OpenStack下vCPU与pCPU常用的的绑定方式. 在尝试这些绑定之前,尤其是处理NUMA架构时还是建议看 ...
- (5)微信二次开发 之 XML格式数据解析
1.首先理解一下html html的全名是:HyperText Transfer markup language 超级文本标记语言,html本质上是一门标记(符合)语言,在html里,这些标记是事先定 ...
- 完整部署CentOS7.2+OpenStack+kvm 云平台环境(3)--为虚拟机指定固定ip
之前在测试环境(centos7.2)上部署了openstack云平台(完整部署CentOS7.2+OpenStack+kvm 云平台环境(1)--基础环境搭建),openstack在neutron组网 ...
- OpenStack入门篇(四)之KVM虚拟机介绍和管理
1.查看虚拟机,启动虚拟机 [root@linux-node1 ~]# virsh list --all Id Name State --------------------------------- ...
- 解析XML格式数据
学习解析XML格式的数据前,搭建一个简单的web服务器,在这个服务器上提供xml文本用于练习. 一.搭建Apache服务器 在Apache官网下载编译好的服务器程序,安装.对于Windows来说127 ...
随机推荐
- Intellij IDEA maven设置tomcat
1 pom.xml配置插件 <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId&g ...
- Prometheus时序数据库-数据的查询
Prometheus时序数据库-数据的查询 前言 在之前的博客里,笔者详细阐述了Prometheus数据的插入过程.但我们最常见的打交道的是数据的查询.Prometheus提供了强大的Promql来满 ...
- 什么是事务?事务的四个特性(ACID)?并发事务带来哪些问题?事务隔离级别都有哪些?事务的传播特性
什么是事务? 事务是应用程序中一系列严密的操作,所有操作必须成功完成,否则在每个操作中所作的所有更改都会被撤消.也就是事务具有原子性,一个事务中的一系列的操作要么全部成功,要么一个都不做. 事物的四个 ...
- 第20 章 : GPU 管理和 Device Plugin 工作机制
GPU 管理和 Device Plugin 工作机制 本文将主要分享以下几个方面的内容: 需求来源 GPU 的容器化 Kubernetes 的 GPU 管理 工作原理 课后思考与实践 需求来源 201 ...
- Markdown部分用法总结
1.Markdown数学公式&符号 2.Cmd Markdown 公式指导手册
- 带你全面认识CMMI V2.0(二)
CMMI V2.0成熟度等级 CMMI V2.0的一大变化是,所有实践领域均适用于成熟度三级(ML3),并具有特定的附加必需实践水平. 例如,在ML3上需要进行因果分析和解决,但在CMMI成熟度四级( ...
- H5 离线存储-使用 serverWorker 实现
H5 离线存储-使用 serverWorker 实现 离线存储所用技术 serverWorker serviceWorker 生命周期 install 事件会在 serviceWorker 注册成功时 ...
- git版本控制之三
[删除文件]使用关键字 git rm '待删除的文件名或者文件夹名字' 这个默认会把本地和版本库里面的这个文件都删掉!!! 有一种情形就是我往版本库里面提交错了文件,我想从版本库里面移除,但是我本地 ...
- OAuth 2.0 单元测试解决方案
为什么需要单元测试 单元测试拥有保证代码质量.尽早发现软件 Bug.简化调试过程.促进变化并简化集成.使流程更灵活等优势.单元测试是针对代码单元的独立测试,核心是"独立",优势来源 ...
- Mysql无法通过临时密码访问
在Linux上安装Mysql: [步骤一]:将mysql的安装文件上传到Linux的服务器. [步骤二]:安装MYSQL服务端 [步骤三]:安装MYSQL客户端 我在步骤三遇到了问题,所以直接从步骤三 ...