search
HomeBackend DevelopmentXML/RSS TutorialDetailed explanation of the configuration xml code in the KVM virtual machine

In RHEL6, the XML file used to boot from disk

Here is dcs01.xml as an example:

 <domain type=&#39;kvm&#39;>
<name>dcs01</name>
<uuid>e5fff551-bbe1-e748-c8e4-8ecb3bffb902</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch=&#39;x86_64&#39; machine=&#39;rhel6.0.0&#39;>hvm</type>
<boot dev=&#39;hd&#39;/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset=&#39;localtime&#39;/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type=&#39;file&#39; device=&#39;disk&#39;>
<driver name=&#39;qemu&#39; type=&#39;raw&#39; cache=&#39;none&#39;/>
<source file=&#39;/home/kvm/images/dcs01.img&#39;/>
<target dev=&#39;hda&#39; bus=&#39;ide&#39;/>
<address type=&#39;drive&#39; controller=&#39;0&#39; bus=&#39;0&#39; unit=&#39;0&#39;/>
</disk>
<disk type=&#39;file&#39; device=&#39;cdrom&#39;>
<driver name=&#39;qemu&#39; type=&#39;raw&#39;/>
<target dev=&#39;hdc&#39; bus=&#39;ide&#39;/>
<readonly/>
<address type=&#39;drive&#39; controller=&#39;0&#39; bus=&#39;1&#39; unit=&#39;0&#39;/>
</disk>
<controller type=&#39;ide&#39; index=&#39;0&#39;>
<address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x01&#39; function=&#39;0x1&#39;/>
</controller>
<interface type=&#39;bridge&#39;>
<mac address=&#39;52:54:00:ad:75:98&#39;/>
<source bridge=&#39;br0&#39;/>
<address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x03&#39; function=&#39;0x0&#39;/>
</interface>
<input type=&#39;tablet&#39; bus=&#39;usb&#39;/>
<input type=&#39;mouse&#39; bus=&#39;ps2&#39;/>
<graphics type=&#39;vnc&#39; port=&#39;-1&#39; autoport=&#39;yes&#39;/>
<video>
<model type=&#39;vga&#39; vram=&#39;9216&#39; heads=&#39;1&#39;/>
<address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x02&#39; function=&#39;0x0&#39;/>
</video>
<memballoon model=&#39;virtio&#39;>
<address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x05&#39; function=&#39;0x0&#39;/>
</memballoon>
</devices>
</domain>

Comments are as follows:

 1. Kvm guest definition starts

<domain type=&#39;kvm&#39;>

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

<name>dcs01</name>

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

<uuid>e5fff551-bbe1-e748-c8e4-8ecb3bffb902</uuid>

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

<memory>1048576</memory>

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.

<currentMemory>1048576</currentMemory>

6. Assigned virtual cpu

<vcpu>1</vcpu>

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.

<os>
<type arch=&#39;x86_64&#39; machine=&#39;rhel6.0.0&#39;>hvm</type>
<boot dev=&#39;hd&#39;/>
</os>

8. Processor features

<features>
<acpi/>
<apic/>
<pae/>
</features>

9. Clock. Use local time: localtime

<clock offset=&#39;localtime&#39;/>

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.

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

 11. Start of device definition

<devices>

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

<emulator>/usr/libexec/qemu-kvm</emulator>

 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/

<disk type=&#39;file&#39; device=&#39;disk&#39;>
<driver name=&#39;qemu&#39; type=&#39;raw&#39; cache=&#39;none&#39;/>
<source file=&#39;/home/kvm/images/dcs01.img&#39;/>
<target dev=&#39;hda&#39; bus=&#39;ide&#39;/>
<address type=&#39;drive&#39; controller=&#39;0&#39; bus=&#39;0&#39; unit=&#39;0&#39;/>
</disk>

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.

<disk type=&#39;file&#39; device=&#39;disk&#39;>
<driver name=&#39;qemu&#39; type=&#39;raw&#39;/>
<source file=&#39;/usr/local/kvm/vmsample/disk.os&#39;/>
<target dev=&#39;vda&#39; bus=&#39;virtio&#39;/>
</disk>

CD-ROM device:

<disk type=&#39;file&#39; device=&#39;cdrom&#39;>
<driver name=&#39;qemu&#39; type=&#39;raw&#39;/>
<target dev=&#39;hdc&#39; bus=&#39;ide&#39;/>
<readonly/>
<address type=&#39;drive&#39; controller=&#39;0&#39; bus=&#39;1&#39; unit=&#39;0&#39;/>
</disk>

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...)

<interface type=&#39;bridge&#39;>
<mac address=&#39;52:54:00:ad:75:98&#39;/>
<source bridge=&#39;br0&#39;/>
<address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x03&#39; function=&#39;0x0&#39;/>
</interface>

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.

<interface type=&#39;network&#39;>
<source network=&#39;default&#39;/>
<mac address="3B:6E:01:69:3A:11"/>
</interface>

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.

<interface type=&#39;bridge&#39;>
<source bridge=&#39;br1&#39;/>
<model type=&#39;virtio&#39; />
</interface>

15. Input device

<input type=&#39;tablet&#39; bus=&#39;usb&#39;/>
<input type=&#39;mouse&#39; bus=&#39;ps2&#39;/>

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

<graphics type=&#39;vnc&#39; port=&#39;-1&#39; autoport=&#39;yes&#39;/>

 17 , Device definition ends

</devices>

18. KVM definition ends

</domain>

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

  <disk type=&#39;file&#39; device=&#39;disk&#39;>
      <driver name=&#39;qemu&#39; type=&#39;qcow2&#39;/>

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

<source file=&#39;/home/template_make/centos_x86_6.4.img&#39;>
        <seclabel model=&#39;selinux&#39; relabel=&#39;no&#39;/>
      </source>
      <target dev=&#39;hda&#39; bus=&#39;ide&#39;/>
      <alias name=&#39;ide0-0-0&#39;/>
      <address type=&#39;drive&#39; controller=&#39;0&#39; bus=&#39;0&#39; target=&#39;0&#39; unit=&#39;0&#39;/>
    </disk>
    <disk type=&#39;file&#39; device=&#39;cdrom&#39;>
      <driver name=&#39;qemu&#39; type=&#39;raw&#39;/>
      <source file=&#39;/home/template_make/CentOS-6.4-x86_64-bin-DVD1.iso&#39;/>
      <target dev=&#39;hdc&#39; bus=&#39;ide&#39;/>
      <readonly/>
      <alias name=&#39;ide0-1-0&#39;/>
      <address type=&#39;drive&#39; controller=&#39;0&#39; bus=&#39;1&#39; target=&#39;0&#39; unit=&#39;0&#39;/>
    </disk>
    <controller type=&#39;usb&#39; index=&#39;0&#39;>
      <alias name=&#39;usb0&#39;/>
      <address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x01&#39; function=&#39;0x2&#39;/>
    </controller>
    <controller type=&#39;ide&#39; index=&#39;0&#39;>
      <alias name=&#39;ide0&#39;/>
      <address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x01&#39; function=&#39;0x1&#39;/>
    </controller>
    <interface type=&#39;bridge&#39;>

#Virtual machine network connection method

 <mac address=&#39;52:54:00:78:f9:5a&#39;/>
      <source bridge=&#39;br0&#39;/>
      <target dev=&#39;vnet27&#39;/>

## 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.

<model type=&#39;virtio&#39;/>
      <alias name=&#39;net0&#39;/>
      <address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x03&#39; function=&#39;0x0&#39;/>
    </interface>
    <input type=&#39;mouse&#39; bus=&#39;ps2&#39;/>

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


      
    
    


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!

Statement
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
RSS Documents: The Foundation of Web SyndicationRSS Documents: The Foundation of Web SyndicationApr 18, 2025 am 12:04 AM

RSS documents are XML-based structured files used to publish and subscribe to frequently updated content. Its main functions include: 1) automated content updates, 2) content aggregation, and 3) improving browsing efficiency. Through RSSfeed, users can subscribe and get the latest information from different sources in a timely manner.

Decoding RSS: The XML Structure of Content FeedsDecoding RSS: The XML Structure of Content FeedsApr 17, 2025 am 12:09 AM

The XML structure of RSS includes: 1. XML declaration and RSS version, 2. Channel (Channel), 3. Item. These parts form the basis of RSS files, allowing users to obtain and process content information by parsing XML data.

How to Parse and Utilize XML-Based RSS FeedsHow to Parse and Utilize XML-Based RSS FeedsApr 16, 2025 am 12:05 AM

RSSfeedsuseXMLtosyndicatecontent;parsingtheminvolvesloadingXML,navigatingitsstructure,andextractingdata.Applicationsincludebuildingnewsaggregatorsandtrackingpodcastepisodes.

RSS Documents: How They Deliver Your Favorite ContentRSS Documents: How They Deliver Your Favorite ContentApr 15, 2025 am 12:01 AM

RSS documents work by publishing content updates through XML files, and users subscribe and receive notifications through RSS readers. 1. Content publisher creates and updates RSS documents. 2. The RSS reader regularly accesses and parses XML files. 3. Users browse and read updated content. Example of usage: Subscribe to TechCrunch's RSS feed, just copy the link to the RSS reader.

Building Feeds with XML: A Hands-On Guide to RSSBuilding Feeds with XML: A Hands-On Guide to RSSApr 14, 2025 am 12:17 AM

The steps to build an RSSfeed using XML are as follows: 1. Create the root element and set the version; 2. Add the channel element and its basic information; 3. Add the entry element, including the title, link and description; 4. Convert the XML structure to a string and output it. With these steps, you can create a valid RSSfeed from scratch and enhance its functionality by adding additional elements such as release date and author information.

Creating RSS Documents: A Step-by-Step TutorialCreating RSS Documents: A Step-by-Step TutorialApr 13, 2025 am 12:10 AM

The steps to create an RSS document are as follows: 1. Write in XML format, with the root element, including the elements. 2. Add, etc. elements to describe channel information. 3. Add elements, each representing a content entry, including,,,,,,,,,,,. 4. Optionally add and elements to enrich the content. 5. Ensure the XML format is correct, use online tools to verify, optimize performance and keep content updated.

XML's Role in RSS: The Foundation of Syndicated ContentXML's Role in RSS: The Foundation of Syndicated ContentApr 12, 2025 am 12:17 AM

The core role of XML in RSS is to provide a standardized and flexible data format. 1. The structure and markup language characteristics of XML make it suitable for data exchange and storage. 2. RSS uses XML to create a standardized format to facilitate content sharing. 3. The application of XML in RSS includes elements that define feed content, such as title and release date. 4. Advantages include standardization and scalability, and challenges include document verbose and strict syntax requirements. 5. Best practices include validating XML validity, keeping it simple, using CDATA, and regularly updating.

From XML to Readable Content: Demystifying RSS FeedsFrom XML to Readable Content: Demystifying RSS FeedsApr 11, 2025 am 12:03 AM

RSSfeedsareXMLdocumentsusedforcontentaggregationanddistribution.Totransformthemintoreadablecontent:1)ParsetheXMLusinglibrarieslikefeedparserinPython.2)HandledifferentRSSversionsandpotentialparsingerrors.3)Transformthedataintouser-friendlyformatsliket

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.