9.3. 仮想マシンの XML 設定例

仮想マシンの XML 設定 (ドメイン XML とも呼ばれる) は、仮想マシンの設定およびコンポーネントを決定します。以下の表は、仮想マシンの XML 設定例の各セクションと、コンテンツについて説明しています。

仮想マシンの XML 設定を取得するには、virsh dumpxml コマンドの後に仮想マシンの名前を指定します。

# virsh dumpxml testguest1

表9.1 XML 設定のサンプル

ドメイン XML セクション説明
<domain type='kvm'>
 <name>Testguest1</name>
 <uuid>ec6fbaa1-3eb4-49da-bf61-bb02fbec4967</uuid>
 <memory unit='KiB'>1048576</memory>
 <currentMemory unit='KiB'>1048576</currentMemory>

これは、1024 MiB のメモリーが割り当てられている KVM 仮想マシン Testguest1 です。

 <vcpu placement='static'>1</vcpu>

仮想マシンには、仮想 CPU (vCPU) が 1 つ割り当てられます。

vCPU の設定に関する詳細は、仮想マシンの CPU パフォーマンスの最適化 を参照してください。

 <os>
  <type arch='x86_64' machine='pc-q35-rhel9.0.0'>hvm</type>
  <boot dev='hd'/>
 </os>

マシンアーキテクチャーは AMD64 および Intel 64 のアーキテクチャーに設定され、Intel Q35 マシン種別を使用して機能の互換性を決定します。OS は、ハードディスクドライブから起動するように設定されています。

OS がインストールされた仮想マシンの作成については、Web コンソールを使用した仮想マシンの作成、およびゲストのオペレーティングシステムのインストール を参照してください。

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

acpi および apic ハイパーバイザー機能が無効になっています。

 <cpu mode='host-model' check='partial'/>

機能 XML (virsh domcapabilities で取得可能 ) からのホストの CPU 定義は、仮想マシンの XML 設定に自動的にコピーされます。したがって、仮想マシンの起動時に、libvirt はホストの CPU と似た CPU モデルを選択し、さらに機能を追加してホストモデルに可能な限り近づけます。

 <clock offset='utc'>
  <timer name='rtc' tickpolicy='catchup'/>
  <timer name='pit' tickpolicy='delay'/>
  <timer name='hpet' present='no'/>
 </clock>

仮想マシンの仮想ハードウェアクロックは UTC タイムゾーンを使用します。また、QEMU ハイパーバイザーと同期するために、異なるタイマーが 3 つ設定されます。

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

仮想マシンの電源が切れた場合や、仮想マシンの OS が突然終了すると、libvirt が仮想マシンを終了し、割り当てられているリソースをすべて解放します。仮想マシンの再起動時に、libvirt は同じ設定で仮想マシンを起動します。

 <pm>
  <suspend-to-mem enabled='no'/>
  <suspend-to-disk enabled='no'/>
 </pm>

この仮想マシンでは、S3 および S4 ACPI のスリープ状態が無効になっています。

<devices>
 <emulator>/usr/libexec/qemu-kvm</emulator>
 <disk type='file' device='disk'>
  <driver name='qemu' type='qcow2'/>
  <source file='/var/lib/libvirt/images/Testguest.qcow2'/>
  <target dev='vda' bus='virtio'/>
 </disk>
 <disk type='file' device='cdrom'>
  <driver name='qemu' type='raw'/>
  <target dev='sdb' bus='sata'/>
  <readonly/>
 </disk>

仮想マシンは、エミュレーションに /usr/libexec/qemu-kvm バイナリーファイルを使用し、これには 2 つのディスクデバイスが割り当てられています。

最初のディスクは、ホストに保存されている /var/lib/libvirt/images/Testguest.qcow2 をベースにした仮想ハードドライブで、その論理デバイス名は vda に設定されています。Windows ゲストでは、virtio の代わりに sata バスを使用することが推奨されます。

2 番目のディスクは仮想化 CD-ROM で、その論理デバイス名は sdb に設定されています。

  <controller type='usb' index='0' model='qemu-xhci' ports='15'/>
  <controller type='sata' index='0'/>
  <controller type='pci' index='0' model='pcie-root'/>
  <controller type='pci' index='1' model='pcie-root-port'>
   <model name='pcie-root-port'/>
   <target chassis='1' port='0x10'/>
  </controller>
  <controller type='pci' index='2' model='pcie-root-port'>
   <model name='pcie-root-port'/>
   <target chassis='2' port='0x11'/>
  </controller>
  <controller type='pci' index='3' model='pcie-root-port'>
   <model name='pcie-root-port'/>
   <target chassis='3' port='0x12'/>
  </controller>
  <controller type='pci' index='4' model='pcie-root-port'>
   <model name='pcie-root-port'/>
   <target chassis='4' port='0x13'/>
  </controller>
  <controller type='pci' index='5' model='pcie-root-port'>
   <model name='pcie-root-port'/>
   <target chassis='5' port='0x14'/>
  </controller>
  <controller type='pci' index='6' model='pcie-root-port'>
   <model name='pcie-root-port'/>
   <target chassis='6' port='0x15'/>
  </controller>
  <controller type='pci' index='7' model='pcie-root-port'>
   <model name='pcie-root-port'/>
   <target chassis='7' port='0x16'/>
  </controller>
  <controller type='virtio-serial' index='0'/>

仮想マシンは、USB デバイスの割り当てにコントローラーを 1 つ、PCI-Express (PCIe) デバイスにルートコントローラーを使用します。さらに、virtio-serial コントローラーが利用できるため、仮想マシンは、シリアルコンソールなど、各種方法でホストを操作できます。

仮想デバイスの詳細は、仮想デバイスの種類 を参照してください。

 <interface type='network'>
  <mac address='52:54:00:65:29:21'/>
  <source network='default'/>
  <model type='virtio'/>
 </interface>

ネットワークインターフェイスは、default の仮想ネットワークおよび virtio ネットワークデバイスモデルを使用する仮想マシンに設定されます。Windows ゲストでは、virtio の代わりに e1000e モデルを使用することが推奨されます。

ネットワークインターフェイスの設定に関する詳細は、仮想マシンのネットワークパフォーマンスの最適化 を参照してください。

  <serial type='pty'>
   <target type='isa-serial' port='0'>
    <model name='isa-serial'/>
   </target>
  </serial>
  <console type='pty'>
   <target type='serial' port='0'/>
  </console>
  <channel type='unix'>
   <target type='virtio' name='org.qemu.guest_agent.0'/>
   <address type='virtio-serial' controller='0' bus='0' port='1'/>
  </channel>

pty シリアルコンソールが仮想マシンに設定されているので、ホストとの基本的な仮想マシン通信が可能になります。コンソールは、ポート 1 で UNIX チャンネルを使用します。この設定は自動で設定されており、設定の変更は推奨されません。

仮想マシンと相互作用する方法の詳細は、Web コンソールを使用した仮想マシンとの相互作用 を参照してください。

  <input type='tablet' bus='usb'>
   <address type='usb' bus='0' port='1'/>
  </input>
  <input type='mouse' bus='ps2'/>
  <input type='keyboard' bus='ps2'/>

仮想マシンは、タブレット入力を受信するように設定された仮想 usb ポートと、マウスとキーボード入力を受け取るように設定された仮想 ps2 ポートを使用します。この設定は自動で設定されており、設定の変更は推奨されません。

  <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
   <listen type='address' address='127.0.0.1'/>
  </graphics>

仮想マシンは、グラフィカル出力をレンダリングするために vnc プロトコルを使用します。

  <redirdev bus='usb' type='tcp'>
   <source mode='connect' host='localhost' service='4000'/>
   <protocol type='raw'/>
  </redirdev>
  <memballoon model='virtio'>
   <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
  </memballoon>
 </devices>
</domain>

仮想マシンは、USB デバイスのリモート接続に tcp リダイレクターを使用し、メモリーバルーンがオンになっています。この設定は自動で設定されており、設定の変更は推奨されません。