Arik Hadas has uploaded a new change for review. Change subject: restapi: fix NPE when adding vm with no cpu mode ......................................................................
restapi: fix NPE when adding vm with no cpu mode A check whether the lately added attribute 'cpu mode' is defined (set) in a request before trying to map it to enum value was missing, thus creating a NPE. Change-Id: I94b2269a952e4dedcd08ee4b22940aeca020fb4c Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/10372/1 diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java index a7ce807..de1d894 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java @@ -123,7 +123,9 @@ staticVm.setvds_group_id(new Guid(vm.getCluster().getId())); } if (vm.isSetCpu()) { - staticVm.setUseHostCpuFlags(CpuMode.fromValue(vm.getCpu().getMode()) == CpuMode.HOST_PASSTHROUGH); + if (vm.getCpu().isSetMode()) { + staticVm.setUseHostCpuFlags(CpuMode.fromValue(vm.getCpu().getMode()) == CpuMode.HOST_PASSTHROUGH); + } if (vm.getCpu().isSetTopology()) { if (vm.getCpu().getTopology().getCores()!=null) { staticVm.setcpu_per_socket(vm.getCpu().getTopology().getCores()); -- To view, visit http://gerrit.ovirt.org/10372 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I94b2269a952e4dedcd08ee4b22940aeca020fb4c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches