ITPub博客

首页 > 数据库 > 数据库开发技术 > 17 KVM虚拟机配置-XML配置文件示例

17 KVM虚拟机配置-XML配置文件示例

原创 数据库开发技术 作者:shuchaoyang 时间:2023-03-02 21:16:00 0 删除 编辑


17 KVM虚拟机配置-XML配置文件示例17.1 概述17.2 示例一17.3 示例二


17.1 概述

本节给出一个基本的AArch64虚拟机和一个x86_64虚拟机的XML配置文件示例,仅供参考。

17.2 示例一

一个包含基本元素的AArch64架构虚拟机的XML配置文件,其内容示例如下:

<domain type='kvm'>
  <name>openEulerVM</name>
  <memory unit='GiB'>8</memory>
  <vcpu>4</vcpu>
  <os>
<type arch='aarch64' machine='virt'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</loader>
<nvram>/var/lib/libvirt/qemu/nvram/openEulerVM.fd</nvram>
  </os>
  <features>
<acpi/>
<gic version='3'/>
  </features>
  <cpu mode='host-passthrough'>
      <topology sockets='2' cores='2' threads='1'/>
  </cpu>
  <iothreads>1</iothreads>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
  <driver name='qemu' type='qcow2' iothread="1"/>
  <source file='/mnt/openEuler-image.qcow2'/>
  <target dev='vda' bus='virtio'/>
  <boot order='1'/>
</disk>
<disk type='file' device='cdrom'>
  <driver name='qemu' type='raw'/>
  <source file='/mnt/openEuler-22.03-LTS-aarch64-dvd.iso'/>
  <readonly/>
  <target dev='sdb' bus='scsi'/>
  <boot order='2'/>
</disk>
<interface type='bridge'>
  <source bridge='br0'/>
  <model type='virtio'/>
</interface>
<console type='pty'/>
      <video>
          <model type='virtio'/>
      </video>
      <controller type='scsi' index='0' model='virtio-scsi'/>
<controller type='usb' model='ehci'/>
<input type='tablet' bus='usb'/>
<input type='keyboard' bus='usb'/>
<graphics type='vnc' listen='0.0.0.0' passwd='n8VfjbFK'/>
  </devices>
  <seclabel type='dynamic' model='dac' relabel='yes'/>
</domain>

17.3 示例二

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

<domain type='kvm'>
<name>openEulerVM</name>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>4</vcpu>
<iothreads>1</iothreads>
<os>
  <type arch='x86_64' machine='pc-i440fx-4.0'>hvm</type>
</os>
<features>
  <acpi/>
</features>
<cpu mode='host-passthrough' check='none'>
  <topology sockets='2' cores='2' threads='1'/>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
  <emulator>/usr/libexec/qemu-kvm</emulator>
  <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2' iothread='1'/>
    <source file='/mnt/openEuler-image.qcow2'/>
    <target dev='vda' bus='virtio'/>
    <boot order='1'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
  </disk>
  <controller type='scsi' index='0' model='virtio-scsi'>
  </controller>
  <controller type='virtio-serial' index='0'>
  </controller>
  <controller type='usb' index='0' model='ehci'>
  </controller>
  <controller type='sata' index='0'>
  </controller>
  <controller type='pci' index='0' model='pci-root'/>
  <interface type='bridge'>
    <mac address='52:54:00:c1:c4:23'/>
    <source bridge='virbr0'/>
    <model type='virtio'/>
  </interface>
  <serial type='pty'>
    <target type='isa-serial' port='0'>
      <model name='isa-serial'/>
    </target>
  </serial>
  <console type='pty'>
    <target type='serial' port='0'/>
  </console>
  <input type='tablet' bus='usb'>
    <address type='usb' bus='0' port='1'/>
  </input>
  <input type='keyboard' bus='usb'>
    <address type='usb' bus='0' port='2'/>
  </input>
  <input type='mouse' bus='ps2'/>
  <input type='keyboard' bus='ps2'/>
  <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
    <listen type='address' address='0.0.0.0'/>
  </graphics>
  <video>
    <model type='vga' vram='16384' heads='1' primary='yes'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
  </video>
  <memballoon model='virtio'>
  </memballoon>
</devices>
</domain>


👍 点赞,你的认可是我创作的动力!

⭐️ 收藏,你的青睐是我努力的方向!


有什么吐槽或反馈意见,直接告诉我!

温馨提示:如出现二维码失效也可直接添加微信号:ysc13803862469。

原文作者:超哥的IT私房菜;如有侵权,请联系管理员删除。

下一篇: 02 安装虚拟化
请登录后发表评论 登录
全部评论
专注于IT系统集成、运维、架构二十年的IT职场老兵,拥有CCNA、OCA、OCP、PGCA、PGCE认证证书,公众号:超哥的IT私房菜,知识星球:超哥的IT私房菜,目前是多家IT厂商的咨询顾问。

注册时间:2021-08-27

  • 博文量
    552
  • 访问量
    303526