Skip to content

Commit 0062ff2

Browse files
committed
CLOUDSTACK-8748: VM UUID accessible in CreateVMSnapshotCommand and RevertToVMSnapshotCommand
This patch makes it possible to expose VM UUID to subsystems, this can be useful for implementing VM Snapshots for KVM in future. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 1a106ec commit 0062ff2

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎core/src/com/cloud/agent/api/CreateVMSnapshotCommand.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@
2525

2626

2727
public class CreateVMSnapshotCommand extends VMSnapshotBaseCommand {
28+
private String vmUuid;
2829

29-
public CreateVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
30+
public CreateVMSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
3031
super(vmName, snapshot, volumeTOs, guestOSType);
32+
this.vmUuid = vmUuid;
33+
}
34+
35+
public String getVmUuid() {
36+
return vmUuid;
3137
}
3238
}

‎core/src/com/cloud/agent/api/RevertToVMSnapshotCommand.java‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@
2525

2626
public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
2727

28-
public RevertToVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
28+
public RevertToVMSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
2929
super(vmName, snapshot, volumeTOs, guestOSType);
30+
this.vmUuid = vmUuid;
3031
}
3132

32-
public RevertToVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType, boolean reloadVm) {
33-
this(vmName, snapshot, volumeTOs, guestOSType);
33+
public RevertToVMSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType, boolean reloadVm) {
34+
this(vmName, vmUuid, snapshot, volumeTOs, guestOSType);
3435
setReloadVm(reloadVm);
3536
}
3637

3738
private boolean reloadVm = false;
39+
private String vmUuid;
3840

3941
public boolean isReloadVm() {
4042
return reloadVm;
@@ -43,4 +45,8 @@ public boolean isReloadVm() {
4345
public void setReloadVm(boolean reloadVm) {
4446
this.reloadVm = reloadVm;
4547
}
48+
49+
public String getVmUuid() {
50+
return vmUuid;
51+
}
4652
}

‎engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
137137
HostVO host = hostDao.findById(hostId);
138138
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion());
139139

140-
CreateVMSnapshotCommand ccmd = new CreateVMSnapshotCommand(userVm.getInstanceName(), target, volumeTOs, guestOS.getDisplayName());
140+
CreateVMSnapshotCommand ccmd = new CreateVMSnapshotCommand(userVm.getInstanceName(), userVm.getUuid(), target, volumeTOs, guestOS.getDisplayName());
141141
if (guestOsMapping == null) {
142142
ccmd.setPlatformEmulator(null);
143143
} else {
@@ -350,7 +350,7 @@ public boolean revertVMSnapshot(VMSnapshot vmSnapshot) {
350350
snapshot.getCurrent(), parent, true);
351351
Long hostId = vmSnapshotHelper.pickRunningHost(vmSnapshot.getVmId());
352352
GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId());
353-
RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
353+
RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, userVm.getUuid(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
354354
HostVO host = hostDao.findById(hostId);
355355
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion());
356356
if (guestOsMapping == null) {

‎engine/storage/src/org/apache/cloudstack/storage/helper/HypervisorHelperImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public VMSnapshotTO quiesceVm(VirtualMachine virtualMachine) {
124124
GuestOSVO guestOS = guestOSDao.findById(virtualMachine.getGuestOSId());
125125
List<VolumeObjectTO> volumeTOs = vmSnapshotHelper.getVolumeTOList(virtualMachine.getId());
126126
CreateVMSnapshotCommand ccmd =
127-
new CreateVMSnapshotCommand(virtualMachine.getInstanceName(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
127+
new CreateVMSnapshotCommand(virtualMachine.getInstanceName(), virtualMachine.getUuid(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
128128
HostVO host = hostDao.findById(hostId);
129129
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion());
130130
ccmd.setPlatformEmulator(guestOsMapping.getGuestOsName());

0 commit comments

Comments
 (0)