Skip to content

Commit aa35e57

Browse files
committed
fix incremental snapshot creation
1 parent 30e6c22 commit aa35e57

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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
@@ -2093,7 +2093,22 @@ protected void rebaseSnapshot(SnapshotObjectTO snapshotObjectTO, KVMStoragePool
20932093
QemuImg qemuImg = new QemuImg(wait);
20942094
qemuImg.rebase(snapshotFile, parentSnapshotFile, PhysicalDiskFormat.QCOW2.toString(), false);
20952095
} catch (LibvirtException | QemuImgException e) {
2096-
logger.error("Exception while rebasing incremental snapshot [{}] due to: [{}].", snapshotName, e.getMessage(), e);
2096+
if (!e.getMessage().contains("Is another process using the image")) {
2097+
logger.error("Exception while rebasing incremental snapshot [{}] due to: [{}].", snapshotName, e.getMessage(), e);
2098+
throw new CloudRuntimeException(e);
2099+
}
2100+
retryRebase(snapshotName, wait, e, snapshotFile, parentSnapshotFile);
2101+
}
2102+
}
2103+
2104+
private void retryRebase(String snapshotName, int wait, Exception e, QemuImgFile snapshotFile, QemuImgFile parentSnapshotFile) {
2105+
logger.warn("Libvirt still has not released the lock, will wait 60 seconds and try again later.");
2106+
try {
2107+
Thread.sleep(60*1000);
2108+
QemuImg qemuImg = new QemuImg(wait);
2109+
qemuImg.rebase(snapshotFile, parentSnapshotFile, PhysicalDiskFormat.QCOW2.toString(), false);
2110+
} catch (LibvirtException | QemuImgException | InterruptedException ex) {
2111+
logger.error("Unable to rebase snapshot [{}].", snapshotName, ex);
20972112
throw new CloudRuntimeException(e);
20982113
}
20992114
}

0 commit comments

Comments
 (0)