Skip to content

Commit 3b71ec8

Browse files
author
Fabrício Duarte
committed
Merge branch 'fix-lock-snapshot' into '4.20.0.0-scclouds'
Correção na criação de _snapshots_ incrementais Closes #3158 See merge request scclouds/scclouds!1323
2 parents 63acfa1 + f8f37f7 commit 3b71ec8

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2054,7 +2054,22 @@ protected void rebaseSnapshot(SnapshotObjectTO snapshotObjectTO, KVMStoragePool
20542054
QemuImg qemuImg = new QemuImg(wait);
20552055
qemuImg.rebase(snapshotFile, parentSnapshotFile, PhysicalDiskFormat.QCOW2.toString(), false);
20562056
} catch (LibvirtException | QemuImgException e) {
2057-
logger.error("Exception while rebasing incremental snapshot [{}] due to: [{}].", snapshotName, e.getMessage(), e);
2057+
if (!e.getMessage().contains("Is another process using the image")) {
2058+
logger.error("Exception while rebasing incremental snapshot [{}] due to: [{}].", snapshotName, e.getMessage(), e);
2059+
throw new CloudRuntimeException(e);
2060+
}
2061+
retryRebase(snapshotName, wait, e, snapshotFile, parentSnapshotFile);
2062+
}
2063+
}
2064+
2065+
private void retryRebase(String snapshotName, int wait, Exception e, QemuImgFile snapshotFile, QemuImgFile parentSnapshotFile) {
2066+
logger.warn("Libvirt still has not released the lock, will wait 60 seconds and try again later.");
2067+
try {
2068+
Thread.sleep(60*1000);
2069+
QemuImg qemuImg = new QemuImg(wait);
2070+
qemuImg.rebase(snapshotFile, parentSnapshotFile, PhysicalDiskFormat.QCOW2.toString(), false);
2071+
} catch (LibvirtException | QemuImgException | InterruptedException ex) {
2072+
logger.error("Unable to rebase snapshot [{}].", snapshotName, ex);
20582073
throw new CloudRuntimeException(e);
20592074
}
20602075
}

0 commit comments

Comments
 (0)