Skip to content

Commit

Permalink
Added discard-no-unref support to CL 4.8
Browse files Browse the repository at this point in the history
The discard-no-unref was introduced to qemu to counteract fragmentation. Without this, qcow2 images would grow over 100% of their size. See https://patchew.org/QEMU/20230602124747.1544077-1-jean-louis@dupond.be/

I have added the option to ovirt-engine so that this flag is enabled by default on hosts with cluster level compatibility level 4.8. The EnableQemuDiscardNoUnref option can be enabled/disabled in the config. The Virtual Disk option 'Enable Discard' also needs to be active before this flag is enabled.

Signed-off-by: Brooklyn Dewolf <contact@brooklyn.gent>
  • Loading branch information
BrooklynDewolf committed Apr 30, 2024
1 parent 27559ec commit 668f967
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,9 @@ public enum ConfigValues {
@TypeConverterAttribute(Boolean.class)
IsDedicatedSupported,

@TypeConverterAttribute(Boolean.class)
EnableQemuDiscardNoUnref,

Invalid;

private ClientAccessLevel accessLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,9 @@ private void writeDiskDriver(VmDevice device, Disk disk, DiskVmElement dve, int
writer.writeAttributeString("name", "qemu");
if (dve.isPassDiscard()) {
writer.writeAttributeString("discard", "unmap");
if ((boolean) Config.getValue(ConfigValues.EnableQemuDiscardNoUnref, vm.getClusterCompatibilityVersion().toString())) {
writer.writeAttributeString("discard_no_unref", "on");
}
}
if (pinTo > 0) {
writer.writeAttributeString("iothread", String.valueOf(pinTo));
Expand Down
2 changes: 2 additions & 0 deletions packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ select fn_db_add_config_value_for_versions_up_to('ParallelMigrationsSupported',
select fn_db_add_config_value_for_versions_up_to('ParallelMigrationsSupported', 'true', '4.8');
select fn_db_add_config_value_for_versions_up_to('IsDedicatedSupported', 'false', '4.6');
select fn_db_add_config_value_for_versions_up_to('IsDedicatedSupported', 'true', '4.8');
select fn_db_add_config_value_for_versions_up_to('EnableQemuDiscardNoUnref', 'false', '4.7');
select fn_db_add_config_value_for_versions_up_to('EnableQemuDiscardNoUnref', 'true', '4.8');

-- Incremental backup
select fn_db_add_config_value_for_versions_up_to('IsIncrementalBackupSupported', 'false', '4.4');
Expand Down
3 changes: 3 additions & 0 deletions packaging/etc/engine-config/engine-config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,6 @@ CertExpirationWarnPeriodInDays.description=Number of days to issue warnings befo
CertExpirationWarnPeriodInDays.type=Integer
VdsCertificateValidityInDays.description=Number of days which the hypervisor certificate is valid for.
VdsCertificateValidityInDays.type=Integer
# Discard no Unref
EnableQemuDiscardNoUnref.description=Enable the QEMU discard-no-unref feature.
EnableQemuDiscardNoUnref.type=Boolean

0 comments on commit 668f967

Please sign in to comment.