Skip to content

Commit 8d7f625

Browse files
committed
Disable shrinking QCOW2 volumes
Since QCOW2 volumes cannot be resized to lower value in any case, just disable it in backend.
1 parent 0cca854 commit 8d7f625

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,14 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10541054
* This will be checked again at the hypervisor level where we can see
10551055
* the actual disk size.
10561056
*/
1057+
if (currentSize > newSize) {
1058+
VolumeVO vol = _volsDao.findById(cmd.getEntityId());
1059+
if (vol != null && ImageFormat.QCOW2.equals(vol.getFormat()) && !Volume.State.Allocated.equals(volume.getState())) {
1060+
String message = "Unable to shrink volumes of type QCOW2";
1061+
s_logger.warn(message);
1062+
throw new InvalidParameterValueException(message);
1063+
}
1064+
}
10571065
if (currentSize > newSize && !shrinkOk) {
10581066
throw new InvalidParameterValueException("Going from existing size of " + currentSize + " to size of " + newSize + " would shrink the volume."
10591067
+ "Need to sign off by supplying the shrinkok parameter with value of true.");

0 commit comments

Comments
 (0)