KVM虚拟化管理工具之virtsh(一)

一、什么是virsh

virsh 是kvm一个管理工具包。virsh提供两种执行模式:”直接模式(Direct Mode)”与”互动模式(Interactive Mode)”。在直接模式里,你必须在Shell中以参数、自变量的方式来执行virsh,如果在互动模式中,则virsh会提供一个提示字符串, 你可以在该提示字符串后,输入要执行的命令。如果执行virsh没有指定任何参数或自变量则默认就是进入互动模式。 与xm一样,COMMAND也是 virsh提供的命令。

二、virsh 语法及参数

virsh命令有2使用方式,一种是在命令行上 virsh + [COMMAND](指令) +[ARGS…](具体参数)工作;另一种是直接在命令行输入virsh进入控制台通过[COMMAND](指令) +[ARGS…](具体参数)工作。需要注意的是virsh命令只能运行在Linux内核下的主机中,不能运行在windows操作系统中。

方法一:
[root@localhost ~]# virsh version
根据库编译:libvirt 4.5.0
使用库:libvirt 4.5.0
使用的 API: QEMU 4.5.0
运行管理程序: QEMU 1.5.3
方法二:
[root@localhost ~]# virsh 
欢迎使用 virsh,虚拟化的交互式终端。
输入:'help' 来获得命令的帮助信息
       'quit' 退出
virsh #  verison
根据库编译:libvirt 4.5.0
使用库:libvirt 4.5.0
使用的 API: QEMU 4.5.0
运行管理程序: QEMU 1.5.3

三、virsh 命令介绍

virsh 命令包含了domain(工作域),host(宿主机),interface(接口),network(网络), Node Device(节点设备),Snapshot(快照),Secret (安全性),Storage Pool (存储池),Storage Volume(存储卷)
通过 virsh --help 可以查询到:

virsh [options]... [<command_string>]
virsh [options]... <command> [args...]

  options:
    -c | --connect=URI      hypervisor connection URI
    -d | --debug=NUM        debug level [0-4]
    -e | --escape <char>    set escape sequence for console
    -h | --help             this help
    -k | --keepalive-interval=NUM
                            keepalive interval in seconds, 0 for disable
    -K | --keepalive-count=NUM
                            number of possible missed keepalive messages
    -l | --log=FILE         output logging to file
    -q | --quiet            quiet mode
    -r | --readonly         connect readonly
    -t | --timing           print timing information
    -v                      short version
    -V                      long version
         --version[=TYPE]   version, TYPE is short or long (default short)
  commands (non interactive mode):
 
 Domain Management (help keyword 'domain')
    attach-device                  从一个XML文件附加装置
    attach-disk                    附加磁盘设备
    attach-interface               获得网络界面
    autostart                      自动开始一个域
    blkdeviotune                   设定或者查询块设备 I/O 调节参数。
    blkiotune                      获取或者数值 blkio 参数
    blockcommit                    启动块提交操作。
    blockcopy                      启动块复制操作。
    blockjob                       管理活跃块操作
    blockpull                      使用其后端映像填充磁盘。
    blockresize                    创新定义域块设备大小
    change-media                   更改 CD 介质或者软盘驱动器
    console                        连接到客户会话
    cpu-stats                      显示域 cpu 统计数据
    create                         从一个 XML 文件创建一个域
    define                         从一个 XML 文件定义(但不开始)一个域
    desc                           显示或者设定域描述或者标题
    destroy                        销毁(停止)域
    detach-device                  从一个 XML 文件分离设备
    detach-device-alias            detach device from an alias
    detach-disk                    分离磁盘设备
    detach-interface               分离网络界面
    domdisplay                     域显示连接 URI
    domfsfreeze                    Freeze domain's mounted filesystems.
    domfsthaw                      Thaw domain's mounted filesystems.
    domfsinfo                      Get information of domain's mounted filesystems.
    domfstrim                      在域挂载的文件系统中调用 fstrim。
    domhostname                    输出域主机名
    domid                          把一个域名或 UUID 转换为域 id
    domif-setlink                  设定虚拟接口的链接状态
    domiftune                      获取/设定虚拟接口参数
    domjobabort                    忽略活跃域任务
    domjobinfo                     域任务信息
    domname                        将域 id 或 UUID 转换为域名
    domrename                      rename a domain
    dompmsuspend                   使用电源管理功能挂起域
    dompmwakeup                    从 pmsuspended 状态唤醒域
    domuuid                        把一个域名或 id 转换为域 UUID
    domxml-from-native             将原始配置转换为域 XML
    domxml-to-native               将域 XML 转换为原始配置
    dump                           把一个域的内核 dump 到一个文件中以方便分析
    dumpxml                        XML 中的域信息
    edit                           编辑某个域的 XML 配置
    event                          Domain Events
    inject-nmi                     在虚拟机中输入 NMI
    iothreadinfo                   view domain IOThreads
    iothreadpin                    control domain IOThread affinity
    iothreadadd                    add an IOThread to the guest domain
    iothreaddel                    delete an IOThread from the guest domain
    send-key                       向虚拟机发送序列号
    send-process-signal            向进程发送信号
    lxc-enter-namespace            LXC 虚拟机进入名称空间
    managedsave                    管理域状态的保存
    managedsave-remove             删除域的管理保存
    managedsave-edit               edit XML for a domain's managed save state file
    managedsave-dumpxml            Domain information of managed save state file in XML
    managedsave-define             redefine the XML for a domain's managed save state file
    memtune                        获取或者数值内存参数
    perf                           Get or set perf event
    metadata                       show or set domain's custom XML metadata
    migrate                        将域迁移到另一个主机中
    migrate-setmaxdowntime         设定最大可耐受故障时间
    migrate-getmaxdowntime         get maximum tolerable downtime
    migrate-compcache              获取/设定压缩缓存大小
    migrate-setspeed               设定迁移带宽的最大值
    migrate-getspeed               获取最长迁移带宽
    migrate-postcopy               Switch running migration from pre-copy to post-copy
    numatune                       获取或者数值 numa 参数
    qemu-attach                    QEMU 附加
    qemu-monitor-command           QEMU 监控程序命令
    qemu-monitor-event             QEMU Monitor Events
    qemu-agent-command             QEMU 虚拟机代理命令
    reboot                         重新启动一个域
    reset                          重新设定域
    restore                        从一个存在一个文件中的状态恢复一个域
    resume                         重新恢复一个域
    save                           把一个域的状态保存到一个文件
    save-image-define              为域的保存状态文件重新定义 XML
    save-image-dumpxml             在 XML 中保存状态域信息
    save-image-edit                为域保存状态文件编辑 XML
    schedinfo                      显示/设置日程安排变量
    screenshot                     提取当前域控制台快照并保存到文件中
    set-lifecycle-action           change lifecycle actions
    set-user-password              set the user password inside the domain
    setmaxmem                      改变最大内存限制值
    setmem                         改变内存的分配
    setvcpus                       改变虚拟 CPU 的号
    shutdown                       关闭一个域
    start                          开始一个(以前定义的)非活跃的域
    suspend                        挂起一个域
    ttyconsole                     tty 控制台
    undefine                       取消定义一个域
    update-device                  从 XML 文件中关系设备
    vcpucount                      域 vcpu 计数
    vcpuinfo                       详细的域 vcpu 信息
    vcpupin                        控制或者查询域 vcpu 亲和性
    emulatorpin                    控制火车查询域模拟器亲和性
    vncdisplay                     vnc 显示
    guestvcpus                     query or modify state of vcpu in the guest (via agent)
    setvcpu                        attach/detach vcpu or groups of threads
    domblkthreshold                set the threshold for block-threshold event for a given block device or it's backing chain element

 Domain Monitoring (help keyword 'monitor')
    domblkerror                    在块设备中显示错误
    domblkinfo                     域块设备大小信息
    domblklist                     列出所有域块
    domblkstat                     获得域设备块状态
    domcontrol                     域控制接口状态
    domif-getlink                  获取虚拟接口链接状态
    domifaddr                      Get network interfaces' addresses for a running domain
    domiflist                      列出所有域虚拟接口
    domifstat                      获得域网络接口状态
    dominfo                        域信息
    dommemstat                     获取域的内存统计
    domstate                       域状态
    domstats                       get statistics about one or multiple domains
    domtime                        domain time
    list                           列出域

 Host and Hypervisor (help keyword 'host')
    allocpages                     Manipulate pages pool size
    capabilities                   性能
    cpu-baseline                   计算基线 CPU
    cpu-compare                    使用 XML 文件中描述的 CPU 与主机 CPU 进行对比
    cpu-models                     CPU models
    domcapabilities                domain capabilities
    freecell                       NUMA可用内存
    freepages                      NUMA free pages
    hostname                       打印管理程序主机名
    hypervisor-cpu-baseline        compute baseline CPU usable by a specific hypervisor
    hypervisor-cpu-compare         compare a CPU with the CPU created by a hypervisor on the host
    maxvcpus                       连接 vcpu 最大值
    node-memory-tune               获取或者设定节点内存参数
    nodecpumap                     节点 cpu 映射
    nodecpustats                   输出节点的 cpu 状统计数据。
    nodeinfo                       节点信息
    nodememstats                   输出节点的内存状统计数据。
    nodesuspend                    在给定时间段挂起主机节点
    sysinfo                        输出 hypervisor sysinfo
    uri                            打印管理程序典型的URI
    version                        显示版本

 Interface (help keyword 'interface')
    iface-begin                    生成当前接口设置快照,可在今后用于提交 (iface-commit) 或者恢复 (iface-rollback)
    iface-bridge                   生成桥接设备并为其附加一个现有网络设备
    iface-commit                   提交 iface-begin 后的更改并释放恢复点
    iface-define                   define an inactive persistent physical host interface or modify an existing persistent one from an XML file
    iface-destroy                  删除物理主机接口(启用它请执行 "if-down")
    iface-dumpxml                  XML 中的接口信息
    iface-edit                     为物理主机界面编辑 XML 配置
    iface-list                     物理主机接口列表
    iface-mac                      将接口名称转换为接口 MAC 地址
    iface-name                     将接口 MAC 地址转换为接口名称
    iface-rollback                 恢复到之前保存的使用 iface-begin 生成的更改
    iface-start                    启动物理主机接口(启用它请执行 "if-up")
    iface-unbridge                 分离其辅助设备后取消定义桥接设备
    iface-undefine                 取消定义物理主机接口(从配置中删除)

 Network Filter (help keyword 'filter')
    nwfilter-define                使用 XML 文件定义或者更新网络过滤器
    nwfilter-dumpxml               XML 中的网络过滤器信息
    nwfilter-edit                  为网络过滤器编辑 XML 配置
    nwfilter-list                  列出网络过滤器
    nwfilter-undefine              取消定义网络过滤器
    nwfilter-binding-create        create a network filter binding from an XML file
    nwfilter-binding-delete        delete a network filter binding
    nwfilter-binding-dumpxml       XML 中的网络过滤器信息
    nwfilter-binding-list          list network filter bindings

 Networking (help keyword 'network')
    net-autostart                  自动开始网络
    net-create                     从一个 XML 文件创建一个网络
    net-define                     define an inactive persistent virtual network or modify an existing persistent one from an XML file
    net-destroy                    销毁(停止)网络
    net-dhcp-leases                print lease info for a given network
    net-dumpxml                    XML 中的网络信息
    net-edit                       为网络编辑 XML 配置
    net-event                      Network Events
    net-info                       网络信息
    net-list                       列出网络
    net-name                       把一个网络UUID 转换为网络名
    net-start                      开始一个(以前定义的)不活跃的网络
    net-undefine                   undefine a persistent network
    net-update                     更新现有网络配置的部分
    net-uuid                       把一个网络名转换为网络UUID

 Node Device (help keyword 'nodedev')
    nodedev-create                 根据节点中的 XML 文件定义生成设备
    nodedev-destroy                销毁(停止)节点中的设备
    nodedev-detach                 将节点设备与其设备驱动程序分离
    nodedev-dumpxml                XML 中的节点设备详情
    nodedev-list                   这台主机中中的枚举设备
    nodedev-reattach               重新将节点设备附加到他的设备驱动程序中
    nodedev-reset                  重置节点设备
    nodedev-event                  Node Device Events

 Secret (help keyword 'secret')
    secret-define                  定义或者修改 XML 中的 secret
    secret-dumpxml                 XML 中的 secret 属性
    secret-event                   Secret Events
    secret-get-value               secret 值输出
    secret-list                    列出 secret
    secret-set-value               设定 secret 值
    secret-undefine                取消定义 secret

 Snapshot (help keyword 'snapshot')
    snapshot-create                使用 XML 生成快照
    snapshot-create-as             使用一组参数生成快照
    snapshot-current               获取或者设定当前快照
    snapshot-delete                删除域快照
    snapshot-dumpxml               为域快照转储 XML
    snapshot-edit                  编辑快照 XML
    snapshot-info                  快照信息
    snapshot-list                  为域列出快照
    snapshot-parent                获取快照的上级快照名称
    snapshot-revert                将域转换为快照

 Storage Pool (help keyword 'pool')
    find-storage-pool-sources-as   找到潜在存储池源
    find-storage-pool-sources      发现潜在存储池源
    pool-autostart                 自动启动某个池
    pool-build                     建立池
    pool-create-as                 从一组变量中创建一个池
    pool-create                    从一个 XML 文件中创建一个池
    pool-define-as                 在一组变量中定义池
    pool-define                    define an inactive persistent storage pool or modify an existing persistent one from an XML file
    pool-delete                    删除池
    pool-destroy                   销毁(删除)池
    pool-dumpxml                   XML 中的池信息
    pool-edit                      为存储池编辑 XML 配置
    pool-info                      存储池信息
    pool-list                      列出池
    pool-name                      将池 UUID 转换为池名称
    pool-refresh                   刷新池
    pool-start                     启动一个(以前定义的)非活跃的池
    pool-undefine                  取消定义一个不活跃的池
    pool-uuid                      把一个池名称转换为池 UUID
    pool-event                     Storage Pool Events

 Storage Volume (help keyword 'volume')
    vol-clone                      克隆卷。
    vol-create-as                  从一组变量中创建卷
    vol-create                     从一个 XML 文件创建一个卷
    vol-create-from                生成卷,使用另一个卷作为输入。
    vol-delete                     删除卷
    vol-download                   将卷内容下载到文件中
    vol-dumpxml                    XML 中的卷信息
    vol-info                       存储卷信息
    vol-key                        为给定密钥或者路径返回卷密钥
    vol-list                       列出卷
    vol-name                       为给定密钥或者路径返回卷名
    vol-path                       为给定密钥或者路径返回卷路径
    vol-pool                       为给定密钥或者路径返回存储池
    vol-resize                     创新定义卷大小
    vol-upload                     将文件内容上传到卷中
    vol-wipe                       擦除卷

 Virsh itself (help keyword 'virsh')
    cd                             更改当前目录
    echo                           echo 参数
    exit                           退出这个非交互式终端
    help                           打印帮助
    pwd                            输出当前目录
    quit                           退出这个非交互式终端
    connect                        连接(重新连接)到 hypervisor

四、virsh常用命令介绍

4.1 host(宿主机相关)

4.1.1 hostname

virsh hostname 显示宿主机的机器名

[root@localhost ~] virsh hostname
localhost.localdomain

4.1.2 maxvcpus

virsh maxvcpus 显示宿主机最大可提供分配的虚拟cpu的总数,也就是一台机器下所有虚拟机的vcpu个数之和不能大于这个参数。

[root@localhost ~] virsh maxvcpus
240

4.1.3 version

virsh version 显示libvirt及qemu对应的版本信息

[root@localhost ~] virsh version
根据库编译:libvirt 4.5.0
使用库:libvirt 4.5.0
使用的 API: QEMU 4.5.0
运行管理程序: QEMU 1.5.3

4.1.4 sysinfo

virsh sysinfo 显示宿主机的硬件信息

[root@localhost ~] virsh sysinfo
<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>American Megatrends Inc.</entry>
    <entry name='version'>0602</entry>
    <entry name='date'>12/09/2014</entry>
    <entry name='release'>4.6</entry>
  </bios>
  <system>
    <entry name='manufacturer'>ASUS</entry>
    <entry name='product'>All Series</entry>
    <entry name='version'>System Version</entry>
    <entry name='serial'>System Serial Number</entry>
    <entry name='uuid'>2198b9a0-d7da-11dd-8b03-086266276416</entry>
    <entry name='sku'>All</entry>
    <entry name='family'>ASUS MB</entry>
  </system>
  <baseBoard>
    <entry name='manufacturer'>ASUSTeK COMPUTER INC.</entry>
    <entry name='product'>Z97-K R2.0</entry>
    <entry name='version'>Rev X.0x</entry>
    <entry name='serial'>141236867304293</entry>
    <entry name='asset'>To be filled by O.E.M.</entry>
    <entry name='location'>To be filled by O.E.M.</entry>
  </baseBoard>
  <chassis>
    <entry name='manufacturer'>To Be Filled By O.E.M.</entry>
    <entry name='version'>To Be Filled By O.E.M.</entry>
    <entry name='serial'>To Be Filled By O.E.M.</entry>
    <entry name='asset'>To Be Filled By O.E.M.</entry>
    <entry name='sku'>To be filled by O.E.M.</entry>
  </chassis>
  <processor>
    <entry name='socket_destination'>SOCKET 1150</entry>
    <entry name='type'>Central Processor</entry>
    <entry name='family'>Other</entry>
    <entry name='manufacturer'>Intel</entry>
    <entry name='version'>Intel(R) Xeon(R) CPU E3-1230 v3 @ 3.30GHz</entry>
    <entry name='external_clock'>100 MHz</entry>
    <entry name='max_speed'>3900 MHz</entry>
    <entry name='status'>Populated, Enabled</entry>
    <entry name='serial_number'>Not Specified</entry>
    <entry name='part_number'>Fill By OEM</entry>
  </processor>
  <memory_device>
    <entry name='size'>4096 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_A1</entry>
    <entry name='bank_locator'>BANK 0</entry>
    <entry name='type'>DDR3</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1600 MT/s</entry>
    <entry name='manufacturer'>Kingston</entry>
    <entry name='serial_number'>8A3A040F</entry>
    <entry name='part_number'>99P5474-013.A00LF</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_A2</entry>
    <entry name='bank_locator'>BANK 1</entry>
    <entry name='type'>DDR3</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1600 MT/s</entry>
    <entry name='manufacturer'>0622</entry>
    <entry name='serial_number'>00000000</entry>
    <entry name='part_number'>DDR3-1600 CL11 8GB</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>4096 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_B1</entry>
    <entry name='bank_locator'>BANK 2</entry>
    <entry name='type'>DDR3</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1600 MT/s</entry>
    <entry name='manufacturer'>Kingston</entry>
    <entry name='serial_number'>853A080F</entry>
    <entry name='part_number'>99P5474-013.A00LF</entry>
  </memory_device>
</sysinfo>

4.1.5 capabilities

virsh capabilities 以XML文件格式显示当前虚拟环境的性能参数

[root@localhost ~] virsh capabilities
<capabilities>
  <host>        
    <uuid>2198b9a0-d7da-11dd-8b03-086266276416</uuid>   
    <cpu>     
      <arch>x86_64</arch>
      <model>Haswell-noTSX-IBRS</model>
      <vendor>Intel</vendor>
      <microcode version='39'/>
      <counter name='tsc' frequency='3298088000' scaling='no'/>
      <topology sockets='1' cores='4' threads='2'/>
      <feature name='vme'/>
      <feature name='ds'/>
      <feature name='acpi'/>
      <feature name='ss'/>
      <feature name='ht'/>
      <feature name='tm'/>
      <feature name='pbe'/>
      <feature name='dtes64'/>
      <feature name='monitor'/>
      <feature name='ds_cpl'/>
      <feature name='vmx'/>
      <feature name='smx'/>
      <feature name='est'/>
      <feature name='tm2'/>
      <feature name='xtpr'/>
      <feature name='pdcm'/>
      <feature name='osxsave'/>
      <feature name='f16c'/>
      <feature name='rdrand'/>
      <feature name='arat'/>
      <feature name='tsc_adjust'/>
      <feature name='md-clear'/>
      <feature name='stibp'/>
      <feature name='ssbd'/>
      <feature name='xsaveopt'/>
      <feature name='pdpe1gb'/>
      <feature name='abm'/>
      <feature name='invtsc'/>
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='2048'/>
      <pages unit='KiB' size='1048576'/>
    </cpu>
    <power_management>      
      <suspend_mem/>
      <suspend_disk/>
      <suspend_hybrid/>
    </power_management>
    <iommu support='no'/>
    <migration_features>   
      <live/>
      <uri_transports>
        <uri_transport>tcp</uri_transport>
        <uri_transport>rdma</uri_transport>
      </uri_transports>
    </migration_features>
    <topology>    
      <cells num='1'>
        <cell id='0'>
          <memory unit='KiB'>24464364</memory>
          <pages unit='KiB' size='4'>6116091</pages>
          <pages unit='KiB' size='2048'>0</pages>
          <pages unit='KiB' size='1048576'>0</pages>
          <distances>
            <sibling id='0' value='10'/>
          </distances>
          <cpus num='8'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0,4'/>
            <cpu id='1' socket_id='0' core_id='1' siblings='1,5'/>
            <cpu id='2' socket_id='0' core_id='2' siblings='2,6'/>
            <cpu id='3' socket_id='0' core_id='3' siblings='3,7'/>
            <cpu id='4' socket_id='0' core_id='0' siblings='0,4'/>
            <cpu id='5' socket_id='0' core_id='1' siblings='1,5'/>
            <cpu id='6' socket_id='0' core_id='2' siblings='2,6'/>
            <cpu id='7' socket_id='0' core_id='3' siblings='3,7'/>
          </cpus>
        </cell>
      </cells>
    </topology>
    <cache>
      <bank id='0' level='3' type='both' size='8' unit='MiB' cpus='0-7'/>
    </cache>
    
    <secmodel> 
      <model>none</model>
      <doi>0</doi>
    </secmodel>
    <secmodel>
      <model>dac</model>
      <doi>0</doi>
      <baselabel type='kvm'>+107:+107</baselabel>
      <baselabel type='qemu'>+107:+107</baselabel>
    </secmodel>
  </host>

  <guest>
    <os_type>hvm</os_type>  
    <arch name='i686'>  
      <wordsize>32</wordsize>  
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
      <machine canonical='pc-i440fx-rhel7.0.0' maxCpus='240'>pc</machine> 
      <machine maxCpus='240'>rhel6.0.0</machine>
      <machine maxCpus='240'>rhel6.1.0</machine>
      <machine maxCpus='240'>rhel6.2.0</machine>
      <machine maxCpus='240'>rhel6.3.0</machine>
      <machine maxCpus='240'>rhel6.4.0</machine>
      <machine maxCpus='240'>rhel6.5.0</machine>
      <machine maxCpus='240'>rhel6.6.0</machine>
      <domain type='qemu'/> 
      <domain type='kvm'>
        <emulator>/usr/libexec/qemu-kvm</emulator>
      </domain>
    </arch>
    <features>
      <cpuselection/>
      <deviceboot/>
      <disksnapshot default='off' toggle='no'/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>
      <pae/>
      <nonpae/>
    </features>
  </guest>

  <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
      <machine canonical='pc-i440fx-rhel7.0.0' maxCpus='240'>pc</machine>
      <machine maxCpus='240'>rhel6.0.0</machine>
      <machine maxCpus='240'>rhel6.1.0</machine>
      <machine maxCpus='240'>rhel6.2.0</machine>
      <machine maxCpus='240'>rhel6.3.0</machine>
      <machine maxCpus='240'>rhel6.4.0</machine>
      <machine maxCpus='240'>rhel6.5.0</machine>
      <machine maxCpus='240'>rhel6.6.0</machine>
      <domain type='qemu'/>
      <domain type='kvm'>
        <emulator>/usr/libexec/qemu-kvm</emulator>
      </domain>
    </arch>
    <features>
      <cpuselection/>
      <deviceboot/>
      <disksnapshot default='off' toggle='no'/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>
    </features>
  </guest>
</capabilities>

4.2 capabilities XML文件解释

4.2.1 host(宿主机相关配置)
标签名作用父级标签
host宿主机相关功能元素顶级标签
guest来宾相关功能元素顶级标签
uuid表明宿主机的UUIDhost
cpu主机CPU的体系结构和功能host
power_management主机是否能够进行内存挂起"suspend_mem",磁盘休眠"suspend_disk"或混合挂起"suspend_hybrid"host
migration公开有关虚拟机管理程序迁移功能的信息host
topology该元素体现了主机内部拓扑。例如,由于减少了NUMA之间的节点传输,管理应用程序可能希望在组织新的来宾时学习此信息host
secmodel要找出不同安全模型的默认安全标签,您需要解析此元素。与以前的元素相比,对于libvirt守护程序当前支持的每个安全模型,都重复此操作。host
arch操作系统架构类型,x86_64、i386、i486、i586、alpha、sparc、arm、m68k、mips、ppc、i686等cpu
modelqemu中cpu虚拟化支持的类型,如果在迁移虚拟机过程中,遇到cpu虚拟化支持的类型不匹配会导致虚拟机无法正常启动cpu
vendor生产所属公司cpu
microcodecpu 微代码版本号cpun必备的 详细请查阅 microcodecpu
countername=‘tsc’ frequency=‘3298088000’ scaling=‘no’ ,TSC代表是Time Stamp Counter,frequency代表最大计数值,scaling 详见TSC官方文档cpu
topologyCPU拓扑及结构,常常以sockets='1’1、 cores=‘4’ threads=‘2’,sockets代表路,cores代表核,threads代表超线程数(单颗)cpu
featurecpu支持的一些特性,通常有vme,ss,acpi等cpu
cachecpu缓存相关配置cpu
pages内存页所支持的单位大小cpu
iommu辅助虚拟化 vt-x PCI透传是否开启host
suspend_mem内存挂机power_management
suspend_disk硬盘休眠power_management
suspend_hybrid混合挂起power_management
live支持在线迁移migration_features
uri_transports支持的迁移方式tcp,rdmamigration_features
topology宿主机所有CPU及内存相关参数host
cells实际CPU的数量topology
memory宿主机内存总量topology
pages内存页使用数topology
distancescpu 之间的NUMA之间访问内存的优先级cpus
cpuscpu 总数量cpus
cpucpu核数绑定关系cpus
cachecpu缓存相关参数topology
model支持的安全模式secmodel
doi安全表示符secmodel
4.2.2 guest(来宾相关配置)
标签名作用父级标签
os_type管理程序能够运行哪种操作系统:xen、linux、xenpvh、hvm、exeguest
arch架构类型guest
wordsizeCPU字的大小arch
emulator仿真模拟器的位置arch
machine机器类型,用于 域XML中os / type元素的机器属性。例如,Xen支持xenfvHVM,xenpvPV或xenpvhPVH。arch
domain指定运行域所需的系统管理程序的类型arch
features可选元素包含可与所描述类型的来宾一起使用的可能功能guest
cpuselection如果存在此元素,则管理程序将在域定义中支持该元素,以对提供给来宾的CPU进行细粒度控制。从0.7.5开始features
deviceboot如果存在此元素,则可以在设备内部使用该元素,而不是按类别使用较早的引导规范。从0.8.8开始features
disksnapshot如果存在此元素,则default属性描述是否支持外部磁盘快照。如果不存在,可能仍支持外部快照,但是它需要尝试API并检查错误以确保确定。从1.2.3开始features
acpi如果存在此元素,则default属性描述默认情况下管理程序是否向访客公开ACPI,并且toggle属性描述用户是否可以覆盖此默认值。从0.4.1开始features
apic如果存在此元素,则该default属性描述默认情况下管理程序是否向访客公开APIC,并且该toggle属性描述用户是否可以覆盖此默认值。从0.4.1开始features
ia64_be如果存在,则从0.4.1开始,IA64 guest虚拟机可以在大端模式下运行。features
pae从0.4.1开始,如果存在,则32位guest 虚拟机可以使用PAE地址空间扩展。features
nonpae如果存在,则从0.4.1开始,无需PAE即可运行32位guest 虚拟机。features

4.3 sysinfo XML文件解释

标签名作用父级标签
sysinfo设备信息,type=smbios 表示允许来宾主机使用和修改的信息顶级
biosbios信息sysinfo
system系统信息sysinfo
baseBoard主板信息sysinfo
chassis机箱信息sysinfo
processor处理器相关信息sysinfo
memory_device内存相关信息sysinfo
  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值