Roy Golan has uploaded a new change for review.

Change subject: core: Prevent StopVm to interleave with other VM locked actions
......................................................................

core: Prevent StopVm to interleave with other VM locked actions

StopVm command is calling the DestoryVds command which is contending on
the VdsManager lock - this means that other commands, like RunVm can
take the lock and result the Vm to stop instead of start

Fix: take an exclusive engine lock on StopVm command

This will also prevent a situation where asyncRunningVms has an entry
although the VM is down.

Change-Id: I6109ef0ea4869b59a93be6fef4b0c3cff50da62e
Signed-off-by: Roy Golan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommand.java
1 file changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/24239/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommand.java
index 821b787..70306a3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommand.java
@@ -3,7 +3,12 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.StopVmParameters;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.common.locks.LockingGroup;
+import org.ovirt.engine.core.common.utils.Pair;
 import org.ovirt.engine.core.compat.Guid;
+
+import java.util.Collections;
+import java.util.Map;
 
 @NonTransactiveCommandAttribute(forceCompensation=true)
 public class StopVmCommand<T extends StopVmParameters> extends 
StopVmCommandBase<T> {
@@ -45,4 +50,13 @@
         addCanDoActionMessage(VdcBllMessages.VAR__ACTION__STOP);
         addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM);
     }
+
+    @Override
+    protected Map<String, Pair<String, String>> getExclusiveLocks() {
+        return Collections.singletonMap(
+                getVmId().toString(),
+                LockMessagesMatchUtil.makeLockingPair(
+                        LockingGroup.VM,
+                        VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
+    }
 }


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

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

Reply via email to