From ce3303212b5f9639ee91db52972fc9fd4b9a3c68 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Sat, 16 Dec 2017 14:19:28 +0530 Subject: [PATCH] CLOUDSTACK-9953: Resize root disk for VMware when full clone is enabled Resize for VMware root disk should only be performed during VM start when vmware.create.full.clone is true i.e. the disk chain length is one. Signed-off-by: Rohit Yadav --- .../vmware/resource/VmwareResource.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index c08a6120ebf..d8691505203 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -2178,9 +2178,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa hyperHost.setRestartPriorityForVM(vmMo, DasVmPriority.HIGH.value()); } - //For resizing root disk. + // For resizing root disk. if (rootDiskTO != null && !hasSnapshot) { - resizeRootDisk(vmMo, rootDiskTO, hyperHost, context); + resizeRootDiskOnVMStart(vmMo, rootDiskTO, hyperHost, context); } // @@ -2250,28 +2250,24 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa return path + fileType; } - private void resizeRootDisk(VirtualMachineMO vmMo, DiskTO rootDiskTO, VmwareHypervisorHost hyperHost, VmwareContext context) throws Exception - { - Pair vdisk = getVirtualDiskInfo(vmMo, appendFileType(rootDiskTO.getPath(), ".vmdk")); + private void resizeRootDiskOnVMStart(VirtualMachineMO vmMo, DiskTO rootDiskTO, VmwareHypervisorHost hyperHost, VmwareContext context) throws Exception { + final Pair vdisk = getVirtualDiskInfo(vmMo, appendFileType(rootDiskTO.getPath(), ".vmdk")); assert(vdisk != null); - Long reqSize=((VolumeObjectTO)rootDiskTO.getData()).getSize()/1024; - VirtualDisk disk = vdisk.first(); - if (reqSize > disk.getCapacityInKB()) - { - VirtualMachineDiskInfo diskInfo = getMatchingExistingDisk(vmMo.getDiskInfoBuilder(), rootDiskTO, hyperHost, context); + final Long reqSize = ((VolumeObjectTO)rootDiskTO.getData()).getSize() / 1024; + final VirtualDisk disk = vdisk.first(); + if (reqSize > disk.getCapacityInKB()) { + final VirtualMachineDiskInfo diskInfo = getMatchingExistingDisk(vmMo.getDiskInfoBuilder(), rootDiskTO, hyperHost, context); assert (diskInfo != null); - String[] diskChain = diskInfo.getDiskChain(); + final String[] diskChain = diskInfo.getDiskChain(); - if (diskChain != null && diskChain.length>1) - { - s_logger.error("Unsupported Disk chain length "+ diskChain.length); - throw new Exception("Unsupported Disk chain length "+ diskChain.length); + if (diskChain != null && diskChain.length > 1) { + s_logger.warn("Disk chain length for the VM is greater than one, skipping resizing of root disk."); + return; } - if (diskInfo.getDiskDeviceBusName() == null || !diskInfo.getDiskDeviceBusName().toLowerCase().startsWith("scsi")) - { - s_logger.error("Unsupported root disk device bus "+ diskInfo.getDiskDeviceBusName() ); - throw new Exception("Unsupported root disk device bus "+ diskInfo.getDiskDeviceBusName()); + if (diskInfo.getDiskDeviceBusName() == null || !diskInfo.getDiskDeviceBusName().toLowerCase().startsWith("scsi")) { + s_logger.warn("Resizing of root disk is only support for scsi device/bus, the provide disk's device bus name is " + diskInfo.getDiskDeviceBusName()); + return; } disk.setCapacityInKB(reqSize);