Skip to content

Commit bc677e2

Browse files
author
Likitha Shetty
committed
CLOUDSTACK-5782. [VMware] Snapshot creation on a detached volume failes with NPE.
For a detached volume, don't try to find the associated VM on the hypervisor/peer hypervisor host. By default create a worker VM to perform snapshot operations. Conflicts: plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
1 parent bb7fc3c commit bc677e2

1 file changed

Lines changed: 17 additions & 23 deletions

File tree

plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,32 +1000,26 @@ public Answer backupSnapshot(CopyCommand cmd) {
10001000
CopyCmdAnswer answer = null;
10011001

10021002
try {
1003-
vmMo = hyperHost.findVmOnHyperHost(vmName);
1004-
if (vmMo == null) {
1005-
if (s_logger.isDebugEnabled()) {
1006-
s_logger.debug("Unable to find owner VM for BackupSnapshotCommand on host " + hyperHost.getHyperHostName() + ", will try within datacenter");
1007-
}
1008-
1009-
vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
1003+
if(vmName != null) {
1004+
vmMo = hyperHost.findVmOnHyperHost(vmName);
10101005
if (vmMo == null) {
1011-
dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
1012-
1013-
workerVMName = hostService.getWorkerName(context, cmd, 0);
1014-
1015-
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
1016-
1017-
if (vmMo == null) {
1018-
throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
1006+
if(s_logger.isDebugEnabled()) {
1007+
s_logger.debug("Unable to find owner VM for BackupSnapshotCommand on host " + hyperHost.getHyperHostName() + ", will try within datacenter");
10191008
}
1020-
workerVm = vmMo;
1021-
1022-
// attach volume to worker VM
1023-
String datastoreVolumePath = dsMo.getDatastorePath(volumePath + ".vmdk");
1024-
vmMo.attachDisk(new String[] {datastoreVolumePath}, morDs);
1025-
} else {
1026-
s_logger.info("Using owner VM " + vmName + " for snapshot operation");
1027-
hasOwnerVm = true;
1009+
vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
1010+
}
1011+
}
1012+
if(vmMo == null) {
1013+
dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
1014+
workerVMName = hostService.getWorkerName(context, cmd, 0);
1015+
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
1016+
if (vmMo == null) {
1017+
throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
10281018
}
1019+
workerVm = vmMo;
1020+
// attach volume to worker VM
1021+
String datastoreVolumePath = dsMo.getDatastorePath(volumePath + ".vmdk");
1022+
vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
10291023
} else {
10301024
s_logger.info("Using owner VM " + vmName + " for snapshot operation");
10311025
hasOwnerVm = true;

0 commit comments

Comments
 (0)