Omer Frenkel has uploaded a new change for review.

Change subject: core: Block changing sound device configuration for running vm
......................................................................

core: Block changing sound device configuration for running vm

This check is missing, users should not change properties of a running
vm, as this is not reflected in the vm and may cause confusion.

Change-Id: I923299830e1497306b7c5a2b25e9c3e523f20d29
Signed-off-by: Omer Frenkel <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
1 file changed, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/17011/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 3d244a9..43862ea 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
@@ -323,18 +323,24 @@
             return 
failCanDoAction(VdcBllMessages.VM_HOSTCPU_MUST_BE_PINNED_TO_HOST);
         }
 
-        if (getParameters().isConsoleEnabled() != null && !getVm().isDown() && 
consoleDeviceChanged()) {
+        if (getParameters().isConsoleEnabled() != null && !getVm().isDown()
+                && vmDeviceChanged(VmDeviceGeneralType.CONSOLE, 
getParameters().isConsoleEnabled())) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING);
+        }
+
+        if (getParameters().isSoundDeviceEnabled() != null && !getVm().isDown()
+                && vmDeviceChanged(VmDeviceGeneralType.SOUND, 
getParameters().isSoundDeviceEnabled())) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING);
         }
 
         return true;
     }
 
-    private boolean consoleDeviceChanged() {
-        List<VmDevice> consoleDevices = 
getVmDeviceDao().getVmDeviceByVmIdAndType(getParameters().getVmId(),
-                VmDeviceGeneralType.CONSOLE);
+    private boolean vmDeviceChanged(VmDeviceGeneralType deviceType, boolean 
deviceEnabled) {
+        List<VmDevice> vmDevices = 
getVmDeviceDao().getVmDeviceByVmIdAndType(getParameters().getVmId(),
+                deviceType);
 
-        return getParameters().isConsoleEnabled() == consoleDevices.isEmpty();
+        return deviceEnabled == vmDevices.isEmpty();
     }
 
     private boolean isVmExist() {


-- 
To view, visit http://gerrit.ovirt.org/17011
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I923299830e1497306b7c5a2b25e9c3e523f20d29
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Omer Frenkel <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to