Arik Hadas has uploaded a new change for review. Change subject: core: add missing sound card for imported vm ......................................................................
core: add missing sound card for imported vm This patch solves a bug in which when importing desktop vm that doesn't have sound card device (which is the case when importing vm that was created in 3.0 for example), the resulting vm won't have sound device. The solution is to check the imported vm and if it is desktop vm and it doesn't have sound device, we add sound device to it. Change-Id: I295d158f014f865be5a03f630ce48ba446752e5e Bug-Url: https://bugzilla.redhat.com/955498 Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java 1 file changed, 24 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/14607/1 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 908b937..2c4eda3 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 @@ -238,14 +238,8 @@ // create sound card for a desktop VM if not exists if (vmBase.getVmType() == VmType.Desktop) { List<VmDevice> list = DbFacade.getInstance().getVmDeviceDao().getVmDeviceByVmIdAndType(vmBase.getId(), VmDeviceType.SOUND.getName()); - if (list.size() == 0) { - String soundDevice = VmInfoBuilderBase.getSoundDevice(vm.getStaticData(), vm.getVdsGroupCompatibilityVersion()); - addManagedDevice(new VmDeviceId(Guid.NewGuid(), vmBase.getId()), - VmDeviceType.SOUND, - VmDeviceType.getSoundDeviceType(soundDevice), - new HashMap<String, Object>(), - true, - true); + if (list.isEmpty()) { + addSoundCard(vm.getStaticData(), vm.getVdsGroupCompatibilityVersion()); } } int numOfMonitors = (vm.getDisplayType() == DisplayType.vnc) ? Math.max(1, vm.getNumOfMonitors()) : vm.getNumOfMonitors(); @@ -256,6 +250,21 @@ } } + + private static void addSoundCard(VmBase vmBase) { + addSoundCard(vmBase, ClusterUtils.getCompatilibilyVersion(vmBase)); + } + + private static void addSoundCard(VmBase vmBase, Version vdsGroupCompatibilityVersion) { + String soundDevice = VmInfoBuilderBase.getSoundDevice(vmBase, vdsGroupCompatibilityVersion); + addManagedDevice(new VmDeviceId(Guid.NewGuid(), vmBase.getId()), + VmDeviceType.SOUND, + VmDeviceType.getSoundDeviceType(soundDevice), + new HashMap<String, Object>(), + true, + true); + } + /** * Copies relevant entries on "Vm from Template" or "Template from VM" creation. * @@ -652,6 +661,7 @@ */ private static <T extends VmBase> void addOtherDevices(T entity, List<VmDevice> vmDeviceToAdd) { boolean hasCD = false; + boolean hasSoundCard = false; for (VmDevice vmDevice : entity.getManagedDeviceMap().values()) { if (isDiskOrInterface(vmDevice)) { continue; // skip disks/interfaces that were added separately. @@ -663,11 +673,17 @@ if (vmDevice.getDevice().equals(VmDeviceType.CDROM.getName())){ hasCD = true; } + if (vmDevice.getDevice().equals(VmDeviceType.SOUND.getName())){ + hasSoundCard = true; + } vmDeviceToAdd.add(vmDevice); } if (!hasCD) { // add an empty CD addEmptyCD(entity.getId()); } + if (!hasSoundCard && entity.getVmType() == VmType.Desktop) { + addSoundCard(entity); + } for (VmDevice vmDevice : entity.getUnmanagedDeviceList()) { vmDeviceToAdd.add(vmDevice); } -- To view, visit http://gerrit.ovirt.org/14607 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I295d158f014f865be5a03f630ce48ba446752e5e 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