Omer Frenkel has uploaded a new change for review. Change subject: core: dont copy old num of sockets on hotplug ......................................................................
core: dont copy old num of sockets on hotplug when editing running vm, all fields that are not editable, are copied from the old vm to new vm, as they are saved in the running snapshot, and db reflect the actual running config. when user select to do hot-set to cpu, the number of sockets should not be copied with the old value, as it is used in the hot-set command. this is fixed by sending to the copy method, if this is a hot-set flow, and it will check it when doing copy of the old value, for hot-set allowed fields. Change-Id: I57bcd2287350c3146f06fe2a5c9a583c88dded04 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1151827 Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ObjectIdentityChecker.java 3 files changed, 19 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/34069/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java index 8bbe5b9..79863e5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java @@ -139,7 +139,7 @@ } if (getVm().isRunningOrPaused()) { - if (!VmHandler.copyNonEditableFieldsToDestination(oldVm.getStaticData(), newVmStatic)) { + if (!VmHandler.copyNonEditableFieldsToDestination(oldVm.getStaticData(), newVmStatic, isHotsetEnabled())) { // fail update vm if some fields could not be copied throw new VdcBLLException(VdcBllErrors.FAILED_UPDATE_RUNNING_VM); } @@ -148,7 +148,7 @@ UpdateVmNetworks(); updateVmNumaNodes(); - if (!getParameters().isApplyChangesLater()) { + if (isHotsetEnabled()) { hotSetCpus(cpuPerSocket, numOfSockets); } getVmStaticDAO().update(newVmStatic); @@ -676,10 +676,14 @@ !VmHandler.isUpdateValid(getVm().getStaticData(), getParameters().getVmStaticData(), getVm().getStatus(), - !getParameters().isApplyChangesLater()) || + isHotsetEnabled()) || !VmHandler.isUpdateValidForVmDevices(getVmId(), getVm().getStatus(), getParameters()); } + private boolean isHotsetEnabled() { + return !getParameters().isApplyChangesLater(); + } + @Override public List<PermissionSubject> getPermissionCheckSubjects() { final List<PermissionSubject> permissionList = super.getPermissionCheckSubjects(); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java index 09a4f74..195a1eb 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java @@ -163,8 +163,8 @@ return mUpdateVmsStatic.IsFieldUpdatable(status, fieldName, null); } - public static boolean copyNonEditableFieldsToDestination(VmStatic source, VmStatic destination) { - return mUpdateVmsStatic.copyNonEditableFieldsToDestination(source, destination); + public static boolean copyNonEditableFieldsToDestination(VmStatic source, VmStatic destination, boolean hotsetEnabled) { + return mUpdateVmsStatic.copyNonEditableFieldsToDestination(source, destination, hotsetEnabled); } /** diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ObjectIdentityChecker.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ObjectIdentityChecker.java index 74b2010..43d4d24 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ObjectIdentityChecker.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ObjectIdentityChecker.java @@ -94,6 +94,10 @@ return permitted.contains(name); } + public final boolean isHotsetField(String name) { + return hotsetAllowedFields.contains(name); + } + public boolean IsFieldUpdatable(Enum<?> status, String name, Object fieldContainer) { return IsFieldUpdatable(status, name, fieldContainer, false); } @@ -110,7 +114,7 @@ // if field is not updateable in this status, check if hotset request and its an hotset allowed field if (!returnValue && hotsetEnabled) { - returnValue = hotsetAllowedFields.contains(name); + returnValue = isHotsetField(name); } } if (!returnValue) { @@ -126,12 +130,15 @@ * @param source object that has values of non editable fields * @param destination object to copy the non editable to it */ - public boolean copyNonEditableFieldsToDestination(Object source, Object destination) { + public boolean copyNonEditableFieldsToDestination(Object source, Object destination, boolean hotsetEnabled) { Class<?> cls = source.getClass(); while (!cls.equals(Object.class)) { for (Field srcFld : cls.getDeclaredFields()) { try { - if (!Modifier.isFinal(srcFld.getModifiers()) && !IsFieldUpdatable(srcFld.getName())) { + // copy fields that are non final, and not-editable and not a hotset field or it is but this is not hotset case + if (!Modifier.isFinal(srcFld.getModifiers()) && + !IsFieldUpdatable(srcFld.getName()) && + (!isHotsetField(srcFld.getName()) || (isHotsetField(srcFld.getName()) && !hotsetEnabled))) { srcFld.setAccessible(true); Field dstFld = cls.getDeclaredField(srcFld.getName()); -- To view, visit http://gerrit.ovirt.org/34069 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I57bcd2287350c3146f06fe2a5c9a583c88dded04 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches