【Virtualization】Virtual machine xml file parsing

Virtual machine xml file parsing

name

name	# 虚拟机名称,具有唯一性,不可与已建立的虚拟机重复

uuid

uuid	#虚拟机ID,通常在新建虚拟机时自动生成,可自行设定,不可重复

memory/currentMemory

Virtual machine memory, the default unit is KB. It is specified when creating a new virtual machine, and can also be modified by itself. After modification, the virtual machine needs to be redefined, and it cannot exceed the free memory of the physical machine.

<memory unit='G'>4</memory>
<currentMemory unit='G'>4</currentMemory>

vcpu

It is the number of virtual machine CPUs. It is specified when creating a virtual machine or is set by default according to the system version. It can be modified by itself. After modification, the virtual machine needs to be redefined. If the virtual machine needs to run stress tests and other resource-consuming processes, it needs to be the host machine. Reserve enough CPU to avoid system crash

<vcpu placement='static'>2</vcpu>

boot

It is the startup location of the virtual machine. After the system is installed, it is usually set to hd, that is, it starts from the hard disk.

Other options include cdrom (boot via CD-ROM or image), pxe (boot via network), nfs, ftp, etc.

<os>
    <type arch='x86_64' machine='pc-i440fx-4.1'>hvm</type>
    <boot dev='hd'/>
</os>

cpu

Virtual machine cpu mode, the default is host-model, check the system support configuration and modify it to the corresponding configuration.

The nested virtualization configuration is host-passthrough, and the virtual machine needs to be redefined after modification

<cpu mode='host-passthrough' check='none'/>

on_poweroff

on_poweroff, on_reboot, on_crash: set the response of the virtual machine when the corresponding situation occurs. The default action is poweroff shutdown, reboot restart, and crash shutdown when the system crashes.

on_poweroff and on_reboot are not interchangeable, that is, on_reboot cannot be set to destroy while on_poweroff is set to restart.

<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

Configurations supported by on_poweroff:

# 指定了 guest 请求断电时执行的操作。可选值有
<on_poweroff>destroy</on_poweroff> # domain 将被完全终止并释放所有资源。
<on_poweroff>restart</on_poweroff> #domain 将被终止,然后使用相同的配置重新启动。
<on_poweroff>preserve</on_poweroff> #domain 将被终止,其资源将被保留以便进行分析。

on_reboot

Configurations supported by on_reboot:

# 指定了 guest 请求重启时执行的操作。可选值有
<on_reboot>destroy</on_reboot> # domain 将被完全终止并释放所有资源。
<on_reboot>restart</on_reboot> #domain 将被终止,然后使用相同的配置重新启动。
<on_reboot>preserve</on_reboot> #domain 将被终止,其资源将被保留以便进行分析。

on_crash

System crash handling [Because arm does not support related monitoring hardware, the on_crush setting is not applicable on arm]

To make the on_crush event settings take effect, the following hardware needs to be added to the xml file:

<devices>
    <panic model='isa'>
    </panic>
</devices>

Configurations supported by on_crush:

# 指定了 guest 请求断电时执行的操作。可选值有
<on_crush>destroy</on_crush> # domain 将被完全终止并释放所有资源。
<on_crush>restart</on_crush> #domain 将被终止,然后使用相同的配置重新启动。
<on_crush>preserve</on_crush> #domain 将被终止,其资源将被保留以便进行分析。
# 还支持额外的两个操作
<on_cursh>coredump-destroy</on_cursh> # 崩溃 domain 的核心将被转储,然后 domain 将被完全终止并释放所有资源。
<on_cursh>coredump-restart</on_cursh> # 崩溃 domain 的核心将被转储,然后 domain 将使用相同的配置重新启动

disk

Configured for storage devices. Disk files and virtual CD-ROM are configured in this item.

Disk bus type support: IDE/scsi/usb/virtio

Disk image format support: raw/qcow2

# 磁盘文件
<disk type='file' device='disk'>
  <driver name='qemu' type='qcow2' cache='none'/>
  <source file='/cyq-data/images/test.qcow2'/>
  <target dev='vda' bus='virtio'/>
</disk>

# 虚拟光驱
<disk type='file' device='cdrom'>
    <driver name='qemu' type='raw'/>
    <source file='/iso/Kylin-Server-10-Host-x86_64-Build02-20220627.iso'/>
    <target dev='hdb' bus='ide'/>
    <readonly/>
    <address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>

interface

Network configuration, type configuration supports bridge, nat, etc.

The network bridge needs to configure the bridge network card in the host in advance, which is expressed as bridge in the configuration file, that is, interface type='bridge', and defines the bridge network card, that is, source bridge='my-br', where my-br is the sink The bridge network card established in the host.

The mac address is usually automatically generated or specified, but as a virtual machine, the first three segments of the mac address must be 52:54:00.

model type is the network card driver loaded by the virtual machine, supporting e1000, rt18139, virtio, etc., written as follows

<interface type='network'>
    <mac address='52:54:34:4d:b4:e0'/>
    <source network='default'/>
    <model type='virtio'/>
</interface>

input

Define the input device of the virtual machine, which can usually be automatically generated. If it is not generated, the following line can be added. Note that the port cannot be repeated

The tablet is a digital board, the keyboard is a keyboard, the mouse is a mouse, and the tablet is used as a mouse.

# 数位板
<input type='tablet' bus='usb'>
    <address type='usb' bus='0' port='3'/>
</input>

# 键盘
<input type='keyboard' bus='usb'>
    <address type='usb' bus='0' port='4'/>
</input>

graphics

Graphically configure virtual machines.

It is usually set to vnc for remote connection, where the port cannot be repeated, passwd is the access password, which must be set, listen sets the listening port, and is usually set to 0.0.0.0, which means listening to all ports of the machine.

When it is set to vnc, autoport needs to be set to no, listen type is configured to address, and address is defined as 0.0.0.0.

<graphics type='vnc' port='5925'  autoport='no' passwd='qwer1234' listen='0.0.0.0'>
    <listen type='address' address='0.0.0.0'/>
</graphics>

Supplementary Note

1. Disk bus type

There is no direct connection between the virtual machine disk bus type and the physical machine disk bus type

Virtual machine: disk bus type support: IDE / scsi / /virtio

insert image description here

Guess you like

Origin blog.csdn.net/Sanayeah/article/details/131539527