@@ -4766,7 +4766,13 @@ protected Answer execute(MigrateCommand cmd) {
47664766 final String vmName = cmd .getVmName ();
47674767 try {
47684768 VmwareHypervisorHost hyperHost = getHyperHost (getServiceContext ());
4769+ if (hyperHost == null ) {
4770+ throw new CloudRuntimeException ("no hypervisor host found for migrate command" );
4771+ }
47694772 ManagedObjectReference morDc = hyperHost .getHyperHostDatacenter ();
4773+ if (morDc == null ) {
4774+ throw new CloudRuntimeException ("no Managed Object Reference for the Data Center found for migrate command" );
4775+ }
47704776
47714777 // find VM through datacenter (VM is not at the target host yet)
47724778 VirtualMachineMO vmMo = hyperHost .findVmOnPeerHyperHost (vmName );
@@ -4777,6 +4783,9 @@ protected Answer execute(MigrateCommand cmd) {
47774783 }
47784784
47794785 VmwareHypervisorHost destHyperHost = getTargetHyperHost (new DatacenterMO (hyperHost .getContext (), morDc ), cmd .getDestinationIp ());
4786+ if (destHyperHost == null ) {
4787+ throw new CloudRuntimeException ("no destination Hypervisor Host found for migrate command" );
4788+ }
47804789
47814790 ManagedObjectReference morTargetPhysicalHost = destHyperHost .findMigrationTarget (vmMo );
47824791 if (morTargetPhysicalHost == null ) {
@@ -4788,7 +4797,8 @@ protected Answer execute(MigrateCommand cmd) {
47884797 }
47894798
47904799 return new MigrateAnswer (cmd , true , "migration succeeded" , null );
4791- } catch (Throwable e ) {
4800+ } catch (Exception e ) {
4801+ s_logger .info (String .format ("migrate command for %s failed due to %s" , vmName , e .getLocalizedMessage ()));
47924802 return new MigrateAnswer (cmd , false , createLogMessageException (e , cmd ), null );
47934803 }
47944804 }
0 commit comments