XML配置文件示例

概述

本节给出两个基本的虚拟机XML配置文件示例,供用户参考。

示例一

一个包含基本元素的XML配置文件,其内容示例如下:

  1. <domain type='kvm'>
  2. <name>openEulerVM</name>
  3. <memory unit='GiB'>8</memory>
  4. <vcpu>4</vcpu>
  5. <os>
  6. <type arch='aarch64' machine='virt-4.0'>hvm</type>
  7. <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</loader>
  8. <nvram>/var/lib/libvirt/qemu/nvram/openEulerVM.fd</nvram>
  9. </os>
  10. <features>
  11. <acpi/>
  12. <gic version='3'/>
  13. </features>
  14. <cpu mode='host-passthrough'>
  15. <topology sockets='2' cores='2' threads='1'/>
  16. </cpu>
  17. <iothreads>1</iothreads>
  18. <clock offset='utc'/>
  19. <on_poweroff>destroy</on_poweroff>
  20. <on_reboot>restart</on_reboot>
  21. <on_crash>restart</on_crash>
  22. <devices>
  23. <emulator>/usr/libexec/qemu-kvm</emulator>
  24. <disk type='file' device='disk'>
  25. <driver name='qemu' type='qcow2' iothread="1"/>
  26. <source file='/mnt/openEuler-image.qcow2'/>
  27. <target dev='vda' bus='virtio'/>
  28. <boot order='1'/>
  29. </disk>
  30. <disk type='file' device='cdrom'>
  31. <driver name='qemu' type='raw'/>
  32. <source file='/mnt/openEuler-1.0-base-aarch64-dvd.iso'/>
  33. <readonly/>
  34. <target dev='sdb' bus='scsi'/>
  35. <boot order='2'/>
  36. </disk>
  37. <interface type='bridge'>
  38. <source bridge='br0'/>
  39. <model type='virtio'/>
  40. </interface>
  41. <console type='pty'/>
  42. <video>
  43. <model type='virtio'/>
  44. </video>
  45. <controller type='scsi' index='0' model='virtio-scsi'/>
  46. <controller type='usb' model='ehci'/>
  47. <input type='tablet' bus='usb'/>
  48. <input type='keyboard' bus='usb'/>
  49. <graphics type='vnc' listen='0.0.0.0' passwd='n8VfjbFK'/>
  50. </devices>
  51. </domain>

示例二

一个包含基本元素及总线元素的XML配置文件,其配置示例如下:

  1. <domain type='kvm'>
  2. <name>openEulerVM</name>
  3. <memory unit='GiB'>8</memory>
  4. <vcpu>4</vcpu>
  5. <os>
  6. <type arch='aarch64' machine='virt-4.0'>hvm</type>
  7. <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</loader>
  8. <nvram>/var/lib/libvirt/qemu/nvram/openEulerVM.fd</nvram>
  9. </os>
  10. <features>
  11. <acpi/>
  12. <gic version='3'/>
  13. </features>
  14. <cpu mode='host-passthrough'>
  15. <topology sockets='2' cores='2' threads='1'/>
  16. </cpu>
  17. <iothreads>1</iothreads>
  18. <clock offset='utc'/>
  19. <on_poweroff>destroy</on_poweroff>
  20. <on_reboot>restart</on_reboot>
  21. <on_crash>restart</on_crash>
  22. <devices>
  23. <emulator>/usr/libexec/qemu-kvm</emulator>
  24. <disk type='file' device='disk'>
  25. <driver name='qemu' type='qcow2' iothread="1"/>
  26. <source file='/mnt/openEuler-image.qcow2'/>
  27. <target dev='vda' bus='virtio'/>
  28. <boot order='1'/>
  29. </disk>
  30. <disk type='file' device='cdrom'>
  31. <driver name='qemu' type='raw'/>
  32. <source file='/mnt/openEuler-1.0-base-aarch64-dvd.iso'/>
  33. <readonly/>
  34. <target dev='sdb' bus='scsi'/>
  35. <boot order='2'/>
  36. </disk>
  37. <controller type='pci' index='0' model='pcie-root'/>
  38. <controller type='pci' index='1' model='pcie-root-port'>
  39. <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
  40. </controller>
  41. <controller type='pci' index='2' model='pcie-root-port'>
  42. <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
  43. </controller>
  44. <controller type='pci' index='3' model='pcie-to-pci-bridge'>
  45. <model name='pcie-pci-bridge'/>
  46. <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
  47. </controller>
  48. <controller type='pci' index='4' model='pcie-root-port'>
  49. <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
  50. </controller>
  51. <controller type='scsi' index='0' model='virtio-scsi'>
  52. <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
  53. </controller>
  54. <controller type='virtio-serial' index='0'>
  55. <address type='pci' domain='0x0000' bus='0x03' slot='0x02' function='0x0'/>
  56. </controller>
  57. <controller type='usb' index='0' model='ehci'>
  58. <address type='pci' domain='0x0000' bus='0x03' slot='0x01' function='0x0'/>
  59. </controller>
  60. <interface type='bridge'>
  61. <source bridge='br0'/>
  62. <model type='virtio'/>
  63. </interface>
  64. <console type='pty'/>
  65. <video>
  66. <model type='virtio'/>
  67. </video>
  68. <input type='tablet' bus='usb'/>
  69. <input type='keyboard' bus='usb'/>
  70. <graphics type='vnc' listen='0.0.0.0' passwd='n8VfjbFK'/>
  71. </devices>
  72. </domain>