From 74b5913febef175012e3d799b8839930b2c490e4 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 30 Jul 2008 11:29:31 +0000
Subject: [PATCH] LURenameInstance, add/remove relevant locks

LURenameInstance forgot to remove the old lock name and add the new one,
making it impossible for parallel LUs to act on the instance (without a
master daemon restart). This also fixes burning+rename with the
parallelization of {Start,Stop}Instance.

Reviewed-by: iustinp
---
 lib/cmdlib.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 6116c524d..243a4c906 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2268,6 +2268,9 @@ class LURenameInstance(LogicalUnit):
       old_file_storage_dir = os.path.dirname(inst.disks[0].logical_id[1])
 
     self.cfg.RenameInstance(inst.name, self.op.new_name)
+    # Change the instance lock. This is definitely safe while we hold the BGL
+    self.context.glm.remove(locking.LEVEL_INSTANCE, inst.name)
+    self.context.glm.add(locking.LEVEL_INSTANCE, self.op.new_name)
 
     # re-read the instance from the configuration after rename
     inst = self.cfg.GetInstanceInfo(self.op.new_name)
-- 
GitLab