{% block basic %}
        {{ vm.name }}
        {{ vm.uuid }}
        {% if ((vm.virt_mode == 'hvm' and vm.devices['pci'].persistent() | list)
            or vm.maxmem == 0) -%}
            {{ vm.memory }}
        {% else -%}
            {{ vm.maxmem }}
        {% endif -%}
        {{ vm.memory }}
        {{ vm.vcpus }}
    {% endblock %}
    {% block cpu %}
    {% if vm.virt_mode != 'pv' %}
        
            
            
            
            
            
        
    {% endif %}
    {% endblock %}
    
        {% block os %}
            {% if vm.virt_mode == 'hvm' %}
                hvm
                
                hvmloader
                
                
            {% else %}
                {% if vm.virt_mode == 'pvh' %}
                    xenpvh
                {% else %}
                    linux
                {% endif %}
                {{ vm.storage.kernels_dir }}/vmlinuz
                {{ vm.storage.kernels_dir }}/initramfs
            {% endif %}
            {% if vm.kernel %}
                {% if vm.features.check_with_template('no-default-kernelopts', False) -%}
                {{ vm.kernelopts }}
                {% else -%}
                {{ vm.kernelopts_common }}{{ vm.kernelopts }}
                {% endif -%}
            {% endif %}
        {% endblock %}
    
    
        {% block features %}
            {% if vm.virt_mode != 'pv' %}
                
                
                
                
            {% endif %}
                
                {% if vm.devices['pci'].persistent() | list
                      and vm.features.get('pci-e820-host', True) %}
                    
                {% endif %}
                {% if vm.features.check_with_template('gfx-passthru', False) %}
                    
                {% endif %}
                
        {% endblock %}
    
    {% block clock %}
        {% if vm.virt_mode == 'hvm' %}
            {% set timezone = vm.features.check_with_template('timezone', 'localtime').lower() %}
            {% if timezone == 'localtime' %}
                
            {% elif timezone.isdigit() %}
                
            {% else %}
                
            {% endif %}
        {% else %}
            
                
            
        {% endif %}
    {% endblock %}
    {% block on %}
        destroy
        destroy
        destroy
    {% endblock %}
    
        {% block devices %}
            {#
                HACK: The letter counter is implemented in this way because
                Jinja does not allow you to increment variables in a loop
                anymore. As of Jinja 2.10, we will be able to replace this
                with:
                {% set counter = namespace(i=0) %}
                {% set counter.i = counter.i + 1 %}
            #}
            {% set counter = {'i': 0} %}
            {# TODO Allow more volumes out of the box #}
            {% set dd = ['e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
                'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
            %}
            {% for device in vm.block_devices %}
                
                    
                    
                    {% if device.name == 'root' %}
                        
                    {% elif device.name == 'private' %}
                        
                    {% elif device.name == 'volatile' %}
                        
                    {% elif device.name == 'kernel' %}
                        
                    {% else %}
                        
                        {% if counter.update({'i': counter.i + 1}) %}{% endif %}
                    {% endif %}
                    {% if not device.rw %}
                        
                    {% endif %}
                    {% if device.domain %}
                        
                    {% endif %}
                    {% if device.script %}
                        
                    {% endif %}
                
            {% endfor %}
            {# start external devices from xvdi #}
            {% set counter = {'i': 4} %}
            {% for assignment in vm.devices.block.assignments(True) %}
                {% set device = assignment.device %}
                {% set options = assignment.options %}
                {% include 'libvirt/devices/block.xml' %}
            {% endfor %}
            {% if vm.netvm %}
                {% include 'libvirt/devices/net.xml' with context %}
            {% endif %}
            {% for assignment in vm.devices.pci.assignments(True) %}
                {% set device = assignment.device %}
                {% set options = assignment.options %}
                {% include 'libvirt/devices/pci.xml' %}
            {% endfor %}
            {% if vm.virt_mode == 'hvm' %}
                
                
                
                {% if vm.features.check_with_template('video-model', 'vga') != 'none' %}
                    
                    {% if vm.features.check_with_template('linux-stubdom', True) %}
                        {# TODO only add qubes gui if gui-agent is not installed in HVM #}
                        
                    {% endif %}
                {% endif %}
            {% endif %}
                
                    
                
        {% endblock %}