@@ -571,9 +571,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
571
571
* 1st parameter: VM's name;<br>
572
572
* 2nd parameter: disk's label (target.dev tag from VM's XML);<br>
573
573
* 3rd parameter: the absolute path of the base file;
574
- * 4th parameter: the flag '--delete', if Libvirt supports it. Libvirt started to support it on version <b>6.0.0</b>;
575
574
*/
576
- private static final String COMMAND_MERGE_SNAPSHOT = "virsh blockcommit %s %s --base %s --active --wait %s --pivot " ;
575
+ private static final String COMMAND_MERGE_SNAPSHOT = "virsh blockcommit %s %s --base %s" ;
577
576
578
577
public long getHypervisorLibvirtVersion () {
579
578
return hypervisorLibvirtVersion ;
@@ -5878,7 +5877,7 @@ public void mergeSnapshotIntoBaseFile(Domain vm, String diskLabel, String baseFi
5878
5877
if (AgentPropertiesFileHandler .getPropertyValue (AgentProperties .LIBVIRT_EVENTS_ENABLED )) {
5879
5878
mergeSnapshotIntoBaseFileWithEventsAndConfigurableTimeout (vm , diskLabel , baseFilePath , topFilePath , active , snapshotName , volume , conn );
5880
5879
} else {
5881
- mergeSnapshotIntoBaseFileWithoutEvents (vm , diskLabel , baseFilePath , snapshotName , volume , conn );
5880
+ mergeSnapshotIntoBaseFileWithoutEvents (vm , diskLabel , baseFilePath , topFilePath , active , snapshotName , volume , conn );
5882
5881
}
5883
5882
}
5884
5883
@@ -5949,10 +5948,10 @@ protected void mergeSnapshotIntoBaseFileWithEventsAndConfigurableTimeout(Domain
5949
5948
* @param snapshotName Name of the snapshot;
5950
5949
* @throws LibvirtException
5951
5950
*/
5952
- protected void mergeSnapshotIntoBaseFileWithoutEvents (Domain vm , String diskLabel , String baseFilePath , String snapshotName , VolumeObjectTO volume , Connect conn ) throws LibvirtException {
5951
+ protected void mergeSnapshotIntoBaseFileWithoutEvents (Domain vm , String diskLabel , String baseFilePath , String topFilePath , boolean active , String snapshotName , VolumeObjectTO volume , Connect conn ) throws LibvirtException {
5953
5952
boolean isLibvirtSupportingFlagDeleteOnCommandVirshBlockcommit = LibvirtUtilitiesHelper .isLibvirtSupportingFlagDeleteOnCommandVirshBlockcommit (conn );
5954
5953
String vmName = vm .getName ();
5955
- String mergeCommand = String . format ( COMMAND_MERGE_SNAPSHOT , vmName , diskLabel , baseFilePath , isLibvirtSupportingFlagDeleteOnCommandVirshBlockcommit ? "--delete" : "" );
5954
+ String mergeCommand = buildMergeCommand ( vmName , diskLabel , baseFilePath , topFilePath , active , isLibvirtSupportingFlagDeleteOnCommandVirshBlockcommit );
5956
5955
String mergeResult = Script .runSimpleBashScript (mergeCommand );
5957
5956
5958
5957
if (mergeResult == null ) {
@@ -5969,6 +5968,22 @@ protected void mergeSnapshotIntoBaseFileWithoutEvents(Domain vm, String diskLabe
5969
5968
throw new CloudRuntimeException (errorMsg );
5970
5969
}
5971
5970
5971
+ protected String buildMergeCommand (String vmName , String diskLabel , String baseFilePath , String topFilePath , boolean active , boolean delete ) {
5972
+ StringBuilder cmd = new StringBuilder (COMMAND_MERGE_SNAPSHOT );
5973
+ if (StringUtils .isNotEmpty (topFilePath )) {
5974
+ cmd .append (" --top " );
5975
+ cmd .append (topFilePath );
5976
+ }
5977
+ if (active ) {
5978
+ cmd .append (" --active --pivot" );
5979
+ }
5980
+ if (delete ) {
5981
+ cmd .append (" --delete" );
5982
+ }
5983
+ cmd .append (" --wait" );
5984
+ return String .format (cmd .toString (), vmName , diskLabel , baseFilePath );
5985
+ }
5986
+
5972
5987
/**
5973
5988
* This was created to facilitate testing.
5974
5989
* */
0 commit comments