From: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Date: Mon, 26 Mar 2018 17:10:12 +0100
CA-283724: Don't attach CBT log when VDI attached in RO mode

Attaching a VDI with its CBT log marks the latter dirty. When this happens
simultaneously on two different hosts, the second hosts marks the CBT 
content incosistent and disables CBT on the disk. This can be avoided if 
the disks are only being attached in RO mode. 

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
---
 drivers/VDI.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/VDI.py b/drivers/VDI.py
index a4b4e00..c73cc92 100755
--- a/drivers/VDI.py
+++ b/drivers/VDI.py
@@ -427,6 +427,13 @@ class VDI(object):
     def activate(self, sr_uuid, vdi_uuid):
         """Activate VDI - called pre tapdisk open"""
         if self._get_blocktracking_status():
+            if self.sr.srcmd.params.has_key('args'):
+                read_write = self.sr.srcmd.params['args'][0]
+                if read_write == "false":
+                    # Disk is being attached in RO mode, 
+                    # don't attach metadata log file
+                    return None
+ 
             from lock import Lock
             lock = Lock("cbtlog", str(vdi_uuid))
             lock.acquire()
-- 
1.8.3.1

