Skip to content

Commit 2622856

Browse files
authored
kvm: Disable shrinking QCOW2 volumes (#4679)
Since QCOW2 volumes cannot be resized to lower value in any case, just disable it in backend.
1 parent 7208fac commit 2622856

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
@@ -1061,6 +1061,14 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10611061
* This will be checked again at the hypervisor level where we can see
10621062
* the actual disk size.
10631063
*/
1064+
if (currentSize > newSize) {
1065+
VolumeVO vol = _volsDao.findById(cmd.getEntityId());
1066+
if (vol != null && ImageFormat.QCOW2.equals(vol.getFormat()) && !Volume.State.Allocated.equals(volume.getState())) {
1067+
String message = "Unable to shrink volumes of type QCOW2";
1068+
s_logger.warn(message);
1069+
throw new InvalidParameterValueException(message);
1070+
}
1071+
}
10641072
if (currentSize > newSize && !shrinkOk) {
10651073
throw new InvalidParameterValueException("Going from existing size of " + currentSize + " to size of " + newSize + " would shrink the volume."
10661074
+ "Need to sign off by supplying the shrinkok parameter with value of true.");

0 commit comments

Comments
 (0)