From 2656d043af2ac3180056b839b5b1cbf1bdfda0bb Mon Sep 17 00:00:00 2001 From: Anael Beutot <anael.beutot@smartjog.com> Date: Thu, 28 Jun 2012 15:47:13 +0200 Subject: [PATCH] Add tag cache for VMs. Indicates if driver used for disk backing is using some sort of caching which may lead to data corruption for a live migration. --- cloudcontrol/node/hypervisor/domains/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cloudcontrol/node/hypervisor/domains/__init__.py b/cloudcontrol/node/hypervisor/domains/__init__.py index 8773b2b..38033fe 100644 --- a/cloudcontrol/node/hypervisor/domains/__init__.py +++ b/cloudcontrol/node/hypervisor/domains/__init__.py @@ -44,6 +44,9 @@ class VirtualMachine(object): #: tags for this VM # FIXME use a tag db instance self.tags = dict((t.name, t) for t in tag_inspector(vm_tags, self)) + #: Driver cache behavior for each VM storage, see + #: http://libvirt.org/formatdomain.html#elementsDisks + self.cache_behaviour = dict() # define dynamic tags i = 0 for v in self.iter_disks(): @@ -52,6 +55,8 @@ class VirtualMachine(object): Tag('disk%s_path' % i, v.path, 10), Tag('disk%s_pool' % i, v.storage, 10), # FIXME: change Tag('disk%s_vol' % i, v.name, 10), + Tag('disk%s_cache' %i, + lambda: self.cache_behaviour.get(v.path), 10) ): self.tags[t.name] = t @@ -129,6 +134,13 @@ class VirtualMachine(object): continue path = d.find('source').get(dict(file='file', block='dev')[type_]) + + # update cache behaviour + driver = d.find('driver') + if driver is None: + driver = {} + self.cache_behaviour[path] = driver.get('cache', 'default') + volume = self.hypervisor.storage.get_volume(path) if volume is None: continue -- GitLab