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 ...
随机推荐
- .NET 5下的Blazor是否可以大规模正式使用?
今天在微信群讨论了很多Blazor是否可以正常用的问题.大家争的面红耳赤的. 于是趁着无聊,就水了这么一篇文. 还记得Blazor还在预览版的时候,我就开始关注Blazor了. 那会儿调试Blazor ...
- 【python+selenium的web自动化】- 元素的常用操作详解(一)
如果想从头学起selenium,可以去看看这个系列的文章哦! https://www.cnblogs.com/miki-peng/category/1942527.html 本篇主要内容:1.元素 ...
- BeanShell 用法汇总
一.什么是Bean Shell BeanShell是一种完全符合Java语法规范的脚本语言,并且又拥有自己的一些语法和方法; BeanShell是一种松散类型的脚本语言(这点和JS类似); BeanS ...
- Oracle dg下掉一个从库
1.在数据库中查找要下线的从库 SQL> show parameter log_archive_dest NAME TYPE VALUE----------------------------- ...
- java注解基础入门
前言 这篇博客主要是对java注解相关的知识进行入门级的讲解,包括**,核心内容主要体现在对java注解的理解以及如何使用.希望通过写这篇博客的过程中让自己对java注解有更深入的理解,在工作中可以巧 ...
- Git - 使用命令和P4Merge进行diff
P4Merge P4Merge是Git的一个第三发Diff和Merge工具(可视化冲突解决工具). 下载地址: https://www.perforce.com/downloads/visual-me ...
- time模块&datetime模块
import time a=time.localtime(time.time()) #将时间戳转换为当前时区的元组 print(a) c=time.gmtime(time.time()) #把时间戳转 ...
- Android学习之启动活动的最佳写法
•开始热身 通过之前的学习,我们现在可以很容易的启动一个活动: 首先通过 Intent 构造出当前的 "意图",然后调用 startActivity() 方法将活动启动起来: ...
- Java 并发编程 Executor 框架
本文部分摘自<Java 并发编程的艺术> Excutor 框架 1. 两级调度模型 在 HotSpot VM 的线程模型中,Java 线程被一对一映射为本地操作系统线程.在上层,Java ...
- [图论]最短路径问题 :Floyed-Warshall
最短路径问题 目录 最短路径问题 Description Input Output Sample Input Sample Output 解析 了解Floyed算法 Floyed算法的核心思想: 代码 ...