}
}
if ( dsthost == null ) {
String msg = "Migration failed due to unable to find host " + ipaddr + " in XenServer pool " + _host.pool;
s_logger.warn(msg);
return new MigrateAnswer(cmd, false, msg, null);
}
for (VM vm : vms) {
Set<VBD> vbds = vm.getVBDs(conn);
for( VBD vbd : vbds) {
VBD.Record vbdRec = vbd.getRecord(conn);
if( vbdRec.type.equals(Types.VbdType.CD.toString()) && !vbdRec.empty ) {
vbd.eject(conn);
break;
}
}
migrateVM(conn, dsthost, vm, vmName);
vm.setAffinity(conn, dsthost);
state = State.Stopping;
}
return new MigrateAnswer(cmd, true, "migration succeeded", null);
} catch (Exception e) {
String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed due to " + e.toString();
s_logger.warn(msg, e);
return new MigrateAnswer(cmd, false, msg, null);
} finally {
synchronized (_cluster.intern()) {
s_vms.put(_cluster, _name, vmName, state);
}
s_logger.debug("6. The VM " + vmName + " is in " + state + " state");