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 ...
随机推荐
- vue 页面生成图片保存
需求:将页面中的元素转成图片,支持保存或下载.要求下载的图片包含页面背景,头像,用户名,文本为"我的邀请码"和个人二维码. 实现:将页面绘制到canvas中,生成base64图片链 ...
- mysql中的基础查询 练习
#进阶1:基础查询 /* 语法: select 查询列表 from 表名; 类似于:System.out.println(打印东西); 特点: 1.查询列表可以是:表中的字段.常量值.表达式.函数 2 ...
- Hibernate学习实例
一 Hibernate简介 Hibernate是一种Java语言下的对象关系映射(ORM)解决方案.为面向对象的领域模型到传统的关系型数据库的映射提供了一个使用方便的框架. 二 Hibernate设计 ...
- 杨辉三角的实现(Java)
杨辉三角的实现 一.什么是杨辉三角 杨辉三角是二项式系数在三角形中的一种几何排列.每个数等于它上方两数之和.每行数字左右对称,由1开始逐渐变大.第n行的数字有n项.前n行共[(1+n)n]/2 个数. ...
- N皇后求解。万万没想到,只用一个一维数组就搞定了。还体现了回溯。
一.啥是N皇后?先从四皇后入手 给定一个4x4的棋盘,要在棋盘上放置4个皇后.他们的位置有这样的要求,每一列,每一行,每一对角线都能有一个皇后. 你可能会对这个对角线有疑惑,其实就是每一个小正方形的对 ...
- Java例题_30 在已经排好序的数组中插入值
1 /*30 [程序 30 插入数字] 2 题目:有一个已经排好序的数组.现输入一个数,要求按原来的规律将它插入数组中. 3 程序分析:首先判断此数是否大于最后一个数,然后再考虑插入中间的数的情况,插 ...
- OMnet++ 初学者教程 第一节 入门
第1部分-入门 1.1模型 首先,让我们从一个包含两个节点的"network"开始.节点将做一些简单的事情:一个是节点将创建一个数据包,而两个节点将继续来回传递相同的数据包.我们将 ...
- 最短路径(Floyd算法)
声明:图片及内容基于https://www.bilibili.com/video/BV1oa4y1e7Qt?from=articleDetail 多源最短路径的引入 Floyd算法 原理 加入a: 加 ...
- markdown的基础语法
一级标题,一个#加空格 二级标题,两个#加空格 三级标题,三个#加空格 四级标题,四个#加空格 五级标题,五个#加空格 六级标题(最多支持到六级),六个#加空格 字体 粗体,两边加两个星号 斜体,两边 ...
- js 一数组分割成若干个数组,并装换成字符串赋个li标签
success: function (datas) { //请求成功后处理函数. var htmltext = ''; var data = datas.result; console.log(dat ...