Skip to content

Commit 6ad9296

Browse files
authored
Fix KVM incremental snapshot removal when using multiple secondary storages (#11180)
When removing an incremental snapshot (For both KVM and XenServer), it is checked if the snapshot has a child or not. If it has, then the snapshot is not removed from the storage. For KVM incremental snapshots, snapshots in the same chain may be on different secondary storages (within the same zone). However, the child search process only considers snapshots from the same secondary storage as theirs. Therefore, if a snapshot has its parent snapshot on a different secondary storage, it will be completely removed, making the snapshot chain inconsistent.
1 parent c5da9e6 commit 6ad9296

File tree

1 file changed

+3
-1
lines changed
  • engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot

1 file changed

+3
-1
lines changed

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ protected SnapshotInfo getCorrectIncrementalParent(long parentId) {
155155
@Override
156156
public SnapshotInfo getChild() {
157157
QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class);
158-
sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId());
158+
if (!HypervisorType.KVM.equals(snapshot.getHypervisorType())) {
159+
sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId());
160+
}
159161
sc.and(sc.entity().getRole(), Op.EQ, store.getRole());
160162
sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error);
161163
sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId());

0 commit comments

Comments
 (0)