Skip to content

Commit 15f99d8

Browse files
JoaoJandredhslove
authored andcommitted
Fix KVM incremental snapshot removal when using multiple secondary storages (apache#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 05a8577 commit 15f99d8

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
@@ -157,7 +157,9 @@ protected SnapshotInfo getCorrectIncrementalParent(long parentId) {
157157
@Override
158158
public SnapshotInfo getChild() {
159159
QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class);
160-
sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId());
160+
if (!HypervisorType.KVM.equals(snapshot.getHypervisorType())) {
161+
sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId());
162+
}
161163
sc.and(sc.entity().getRole(), Op.EQ, store.getRole());
162164
sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error);
163165
sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId());

0 commit comments

Comments
 (0)