Francesco Romani has uploaded a new change for review. Change subject: core: not migrate if dst host resolved to src host ......................................................................
core: not migrate if dst host resolved to src host Inhibit migration if destination hostname resolves to source host. In that case, libvirt will abort anyway, so this check just prevents to incur into a libvirt limitation. In addition, avoid to migrate to an host which resolves to localhost, which is rarely, if ever, a good thing. Change-Id: I7d05fb0c1f8108580edc391f87b9e95ffc2ae434 Bug-Url: https://bugzilla.redhat.com/1107650 Signed-off-by: Francesco Romani <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java 1 file changed, 35 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/30239/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java index 3e7354b..c472627 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java @@ -1,5 +1,7 @@ package org.ovirt.engine.core.bll; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -357,6 +359,11 @@ return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL); } + if (!isMigrationPossible(getVds(), getDestinationVds())) { + addCanDoActionMessage(VdcBllMessages.VAR__HOST_STATUS__UP); + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL); + } + return validate(new SnapshotsValidator().vmNotDuringSnapshot(vm.getId())) // This check was added to prevent migration of VM while its disks are being migrated // TODO: replace it with a better solution @@ -369,6 +376,34 @@ getReturnValue().getCanDoActionMessages()); } + // BZ#1107650 + private boolean isMigrationPossible(VDS srcVds, VDS dstVds) { + if (dstVds == null) { + return false; // must be sure + } + + if (srcVds.getHostName().equals(dstVds.getHostName())) { + return false; + } + + InetAddress srcAddress = null; + InetAddress dstAddress = null; + try { + srcAddress = InetAddress.getByName(srcVds.getHostName()); + dstAddress = InetAddress.getByName(dstVds.getHostName()); + } catch (UnknownHostException e) { + // no clues, better to not guess. Let libvirt sort out the mess, + // as it already did before. + return true; + } + + if (srcAddress != null && dstAddress != null && srcAddress.equals(dstAddress)) { + return false; + } + + return true; + } + @Override protected void setActionMessageParameters() { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__MIGRATE); -- To view, visit http://gerrit.ovirt.org/30239 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7d05fb0c1f8108580edc391f87b9e95ffc2ae434 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
