
When using file-backed storage, or SSD storage, any erasing done in the VM does not actually clear up the space. By using the virtio-scsi controller the VM is able to use TRIM to clear any blocks which are deleted. This also allows us to use fstrim to reduce the size of the qemu files before we save them for later re-use. Change-Id: Ia9001522ce054ee9f8a6dd38270da3e3fd039813
112 lines
3.9 KiB
Django/Jinja
112 lines
3.9 KiB
Django/Jinja
<domain type='kvm'>
|
|
<name>{{ hostvars[item]['server_hostname'] }}</name>
|
|
<memory unit='MiB'>{{ hostvars[item]['server_vm_ram'] }}</memory>
|
|
<currentMemory unit='MiB'>{{ hostvars[item]['server_vm_ram'] }}</currentMemory>
|
|
{% set _vcpus_threads = ((hostvars[item]['server_vm_vcpus'] | int) // 2) %}
|
|
{% set vcpus_threads = (_vcpus_threads | int) == 0 | ternary('1', _vcpus_threads) %}
|
|
{% set vcpus = (hostvars[item]['server_vm_vcpus'] | int) * (vcpus_threads | int) %}
|
|
<vcpu placement='static' current='{{ vcpus | int }}'>{{ vcpus | int }}</vcpu>
|
|
<resource>
|
|
<partition>/machine</partition>
|
|
</resource>
|
|
<os>
|
|
<type arch='x86_64' machine='pc-i440fx-{{ ansible_distribution_release | lower }}'>hvm</type>
|
|
<bootmenu enable='yes'/>
|
|
</os>
|
|
<features>
|
|
<acpi/>
|
|
<apic/>
|
|
</features>
|
|
<cpu mode='host-model'>
|
|
<topology sockets='1' cores='{{ hostvars[item]["server_vm_vcpus"] | int }}' threads='{{ vcpus_threads | int }}'/>
|
|
</cpu>
|
|
<clock offset='utc'>
|
|
<timer name='rtc' tickpolicy='catchup'/>
|
|
<timer name='pit' tickpolicy='delay'/>
|
|
<timer name='hpet' present='no'/>
|
|
</clock>
|
|
<on_poweroff>destroy</on_poweroff>
|
|
<on_reboot>restart</on_reboot>
|
|
<on_crash>destroy</on_crash>
|
|
<pm>
|
|
<suspend-to-mem enabled='no'/>
|
|
<suspend-to-disk enabled='no'/>
|
|
</pm>
|
|
<devices>
|
|
<emulator>/usr/bin/kvm-spice</emulator>
|
|
{% if default_vm_disk_mode == "lvm" %}
|
|
<disk type='block' device='disk'>
|
|
<driver name='qemu' type='raw' cache='none' io='native'/>
|
|
<source dev='/dev/{{ default_vm_disk_vg }}/{{ hostvars[item]["server_hostname"] }}'/>
|
|
{% elif default_vm_disk_mode == "file" %}
|
|
<disk type='file' device='disk'>
|
|
<driver name='qemu' type='qcow2' discard='unmap' cache='none' io='native'/>
|
|
<source file='{{ _virt_pools.pools.default.path | default('/data/images') }}/{{ hostvars[item]["server_hostname"] }}.img'/>
|
|
{% endif %}
|
|
<target dev='sda' bus='scsi'/>
|
|
<alias name='scsi0-0-0-0'/>
|
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
<boot order='1'/>
|
|
</disk>
|
|
<controller type='pci' index='0' model='pci-root'>
|
|
<alias name='pci.0'/>
|
|
</controller>
|
|
<controller type='scsi' index='0' model='virtio-scsi'>
|
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
|
|
</controller>
|
|
<controller type='virtio-serial' index='0'>
|
|
<alias name='virtio-serial0'/>
|
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
|
|
</controller>
|
|
|
|
{% for _key, _value in hostvars[item]['server_networks'].items()|sort(attribute='1.iface') %}
|
|
<interface type='network'>
|
|
{% if _key == hostvars[item]['server_vm_primary_network'] %}
|
|
<mac address='{{ hostvars[item]["server_mac_address"] | lower }}'/>
|
|
<boot order='2'/>
|
|
{% endif %}
|
|
<source network='{{ _value.vm_int_iface }}'/>
|
|
<model type='virtio'/>
|
|
</interface>
|
|
{% endfor %}
|
|
|
|
<serial type='pty'>
|
|
<source path='/dev/pts/4'/>
|
|
<target port='0'/>
|
|
<alias name='serial0'/>
|
|
</serial>
|
|
|
|
<console type='pty' tty='/dev/pts/4'>
|
|
<source path='/dev/pts/4'/>
|
|
<target type='serial' port='0'/>
|
|
<alias name='serial0'/>
|
|
</console>
|
|
|
|
<input type='mouse' bus='ps2'/>
|
|
|
|
<input type='keyboard' bus='ps2'/>
|
|
|
|
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'>
|
|
<listen type='address' address='127.0.0.1'/>
|
|
</graphics>
|
|
|
|
<video>
|
|
<model type='vmvga' vram='9216' heads='1'/>
|
|
<alias name='video0'/>
|
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
|
|
</video>
|
|
|
|
<memballoon model='virtio'>
|
|
<alias name='balloon0'/>
|
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
|
|
</memballoon>
|
|
|
|
<rng model='virtio'>
|
|
<backend model='random'>/dev/random</backend>
|
|
<alias name='rng0'/>
|
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
|
|
</rng>
|
|
|
|
</devices>
|
|
</domain>
|