Omer Frenkel has uploaded a new change for review. Change subject: core: fix edit of sound card for running vm ......................................................................
core: fix edit of sound card for running vm Currently, when updating the sound card setting for running vm, the query that checks if sound card exists is wrong, because sound card can have multiple types of devices (ac97,ich6) Added a code that use the "UNKNOWN" device type, to mark the mechanism to use only the general device type (sound) without the specific type. Change-Id: If2ff54c3d0929ddf04f39bb42e61e185005d9655 Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java 3 files changed, 16 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/31207/1 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 5d0bca5..f722bf6 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 @@ -51,6 +51,7 @@ import org.ovirt.engine.core.common.osinfo.OsRepository; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.utils.SimpleDependecyInjector; +import org.ovirt.engine.core.common.utils.VmDeviceType; import org.ovirt.engine.core.common.vdscommands.SetVmStatusVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.UpdateVmDynamicDataVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; @@ -780,9 +781,16 @@ log.warn("VmHandler:: isUpdateValidForVmDevices: Reflection error"); } + // if device type is set to unknown, search by general type only + // because some devices has more than one type, like sound can be ac97/ich6 + String device = null; + if (annotation.type() != VmDeviceType.UNKNOWN) { + device = annotation.type().getName(); + } + if (isEnabled == null || !VmDeviceUtils.vmDeviceChanged(vmId, annotation.generalType(), - annotation.type().getName(), isEnabled)) { + device, isEnabled)) { continue; } 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 0cb58ab..b766007 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 @@ -1140,16 +1140,19 @@ vmManagedDeviceMap.put(device.getDeviceId(), device); } else { - vmManagedDeviceMap.remove(getVmDeviceIdByName(vmManagedDeviceMap, field.type().getName())); + vmManagedDeviceMap.remove(getVmDeviceIdByName(vmManagedDeviceMap, field.generalType(), field.type().getName())); } } return vmManagedDeviceMap; } - private static Guid getVmDeviceIdByName(Map<Guid, VmDevice> vmManagedDeviceMap, String name) { + private static Guid getVmDeviceIdByName(Map<Guid, VmDevice> vmManagedDeviceMap, VmDeviceGeneralType generalType, String name) { for (Map.Entry<Guid, VmDevice> entry : vmManagedDeviceMap.entrySet()) { - if (entry.getValue().getDevice().equals(name)) { + // first check by specific name + // if no match, and specific name is unknown, look by general type + if (entry.getValue().getDevice().equals(name) + || (VmDeviceType.UNKNOWN.getName().equals(name) && entry.getValue().getType() == generalType)) { return entry.getKey(); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java index f5f14e85..0638339 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java @@ -51,7 +51,7 @@ * for add vm legacy logic will be used: create device for desktop type * for update the current configuration will remain */ - @EditableDeviceOnVmStatusField(generalType = VmDeviceGeneralType.SOUND, type = VmDeviceType.SOUND, isReadOnly = true) + @EditableDeviceOnVmStatusField(generalType = VmDeviceGeneralType.SOUND, type = VmDeviceType.UNKNOWN, isReadOnly = true) private Boolean soundDeviceEnabled; /* * This parameter is used to decide if to create console device or not if it is null then: for add vm don't add -- To view, visit http://gerrit.ovirt.org/31207 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If2ff54c3d0929ddf04f39bb42e61e185005d9655 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches