xen.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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'].attached() | list
  29. and vm.features.get('pci-e820-host', True) %}
  30. <xen>
  31. <e820_host state="on"/>
  32. </xen>
  33. {% endif %}
  34. </features>
  35. {% if vm.hvm %}
  36. {% set timezone = vm.features.check_with_template('timezone', 'localtime').lower() %}
  37. {% if timezone == 'localtime' %}
  38. <clock offset="variable" adjustment="0" basis="localtime" />
  39. {% elif timezone.isdigit() %}
  40. <clock offset="variable" adjustment="{{ timezone }}" basis="UTC" />
  41. {% else %}
  42. <clock offset="variable" adjustment="0" basis="UTC" />
  43. {% endif %}
  44. {% else %}
  45. <clock offset='utc' adjustment='reset'>
  46. <timer name="tsc" mode="native"/>
  47. </clock>
  48. {% endif %}
  49. <on_poweroff>destroy</on_poweroff>
  50. <on_reboot>destroy</on_reboot>
  51. <on_crash>destroy</on_crash>
  52. <devices>
  53. {% set i = 0 %}
  54. {# TODO Allow more volumes out of the box #}
  55. {% set dd = ['e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
  56. 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
  57. %}
  58. {% for device in vm.block_devices %}
  59. <disk type="block" device="{{ device.devtype }}">
  60. <driver name="phy" />
  61. <source dev="{{ device.path }}" />
  62. {% if device.name == 'root' %}
  63. <target dev="xvda" />
  64. {% elif device.name == 'private' %}
  65. <target dev="xvdb" />
  66. {% elif device.name == 'volatile' %}
  67. <target dev="xvdc" />
  68. {% elif device.name == 'kernel' %}
  69. <target dev="xvdd" />
  70. {% else %}
  71. <target dev="xvd{{dd[i]}}" />
  72. {% set i = i + 1 %}
  73. {% endif %}
  74. {% if not device.rw %}
  75. <readonly />
  76. {% endif %}
  77. {% if device.domain %}
  78. <domain name="{{ domain }}" />
  79. {% endif %}
  80. {% if device.script %}
  81. <script path="{{ device.script }}" />
  82. {% endif %}
  83. </disk>
  84. {% endfor %}
  85. {% if vm.netvm %}
  86. {% include 'libvirt/devices/net.xml' with context %}
  87. {% endif %}
  88. {% for device in vm.devices.pci.attached() %}
  89. {% include 'libvirt/devices/pci.xml' %}
  90. {% endfor %}
  91. {% if vm.hvm %}
  92. <emulator
  93. type="stubdom"
  94. {% if vm.netvm %}
  95. cmdline="-net lwip,client_ip={{ vm.ip -}}
  96. ,server_ip={{ vm.secondary_dns -}}
  97. ,dns={{ vm.netvm.gateway -}}
  98. ,gw={{ self.netvm.gateway -}}
  99. ,netmask={{ vm.netmask }}"
  100. {% endif %}
  101. />
  102. <input type="tablet" bus="usb"/>
  103. <video type="vga"/>
  104. {% else %}
  105. <console type="pty">
  106. <target type="xen" port="0"/>
  107. </console>
  108. {% endif %}
  109. </devices>
  110. </domain>
  111. <!-- vim: set ft=jinja ts=4 sts=4 sw=4 et tw=80 : -->