Copilot commented on code in PR #13857:
URL: https://github.com/apache/cloudstack/pull/13857#discussion_r3813930000


##########
plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java:
##########
@@ -190,6 +222,16 @@ public static String 
syncVolumeToVmDefaultFolder(DatacenterMO dcMo, String vmNam
             syncVolumeToRootFolder(dcMo, ds, vmdkName, vmName, excludeFolders);
         }
 
+        if (targetAdapterType != null && 
ds.fileExists(vmdkLinkedCloneModeLegacyPair[0])) {
+            String vmwarePath = vmdkLinkedCloneModePair[0];
+            LOGGER.info("sync " + vmdkLinkedCloneModeLegacyPair[0] + "->" + 
vmwarePath);
+            VirtualDiskManagerMO diskManager = new 
VirtualDiskManagerMO(ds.getContext());
+            FileBackedVirtualDiskSpec diskSpec = 
createDiskSpec(targetAdapterType, provisioningType);
+            diskManager.copyVirtualDisk(vmdkLinkedCloneModeLegacyPair[0], 
dcMo.getMor(), vmwarePath, dcMo.getMor(), diskSpec, true);
+            diskManager.deleteVirtualDisk(vmdkLinkedCloneModeLegacyPair[0], 
dcMo.getMor());
+            return new Pair<>(vmwarePath, true);

Review Comment:
   This only migrates a legacy/base-folder VMDK when `targetAdapterType != 
null`. If `vmdkLinkedCloneModeLegacyPair[0]` exists but `targetAdapterType` is 
null (i.e., callers using the existing String-returning overloads), the method 
will skip the migration and later return `vmdkLinkedCloneModePair[0]` even 
though it may not exist. Consider handling the legacy/base-folder case 
regardless: if `targetAdapterType` is null, `moveVirtualDisk(...)` (or return 
the existing legacy path) to preserve the previous contract that the returned 
path points to an existing disk when one is found.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to