Detailed explanation of the configuration xml code in the KVM virtual machine

Y2J
Release: 2017-04-24 09:17:34
Original
3115 people have browsed it

In RHEL6, the XML file used to boot from disk

Here is dcs01.xml as an example:

 
dcs01
e5fff551-bbe1-e748-c8e4-8ecb3bffb902
1048576
1048576
1

hvm








destroy
restart
restart

/usr/libexec/qemu-kvm




Copy after login

Comments are as follows:

 1. Kvm guest definition starts

Copy after login

 2. Short name of guest. It consists of letters and numbers and cannot contain spaces

dcs01
Copy after login

 3. uuid, generated by the command line tool uuidgen.

e5fff551-bbe1-e748-c8e4-8ecb3bffb902
Copy after login

4. The maximum memory that the guest can use without rebooting the guest, in KB.

1048576
Copy after login

5. The memory when the guest starts can be passed Use virsh setmem to adjust the memory, but it cannot be larger than the maximum usable memory.

1048576
Copy after login

6. Assigned virtual cpu

1
Copy after login

7. Related OS
architecture: i686, x86_64
machine: host operating system
boot: Specify the boot device. You can repeat multiple lines and specify different values ​​as a boot device list.


hvm

Copy after login

8. Processor features





Copy after login

9. Clock. Use local time: localtime

Copy after login

10. Define the default actions when power off, reboot, or crash in the kvm environment are destroy and restart respectively. Other allowed actions include: preserve, rename-restart.
destroy: Stop the virtual machine. Equivalent to turning off the power.
restartRestart the virtual machine.

destroy
restart
restart
Copy after login

 11. Start of device definition

Copy after login

 12. Simulation element, the writing method here is used for guest

/usr/libexec/qemu-kvm
Copy after login

 13. File used for kvm storage. In this example, it appears as an IDE device in the guest.
Use the qemu-img command to create this file. The default directory of kvm image is: /var/lib/libvirt/images/





Copy after login

Supplement: Multiple disks can be defined.
Use virtio:
Use an ordinary driver, that is, when both the hard disk and the network card adopt the default configuration, the network card works under the simulated rtl 8139 network card, and the speed is 100M full duplex. After using the virtio driver, the network card works in 1000M mode.

Use an ordinary driver, that is, when both the hard disk and the network card adopt the default configuration, the hard disk is in IDE mode. After using the virtio driver, the hard disk works in SCSI mode.





Copy after login

CD-ROM device:





Copy after login

14. Use the bridge type. Make sure each kvm guest's mac address is unique. A tun device will be created with the name vnetx (x is 0,1,2...)




Copy after login

Supplement:
Use the default virtual network instead of the bridge, that is, the guest is in NAT mode. You can also omit the mac address element, so the mac address will be automatically generated.




Copy after login

The address 192.168.122.x/24 is assigned by default, and can also be specified manually. The gateway is 192.168.122.1

Use virtio:
Use an ordinary driver, that is, when the hard disk and network card are both configured in the default configuration, the network card works under the simulated rtl 8139 network card, with a speed of 100M. duplex. After using the virtio driver, the network card works in 1000M mode.




Copy after login

15. Input device


Copy after login

16. Define the graphics device that interacts with guset. In this example, the vnc protocol is used. The address of listen is the address of host. prot is -1, which means the port number is automatically assigned. Use the following command to find the port number:
virsh vncdisplay

It is not set here

Copy after login

 17 , Device definition ends

Copy after login

18. KVM definition ends

Copy after login

centos_x86_6.4
b9dcdd92-9b9b-14d6-3938-1982a9746a12
2097152
2097152
1
hvm
destroy
restart
restart
/bin/qemu-kvm

  
      
Copy after login

#The destination mirror path in this example, Shown as IDE device in guest.​


        
      
      
      
      
Copy after login

#Virtual machine network connection method

 
      
      
Copy after login

## Use virtio: Use an ordinary driver, that is, when both the hard disk and the network card adopt the default configuration, the hard disk is in ide mode, and the network card works under the simulated rtl 8139 network card, with a speed of 100M full duplex . After using the virtio driver, the network card works in 1000M mode, and the hard disk works in SCSI mode.


      
      
Copy after login

#Log in with vnc, the port number is automatically assigned. You can query [vncdisplay domainId] through virsh vncdisplay


      
    
    
Copy after login


The above is the detailed content of Detailed explanation of the configuration xml code in the KVM virtual machine. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!