From 4d4eae2acfa0a83056296426698a64967da39652 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Tue, 15 Nov 2011 07:21:34 +0100
Subject: [PATCH] Use resource lock when setting node parameters

Also acquire instance and resource locks in shared mode (see comment).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cmdlib.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index af131ee0d..c61bc4d55 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -5309,6 +5309,16 @@ class LUNodeSetParams(LogicalUnit):
     else:
       self.needed_locks = {locking.LEVEL_NODE: self.op.node_name}
 
+    # Since modifying a node can have severe effects on currently running
+    # operations the resource lock is at least acquired in shared mode
+    self.needed_locks[locking.LEVEL_NODE_RES] = \
+      self.needed_locks[locking.LEVEL_NODE]
+
+    # Get node resource and instance locks in shared mode; they are not used
+    # for anything but read-only access
+    self.share_locks[locking.LEVEL_NODE_RES] = 1
+    self.share_locks[locking.LEVEL_INSTANCE] = 1
+
     if self.lock_instances:
       self.needed_locks[locking.LEVEL_INSTANCE] = \
         frozenset(self.cfg.GetInstancesInfoByFilter(self._InstanceFilter))
-- 
GitLab