Skip to content

Commit 9675df5

Browse files
update payload with quiescevm when set for vm snapshot
1 parent f1c1568 commit 9675df5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
183183
thawAnswer = (FreezeThawVMAnswer) agentMgr.send(hostId, thawCmd);
184184
if (thawAnswer != null && thawAnswer.getResult()) {
185185
s_logger.info(String.format(
186-
"Virtual machne is thawed. The freeze of virtual machine took %s milliseconds.",
186+
"Virtual machine is thawed. The freeze of virtual machine took %s milliseconds.",
187187
TimeUnit.MILLISECONDS.convert(elapsedTime(startFreeze), TimeUnit.NANOSECONDS)));
188188
}
189189
} else {
@@ -429,9 +429,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
429429
String snapshotName = vmSnapshot.getId() + "_" + vol.getUuid();
430430
SnapshotVO snapshot = new SnapshotVO(vol.getDataCenterId(), vol.getAccountId(), vol.getDomainId(), vol.getId(), vol.getDiskOfferingId(),
431431
snapshotName, (short) Snapshot.Type.GROUP.ordinal(), Snapshot.Type.GROUP.name(), vol.getSize(), vol.getMinIops(), vol.getMaxIops(), Hypervisor.HypervisorType.KVM, null);
432+
VMSnapshotOptions options = ((VMSnapshotVO) vmSnapshot).getOptions();
433+
boolean quiescevm = false;
434+
if (options != null) {
435+
quiescevm = options.needQuiesceVM();
436+
}
432437

433438
snapshot = snapshotDao.persist(snapshot);
434-
vol.addPayload(setPayload(vol, snapshot));
439+
vol.addPayload(setPayload(vol, snapshot, quiescevm));
435440
SnapshotInfo snapshotInfo = snapshotDataFactory.getSnapshot(snapshot.getId(), vol.getDataStore());
436441
snapshotInfo.addPayload(vol.getpayload());
437442
SnapshotStrategy snapshotStrategy = storageStrategyFactory.getSnapshotStrategy(snapshotInfo, SnapshotOperation.TAKE);
@@ -449,14 +454,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
449454
return snapshotInfo;
450455
}
451456

452-
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate) {
457+
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate, boolean quiescevm) {
453458
CreateSnapshotPayload payload = new CreateSnapshotPayload();
454459
payload.setSnapshotId(snapshotCreate.getId());
455460
payload.setSnapshotPolicyId(SnapshotVO.MANUAL_POLICY_ID);
456461
payload.setLocationType(snapshotCreate.getLocationType());
457462
payload.setAccount(accountService.getAccount(vol.getAccountId()));
458463
payload.setAsyncBackup(false);
459-
payload.setQuiescevm(false);
464+
payload.setQuiescevm(quiescevm);
460465
return payload;
461466
}
462467
}

server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
14161416
}
14171417
} catch (CloudRuntimeException cre) {
14181418
if (s_logger.isDebugEnabled()) {
1419-
s_logger.debug("Failed to create snapshot" + cre.getLocalizedMessage());
1419+
s_logger.debug("Failed to create snapshot - " + cre.getLocalizedMessage());
14201420
}
14211421
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
14221422
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize()));

0 commit comments

Comments
 (0)