xen.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <domain type="xen">
  2. {% block basic %}
  3. <name>{{ vm.name }}</name>
  4. <uuid>{{ vm.uuid }}</uuid>
  5. {% if vm.hvm and vm.devices['pci'].persistent() | list %}
  6. <memory unit="MiB">{{ vm.memory }}</memory>
  7. {% else %}
  8. <memory unit="MiB">{{ vm.maxmem }}</memory>
  9. {% endif %}
  10. <currentMemory unit="MiB">{{ vm.memory }}</currentMemory>
  11. <vcpu placement="static">{{ vm.vcpus }}</vcpu>
  12. {% endblock %}
  13. <os>
  14. {% block os %}
  15. {% if vm.hvm %}
  16. <type arch="x86_64" machine="xenfv">hvm</type>
  17. <loader>hvmloader</loader>
  18. <boot dev="cdrom" />
  19. <boot dev="hd" />
  20. <!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
  21. {% else %}
  22. <type arch="x86_64" machine="xenpv">linux</type>
  23. <kernel>{{ vm.storage.kernels_dir }}/vmlinuz</kernel>
  24. <initrd>{{ vm.storage.kernels_dir }}/initramfs</initrd>
  25. <cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 {{ vm.kernelopts }}</cmdline>
  26. {% endif %}
  27. {% endblock %}
  28. </os>
  29. <features>
  30. {% block features %}
  31. {% if vm.hvm %}
  32. <pae/>
  33. <acpi/>
  34. <apic/>
  35. <viridian/>
  36. {% endif %}
  37. {% if vm.devices['pci'].persistent() | list
  38. and vm.features.get('pci-e820-host', True) %}
  39. <xen>
  40. <e820_host state="on"/>
  41. </xen>
  42. {% endif %}
  43. {% endblock %}
  44. </features>
  45. {% block clock %}
  46. {% if vm.hvm %}
  47. {% set timezone = vm.features.check_with_template('timezone', 'localtime').lower() %}
  48. {% if timezone == 'localtime' %}
  49. <clock offset="variable" adjustment="0" basis="localtime" />
  50. {% elif timezone.isdigit() %}
  51. <clock offset="variable" adjustment="{{ timezone }}" basis="UTC" />
  52. {% else %}
  53. <clock offset="variable" adjustment="0" basis="UTC" />
  54. {% endif %}
  55. {% else %}
  56. <clock offset='utc' adjustment='reset'>
  57. <timer name="tsc" mode="native"/>
  58. </clock>
  59. {% endif %}
  60. {% endblock %}
  61. {% block on %}
  62. <on_poweroff>destroy</on_poweroff>
  63. <on_reboot>destroy</on_reboot>
  64. <on_crash>destroy</on_crash>
  65. {% endblock %}
  66. <devices>
  67. {% block devices %}
  68. {% set i = 0 %}
  69. {# TODO Allow more volumes out of the box #}
  70. {% set dd = ['e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
  71. 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
  72. %}
  73. {% for device in vm.block_devices %}
  74. <disk type="block" device="{{ device.devtype }}">
  75. <driver name="phy" />
  76. <source dev="{{ device.path }}" />
  77. {% if device.name == 'root' %}
  78. <target dev="xvda" />
  79. {% elif device.name == 'private' %}
  80. <target dev="xvdb" />
  81. {% elif device.name == 'volatile' %}
  82. <target dev="xvdc" />
  83. {% elif device.name == 'kernel' %}
  84. <target dev="xvdd" />
  85. {% else %}
  86. <target dev="xvd{{dd[i]}}" />
  87. {% set i = i + 1 %}
  88. {% endif %}
  89. {% if not device.rw %}
  90. <readonly />
  91. {% endif %}
  92. {% if device.domain %}
  93. <backenddomain name="{{ domain }}" />
  94. {% endif %}
  95. {% if device.script %}
  96. <script path="{{ device.script }}" />
  97. {% endif %}
  98. </disk>
  99. {% endfor %}
  100. {# start external devices from xvdi #}
  101. {% set i = 4 %}
  102. {% for assignment in vm.devices.block.assignments(True) %}
  103. {% set device = assignment.device %}
  104. {% set options = assignment.options %}
  105. {% include 'libvirt/devices/block.xml' %}
  106. {% endfor %}
  107. {% if vm.netvm %}
  108. {% include 'libvirt/devices/net.xml' with context %}
  109. {% endif %}
  110. {% for assignment in vm.devices.pci.assignments(True) %}
  111. {% set device = assignment.device %}
  112. {% set options = assignment.options %}
  113. {% include 'libvirt/devices/pci.xml' %}
  114. {% endfor %}
  115. {% if vm.hvm %}
  116. <emulator
  117. {% if vm.features.check_with_template('linux-stubdom', True) %}
  118. type="stubdom-linux"
  119. {% else %}
  120. type="stubdom"
  121. {% endif %}
  122. {% if vm.netvm and not
  123. vm.features.check_with_template('linux-stubdom', True) %}
  124. cmdline="-net lwip,client_ip={{ vm.ip -}}
  125. ,server_ip={{ vm.dns[1] -}}
  126. ,dns={{ vm.netvm.gateway -}}
  127. ,gw={{ vm.netvm.gateway -}}
  128. ,netmask={{ vm.netmask }}"
  129. {% endif %}
  130. {% if vm.stubdom_mem %}
  131. memory="{{ vm.stubdom_mem * 1024 -}}"
  132. {% endif %}
  133. />
  134. <input type="tablet" bus="usb"/>
  135. {% if vm.features.check_with_template('linux-stubdom', True) %}
  136. <video type="cirrus"/>
  137. {% else %}
  138. <video type="vga"/>
  139. {% endif %}
  140. {% if vm.features.check_with_template('linux-stubdom', True) %}
  141. {# TODO only add qubes gui if gui-agent is not installed in HVM #}
  142. <graphics type="qubes"/>
  143. {% endif %}
  144. {% else %}
  145. <console type="pty">
  146. <target type="xen" port="0"/>
  147. </console>
  148. {% endif %}
  149. {% endblock %}
  150. </devices>
  151. </domain>
  152. <!-- vim: set ft=jinja ts=4 sts=4 sw=4 et tw=80 : -->