@@ -2093,8 +2093,25 @@ 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 );
2097- throw new CloudRuntimeException (e );
2096+ if (!StringUtils .contains (e .getMessage (), "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 );
2112+ CloudRuntimeException cre = new CloudRuntimeException (ex );
2113+ cre .addSuppressed (e );
2114+ throw cre ;
20982115 }
20992116 }
21002117
0 commit comments