@@ -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