xen.xml 4.9 KB

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