In RHEL6, www.educity.cnlinux1148549.html uses dcs01.xml as an example: & lt; domaintypekvm & gt; & lt; name & gt; dcs01 & lt; name & gt; & lt; uuid & gt; e5fff551-bbe1-e748-c8e4-8ecb .. in RHEL6, the XML file used to start from the disk
The following uses dcs01.xml as an example:
dcs01
e5fff551-bbe1-e748-c8e4-8ecb3bffb902
1048576
1048576
1
hvm
destroy
restart
restart
/usr/libexec/qemu-kvm
Note:
1. kvm guest definition starts
2. short name of guest. It consists of letters and numbers and cannot contain spaces.
dcs01
3. uuid, which is generated by the command line tool uuidgen.
e5fff551-bbe1-e748-c8e4-8ecb3bffb902
4. maximum memory that can be used by guset without reboot guest, in KB
1048576
5. when guest is started, the memory can be adjusted through virsh setmem, but it cannot be greater than the maximum available memory.
1048576
6. allocated virtual cpu
1
7. related OS
Architecture: i686 and x86_64
Machine: host operating system
Boot: specify the boot device. you can repeat multiple lines and specify different values as a list of boot devices.
hvm
8. Processor features
9. clock. Use local time: localtime
10. defines the default actions for power off, reboot, or crash in the kvm environment: destroy and restart. Other permitted actions include: preserve, rename-restart ..
Destroy: stop the VM. Power off.
Restart to restart the VM.
destroy
restart
restart
11. device definition starts
12. simulate elements. the command is used for kvm guest.
/usr/libexec/qemu-kvm
13. files used for kvm storage. In this example, it is displayed as an IDE device in guest.
Use the qemu-img command to create the file. the default directory of kvm image is/var/lib/libvirt/images/
Supplement: multiple disks can be defined.
Use virtio:
The common driver is used, that is, the hard disk and the network card are configured by default. The network card works under the simulated rtl 8139 network card and the speed is 100 MB. After the virtio driver is used, the NIC works in 1000 M mode.
The general driver is used, that is, the hard disk and network card are configured by default, and the hard disk is in ide mode. After the virtio driver is used, the hard disk works in SCSI mode.
CD-ROM device:
14. use the bridge type. Ensure that the mac address of each kvm guest is unique. Create a tun device named vnetx (x is 0, 1, 2 ...)
Supplement:
Use the default virtual network instead of the bridge, that is, the guest mode is NAT. You can also omit the mac address element to automatically generate a mac address.
By default, the address 192.168.122.x/24 is assigned. you can also manually specify the address. The gateway is 192.168.122.1.
Use virtio:
The common driver is used, that is, the hard disk and the network card are configured by default. The network card works under the simulated rtl 8139 network card and the speed is 100 MB. After the virtio driver is used, the NIC works in 1000 M mode.
15. enter the device
16. define the graphic device that interacts with guset. In this example, the vnc protocol is used. The listen address is the host address. If prot is-1, it indicates that the port number is automatically allocated. run the following command to find the port number:
Virsh vncdisplay
Not set here
17. end of device definition
18. KVM definition ended
Centos_x86_6.4
B9dcdd92-9b9b-14d6-3938-1982a9746a12
2097152
2097152
1
Hvm
Destroy
Restart
Restart
/Bin/qemu-kvm
# The destination image path is displayed as an IDE device in guest in this example.
# Virtual machine network connection
# Use virtio: a common driver is used, that is, when both the hard disk and the network card adopt the default configuration, the hard disk adopts the ide mode, and the NIC works under the simulated rtl 8139 Nic, the speed is 100 M. After the virtio driver is used, the NIC works in 1000 M mode, and the hard disk works in SCSI mode.
# Vnc logon. you can use virsh vncdisplay to query the [vncdisplay domainId]
unconfined_u:system_r:svirt_t:s0:c362,c396
unconfined_u:object_r:svirt_image_t:s0:c362,c396
The above is a detailed description of the code for configuring xml in the KVM virtual machine. For more information, see other related articles in the first PHP community!