MNAIO: Move to using SCSI controller for TRIM support

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
This commit is contained in:
Jesse Pretorius 2018-08-23 13:20:25 +01:00
parent c556bea0d7
commit f3575be76a
7 changed files with 17 additions and 13 deletions

View File

@ -40,16 +40,20 @@
<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' cache='none' io='native'/>
<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='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
<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'/>

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726.
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \
umount /media || true

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726.
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \
umount /media || true

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726.
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \
umount /media || true
@ -90,7 +90,7 @@ d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/method string lvm
d-i partman-auto/disk string /dev/vda
d-i partman-auto/disk string /dev/sda
# For LVM partitioning, you can select how much of the volume group to use
# for logical volumes.
@ -111,7 +111,7 @@ d-i partman-auto/expert_recipe string \
1024 1 100% ext4 \
$primary{ } \
method{ lvm } \
device{ /dev/vda2 } \
device{ /dev/sda2 } \
vg_name{ vmvg00 } \
. \
2048 1 4096 linux-swap \

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726.
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \
umount /media || true
@ -90,7 +90,7 @@ d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/method string lvm
d-i partman-auto/disk string /dev/vda
d-i partman-auto/disk string /dev/sda
# For LVM partitioning, you can select how much of the volume group to use
# for logical volumes.
@ -111,7 +111,7 @@ d-i partman-auto/expert_recipe string \
1024 1 100% ext4 \
$primary{ } \
method{ lvm } \
device{ /dev/vda2 } \
device{ /dev/sda2 } \
vg_name{ vmvg00 } \
. \
2048 1 4096 linux-swap \

View File

@ -9,7 +9,7 @@ selinux --disabled
firewall --disabled
services --enabled=NetworkManager,sshd
eula --agreed
ignoredisk --only-use=vda
ignoredisk --only-use=sda
reboot
bootloader --location=mbr

View File

@ -9,7 +9,7 @@ selinux --disabled
firewall --disabled
services --enabled=NetworkManager,sshd
eula --agreed
ignoredisk --only-use=vda
ignoredisk --only-use=sda
reboot
bootloader --location=mbr