@@ -2095,7 +2095,15 @@ public Answer createSnapshot(final CreateObjectCommand cmd) {
20952095 String diskPath = disk .getPath ();
20962096 String snapshotPath = diskPath + File .separator + snapshotName ;
20972097 SnapshotObjectTO newSnapshot = new SnapshotObjectTO ();
2098- if (DomainInfo .DomainState .VIR_DOMAIN_RUNNING .equals (state ) && !primaryPool .isExternalSnapshot ()) {
2098+ boolean isClvmNgIncremental = primaryPool .getType () == StoragePoolType .CLVM_NG && snapshotTO .isKvmIncrementalSnapshot ();
2099+ if (isClvmNgIncremental && secondaryPool == null ) {
2100+ String errorMsg = String .format ("Incremental snapshots for CLVM_NG require secondary storage. " +
2101+ "Please configure secondary storage or disable incremental snapshots for volume [%s]." , volume .getName ());
2102+ logger .error (errorMsg );
2103+ return new CreateObjectAnswer (errorMsg );
2104+ }
2105+ boolean isLiveClvmNgIncremental = isClvmNgIncremental && (DomainInfo .DomainState .VIR_DOMAIN_RUNNING .equals (state ) || DomainInfo .DomainState .VIR_DOMAIN_PAUSED .equals (state ));
2106+ if ((DomainInfo .DomainState .VIR_DOMAIN_RUNNING .equals (state ) && !primaryPool .isExternalSnapshot ()) || isLiveClvmNgIncremental ) {
20992107 if (snapshotTO .isKvmIncrementalSnapshot ()) {
21002108 newSnapshot = takeIncrementalVolumeSnapshotOfRunningVm (snapshotTO , primaryPool , secondaryPool , imageStoreTo != null ? imageStoreTo .getUrl () : null , snapshotName , volume , vm , conn , cmd .getWait ());
21012109 } else {
@@ -2109,13 +2117,7 @@ public Answer createSnapshot(final CreateObjectCommand cmd) {
21092117 newSnapshot .setPhysicalSize (snapshotSize );
21102118 }
21112119 } else if (primaryPool .getType () == StoragePoolType .CLVM || primaryPool .getType () == StoragePoolType .CLVM_NG ) {
2112- if (primaryPool .getType () == StoragePoolType .CLVM_NG && snapshotTO .isKvmIncrementalSnapshot ()) {
2113- if (secondaryPool == null ) {
2114- String errorMsg = String .format ("Incremental snapshots for CLVM_NG require secondary storage. " +
2115- "Please configure secondary storage or disable incremental snapshots for volume [%s]." , volume .getName ());
2116- logger .error (errorMsg );
2117- return new CreateObjectAnswer (errorMsg );
2118- }
2120+ if (isClvmNgIncremental ) {
21192121 logger .info ("Taking incremental snapshot of CLVM_NG volume [{}] using QCOW2 backup to secondary storage." , volume .getName ());
21202122 newSnapshot = takeIncrementalVolumeSnapshotOfStoppedVm (snapshotTO , primaryPool , secondaryPool ,
21212123 imageStoreTo .getUrl (), snapshotName , volume , conn , cmd .getWait ());
0 commit comments