DaanHoogland commented on code in PR #13020:
URL: https://github.com/apache/cloudstack/pull/13020#discussion_r3958188774
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteDiskOnlyVMSnapshotCommandWrapper.java:
##########
@@ -53,6 +57,40 @@ public Answer execute(DeleteDiskOnlyVmSnapshotCommand
command, LibvirtComputingR
return new Answer(command, e);
}
}
+
+ deleteNvramSnapshotIfNeeded(command, resource, storagePoolMgr,
snapshotsToDelete);
return new Answer(command, true, null);
}
+
+ protected void deleteNvramSnapshotIfNeeded(DeleteDiskOnlyVmSnapshotCommand
command, LibvirtComputingResource resource, KVMStoragePoolManager
storagePoolMgr,
+ List<DataTO> snapshotsToDelete) {
+ if (StringUtils.isBlank(command.getNvramSnapshotPath())) {
+ return;
+ }
+
+ try {
+ KVMStoragePool storagePool;
+ if (command.getPrimaryDataStore() != null) {
+ PrimaryDataStoreTO dataStore = command.getPrimaryDataStore();
+ storagePool =
storagePoolMgr.getStoragePool(dataStore.getPoolType(), dataStore.getUuid());
+ } else {
+ SnapshotObjectTO rootVolumeSnapshot =
snapshotsToDelete.stream()
+ .map(SnapshotObjectTO.class::cast)
+ .filter(snapshotObjectTO ->
Volume.Type.ROOT.equals(snapshotObjectTO.getVolume().getVolumeType()))
+ .findFirst()
+ .orElse(null);
+
+ if (rootVolumeSnapshot == null) {
+ logger.warn("Unable to locate the root volume snapshot
while deleting NVRAM snapshot [{}].", command.getNvramSnapshotPath());
+ return;
+ }
+
+ storagePool =
resource.getLibvirtUtilitiesHelper().getPrimaryPoolFromDataTo(rootVolumeSnapshot,
storagePoolMgr);
+ }
+
+
Files.deleteIfExists(Path.of(storagePool.getLocalPathFor(command.getNvramSnapshotPath())));
Review Comment:
This looks like a valid security concern, @Kunalbehbud . Can you investigate
and rebute or apply?
--
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]