Skip to content

Commit

Permalink
core: adjust volume size when converting to cow/preallocated
Browse files Browse the repository at this point in the history
When converting to COW/Prellocated from RAW additional size may be
required for the qcow header. We already measure required size, however
we only use it for the initial size of the volume which is not used when
the target is a preallocated volume on block storage.

This patch uses required size to increase the target volume if it's
larger than the current size of the volume to ensure there is enough
space to perform the conversion.

Bug-Url: https://bugzilla.redhat.com/2076047
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
  • Loading branch information
bennyz committed Apr 26, 2022
1 parent 096b053 commit eebd01d
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,22 @@ protected void executeCommand() {
return;
}

long requiredSize = actionReturnValue.getActionReturnValue();
long requiredSize = actionReturnValue.getActionReturnValue();

CreateVolumeContainerCommandParameters parameters = createVolumeCreationParameters(getDiskImage(), requiredSize);

// Initial size will not be used for this configuration, meaning the required size will not
// be used at all. However, when converting to COW/Preallocated the required size may be larger
if (parameters.getVolumeType() == VolumeType.Preallocated &&
parameters.getVolumeFormat() == VolumeFormat.COW) {
parameters.setSize(Math.max(getDiskImage().getSize(), requiredSize));
if (parameters.getSize() > getDiskImage().getSize()) {
log.info("Updated disk's '{}' size to: '{}'", getDiskImage().getId(), parameters.getSize());
}
}

// Create volume in the same disk
runInternalAction(ActionType.CreateVolumeContainer,
createVolumeCreationParameters(getDiskImage(), requiredSize),
runInternalAction(ActionType.CreateVolumeContainer, parameters,
ExecutionHandler.createDefaultContextForTasks(getContext()));
updatePhase(ConvertDiskCommandParameters.ConvertDiskPhase.CONVERT_VOLUME);

Expand Down

0 comments on commit eebd01d

Please sign in to comment.