xen.xml 4.1 KB

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