Tomas Jelinek has uploaded a new change for review. Change subject: core: double cdrom and video devices if both template and instance type used ......................................................................
core: double cdrom and video devices if both template and instance type used The problem was that when both template and instance type is used, first all the devices has been copied from the instance type using the VmDeviceUtils.copyVmDevices (which creates by default also the cdrom and the video devices). Than, the disk and and CD device is copied from the template also using the VmDeviceUtils.copyVmDevices which again by default creates a new CD and video device. This way they are duplicated. Fixed by adding new parameters which controls if this devices are supposed to be copied or not. Change-Id: Id6dfbced0b702f3ce0e71283b1e7c4b4cf2604f6 Bug-Url: https://bugzilla.redhat.com/1109880 Signed-off-by: Tomas Jelinek <tjeli...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmAndCloneImageCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java 4 files changed, 30 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/29291/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmAndCloneImageCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmAndCloneImageCommand.java index 8104612..04f2ad0 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmAndCloneImageCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmAndCloneImageCommand.java @@ -464,7 +464,9 @@ getParameters().isConsoleEnabled(), isVirtioScsiEnabled(), isBalloonEnabled(), - false); + false, + true, + true); } protected abstract VM getVmFromConfiguration(); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index acc0fec..344eed8 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -816,7 +816,9 @@ getParameters().isConsoleEnabled(), isVirtioScsiEnabled(), isBalloonEnabled(), - false); + false, + instanceTypeId == null, // it will be copied from the template if this is an instance type + true); if (instanceTypeId != null) { copyDiskDevicesFromTemplate(); @@ -841,6 +843,8 @@ false, false, false, + false, + true, false ); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java index d357328..feeb1ec 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java @@ -261,7 +261,9 @@ getParameters().isConsoleEnabled(), getParameters().isVirtioScsiEnabled(), VmDeviceUtils.isBalloonEnabled(getVmId()), - false); + false, + true, + true); } else { // for instance type and new template without a VM VmDeviceUtils.copyVmDevices(VmTemplateHandler.BLANK_VM_TEMPLATE_ID, @@ -271,7 +273,9 @@ getParameters().isConsoleEnabled(), getParameters().isVirtioScsiEnabled(), getParameters().isBalloonEnabled(), - false); + false, + true, + true); } updateWatchdog(getVmTemplateId()); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java index ab66b5b..de54263 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java @@ -271,7 +271,9 @@ boolean isConsoleEnabled, Boolean isVirtioScsiEnabled, boolean isBalloonEnabled, - boolean copySnapshotDevices) { + boolean copySnapshotDevices, + boolean enableCreatingCdDevice, + boolean enableCreatingVideoDevice) { Guid id; String isoPath=vmBase.getIsoPath(); // indicates that VM should have CD either from its own (iso_path) or from the snapshot it was cloned from. @@ -390,7 +392,7 @@ dao.save(device); } // if VM does not has CD, add an empty CD - if (!shouldHaveCD) { + if (!shouldHaveCD && enableCreatingCdDevice) { addEmptyCD(dstId); } @@ -418,11 +420,13 @@ // update devices boot order updateBootOrderInVmDeviceAndStoreToDB(vmBase); - int numOfMonitors = (vmBase.getDefaultDisplayType() == DisplayType.vnc) ? Math.max(1, vmBase.getNumOfMonitors()) : - vmBase.getSingleQxlPci() ? 1 : vmBase.getNumOfMonitors(); - // create Video device. Multiple if display type is spice - for (int i = 0; i < numOfMonitors; i++) { - addVideoDevice(vmBase); + if (enableCreatingVideoDevice) { + int numOfMonitors = (vmBase.getDefaultDisplayType() == DisplayType.vnc) ? Math.max(1, vmBase.getNumOfMonitors()) : + vmBase.getSingleQxlPci() ? 1 : vmBase.getNumOfMonitors(); + // create Video device. Multiple if display type is spice + for (int i = 0; i < numOfMonitors; i++) { + addVideoDevice(vmBase); + } } } } @@ -449,7 +453,9 @@ boolean isConsoleEnabled, Boolean isVirtioScsiEnabled, boolean isBalloonEnabled, - boolean copySnapshotDevices) { + boolean copySnapshotDevices, + boolean enableCreatingCdDevice, + boolean enableCreatingVideoDevice) { VM vm = DbFacade.getInstance().getVmDao().get(dstId); VmBase vmBase = (vm != null) ? vm.getStaticData() : null; boolean isVm = (vmBase != null); @@ -460,7 +466,8 @@ List<VmDevice> devices = dao.getVmDeviceByVmId(srcId); copyVmDevices(srcId, dstId, vm, vmBase, isVm, devices, srcDeviceIdToTargetDeviceIdMapping, - soundDeviceEnabled, isConsoleEnabled, isVirtioScsiEnabled, isBalloonEnabled, copySnapshotDevices); + soundDeviceEnabled, isConsoleEnabled, isVirtioScsiEnabled, isBalloonEnabled, copySnapshotDevices, + enableCreatingCdDevice, enableCreatingVideoDevice); } private static void addVideoDevice(VmBase vm) { -- To view, visit http://gerrit.ovirt.org/29291 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id6dfbced0b702f3ce0e71283b1e7c4b4cf2604f6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches