Definition of virtual machine XML file in KVM

Source: Internet
Author: User

XML file content is to define the configuration information of domain in KVM, can be generated using virt-install, but need to specify each option, it is better to generate a basic XML or copy template to make corresponding changes.

The following is an explanation of the XML configuration for domain in KVM.

<!--  #提示信息WARNING: this is an auto-generated file. changes to  It are likely to be overwritten and lost. changes to this  xml configuration should be made using:  virsh edit  Win7-02or other application using the libvirt api.--><domain type= ' KVM ' >  #用kvm创建的虚拟机称为domain, type defines which hypervisor to use, values can be: Xen, KVM, Qemu, LXC, kqemu                      #第二个参数是id, It only identifies a running virtual machine, and the inactive client does not have an ID.    <name>win7-02</name>              #name参数为虚拟机定义了一个简短的名字, must be unique   <uuid>6ce14f21-33ac-dc79-5444-f64ccc80ea17</uuid >                    &nbsp, #uuid, the world's only, Linux can be generated with Uuidgen  <title>this is my first test kvm</ title>                      #title参数提供一个对虚拟机简短的说明, it cannot contain line breaks.   <memory unit= ' KiB ' >2097152</memory>                      #可以分配到的最大内存, the unit of memory is defined by the unit, which can be: K, KiB, M, MiB, G, GiB, T, TiB. The default is KiB. mib 2048 represents 2g  <currentmemory unit= ' KiB ' >2097152</currentMemory>                     # The memory actually assigned to the client she is smaller than the definition of memory, if not defined, the value and memory are consistent.   <vcpu placement= ' Static ' >1</vcpu>                      #vcpu的内容是为虚拟机最多分配几个cpu   < Os>&nbSp;   <type arch= ' x86_64 '  machine= ' rhel6.5.0 ' >hvm</type> #arch指定虚拟机的CPU构架, machine Specifies the type of machines. HVM indicates that the OS is designed to run directly on bare metal, requiring full virtualization.     <boot dev= ' cdrom '/>                  #dev属性的值可以是: The Elements of FD, HD, CDROM, Network,boot can be set up with multiple settings to establish a startup precedence rule.    </os>  <features>  #Hypervisor的特性: &NBSP;&NBSP;&NBSP;&NBSP;&LT;ACPI />   #Hypervisors允许特定的CPU/Machine features are turned on or off, all features are in the fearures element, and some of the tags commonly used in full virtualization are described below:     <apic/>   #acpi: for power management           <pae/>     #pae: Extend the physical address pattern so that 32-bit clients support more than 4GB of memory   </features>  <cpu mode= ' Host-passthrough ' >    <topology sockets= ' 1 '  cores= ' 4 '  threads= ' 1 '/ >  </cpu>    <on_poweroff>destroy</on_poweroff>   #当客户端请求poweroff时执行特定的动作   <on_reboot>restart</on_reboot>  # Perform a specific action   <on_crash>restart</on_crash>   #当客户端崩溃时执行的动作 when the client requests reboot  # Each state can allow the following four behaviors to be specified:          #destory: domain will be completely terminated and all resources of domain will be released           #restart: Domain will be terminated and then restarted with the same configuration            #preserver: Domain will be terminated and its resources will be retained for analysis            #rename-restart:domain will be terminated and then restarted with a new name   <clock offset= "LocalTime"  />           #客户端的时间初始化来自宿主机的时间, most operating systems expect the hardware clock to remain in UTC format, and UTC is the default format. However, the Windows machine expects it to be ' localtime '   #UTC: When booting the client clock synchronizes to the UTC clock          # LocalTime: When booting the client clock synchronizes to the time zone where the host clock is located           #timezone: the guest  clock will be synchronized to the requested timezone using the timezone  attribute   <devices>  #所有的设备都是一个名为devices元素的子设备     <emulator >/usr/libexec/qemu-kvm</emulator>        # The emulator element specifies the full path of the emulated device binary file     <disk type= ' file '  device= ' disk ' >       <driver name= ' qemu '  type= ' Qcow2 '/>       <source file= '/data/vmdisk/win7-02.qcow2 '/>      <target dev= ' Vda '  bus= ' virtio '/>      <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x04 '  function= ' 0x0 '/>    </disk>     <disk type= ' file '  device= ' cdrom ' >      < Driver name= ' qemu '  type= ' raw '/>&nbsP;     <source file= '/iso/win7.iso '/>       <target dev= ' HDA '  bus= ' IDE '/>      <readonly/>       <address type= ' drive '  controller= ' 0 '  bus= ' 0 '  target= ' 0 '   unit= ' 0 '/>    </disk>    <disk type= ' file '   Device= ' cdrom ' >      <driver name= ' qemu '  type= ' raw '/>       <source file= '/iso/virtio-win-0.1-100.iso '/>       <target dev= ' HDB '  bus= ' IDE '/>      <readonly/>       <address type= ' drive '  controller= ' 0 '  bus= ' 0 '  target = ' 0 '  unit= ' 1 '/>    </disk>    <disk type= ' file '  device= ' Floppy ' &Gt;      <driver name= ' qemu '  type= ' raw '/>       <source file= '/ISO/VIRTIO-WIN-0.1.96_AMD64.VFG '/>       <target dev= ' FDA '  bus= ' FDC '/>      <readonly/>       <address type= ' drive '  controller= ' 0 '  bus= ' 0 '  target= ' 0 '  unit= ' 0 '/>    </disk> #所有的设备看起来就像一个disk, floppy, CDROM or a   Paravirtualized driver, they are specified by a disk element. #type特性包括: File,block,dir,network,device Describes how disk is subject to the client OS, features include: Floppy, disk, CDROM, LUN, default is disk# SOURCE element: When disk's type is file, the file property specifies a qualified full-path file image as the client's disk, and when disk's type is block, the Dev property specifies the path of a host device as disk.     #在disk的type是dir时, the Dir property specifies a full-path directory as disk, and when disk's type is network, the Protocol property specifies the protocol used to access the mirror, the value of which can be: NBD, The Rbd,sheepdog#dev property indicates the actual name of the local disk on the client, because the actual device name designation does not guarantee that the device mapped to the Client OS #bus property specifies what type of disk is emulated, with the following values: IDE, SCSI, Virtio, Xen, USB, Sata#readonly element: Specify ClientThe device cannot be modified. When a disk contains type=cdrom,readonly, it is the default value. (Disk Virtio-win-0.1-100.iso and VIRTIO-WIN-0.1.96_AMD64.VFG are the driver files required for Windows, Linux series does not need to be defined)      <controller type= ' USB '  index= ' 0 ' >      <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x01 '  function= ' 0x2 '/>     </controller>    <controller type= ' IDE '  index= ' 0 ' >       <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x01 '   function= ' 0x1 '/>    </controller>    <controller type = ' FDC '  index= ' 0 '/>    <controller type= ' virtio-serial '  index= ' 0 ' >       <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot = ' 0x05 '  function= ' 0x0 '/>    </controller>     <interface type= ' bridge ' >   #类型桥接       <source  bridge= ' br0 '/>  #桥接的设备名字       <model type= ' Virtio '/>     </interface>     #串行端口 <serial type= ' file ' >       <source path= '/tmp/console.log '/>       <target port= ' 0 '/>    </serial>    <serial  Type= ' pty ' >      <target port= ' 1 '/>    </ Serial>    <console type= ' file ' >      < Source path= '/tmp/console.log '/>      <target type= ' serial '  port= ' 0 '/>    </console>    <channel type= ' Spicevmc ' >      <target type= ' virtio '  name= ' com.redhat.spice.0 '/>       <address type= ' virtio-serial '  controller= ' 0 '  bus= ' 0 '  port= ' 1 '/>     </channel>    <input type= ' tablet '  bus= ' USB '/>     <input type= ' mouse '  bus= ' PS2 '/>    # INPUT element: The INPUT element contains a mandatory property, the value of the Type property can be a mouse or Tablet#bus attribute specifying an explicit device type, the value can be: Xen, PS2, USB.  <graphics type= ' spice '  port= ' 6789 '  autoport= ' no '  listen= ' 0.0.0.0 '  keymap= ' En-US ' >      <listen type= ' address '  address= ' 0.0.0.0 '/>  #graphics元素: The graphics contains a mandatory property type,type value can be: SDL, VNC, RDP, Desktop, spice      < Channel name= ' main '  mode= ' insecure '/>      #vnc则启动vnc服务, the Port property specifies the TCP port, If it is-1, it is automatically assigned       <channel name= ' dIsplay '  mode= ' insecure '/>   #vnc的端口自动分配的话是从5900向上递增. The Listen property provides an IP address for the server to listen to, which can be set separately in the Listen element       <channel name= ' inputs '  mode= ' insecure '/>    #passwd属性提供一个vnc的密码       <channel  name= ' cursor '  mode= ' insecure '/>    #listen元素: Listen elements specifically for VNC and spice set listening ports        <channel name= ' playback '  mode= ' insecure '/>  #它包含以下属性: Type, Address, network. The value of type can be address or network.       <channel name= ' record '  mode= ' insecure '/>    #如果设置了type =address, then the Address property sets an IP address or host name to listen to.       <channel name= ' smartcard '  mode= ' insecure '/> #如果type =network , the Network property is set to a net name in the network configuration file of Libvirt ' s.       <channel name= ' usbredir '  mode= ' insecure '/>       <image compression= ' Auto_glz '/>      <streaming mode= ' all '/>       <clipboard copypaste= ' yes '/>    </graphics>     <video>      <model type= ' QXL '  ram= ' 65536 '   Vram= ' 65536 '  heads= ' 1 ' >        <acceleration accel3d= ' Yes '  accel2d= ' yes '/>      </model>       <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x02 '  function= ' 0x0 '/ >    </video>    <memballoon model= ' Virtio ' >       <address type= ' PCI '  domain= ' 0x0000 '  bus= ' 0x00 '  slot= ' 0x06 '  function= ' 0x0 '/>    </memballoon>  </devices></domain >   #video元素: Is the container that describes the sound device, in order to be fully compatible backwards, if no video is set but there is a graphics in the XML configuration file, then Libvirt will add a default video according to the client type 


This article from "Life is endless, struggle not only!" "Blog, be sure to keep this provenance http://linuxnote.blog.51cto.com/9876511/1881726

Definition of virtual machine XML file in KVM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.