diff --git a/cloudcontrol/node/hypervisor/domains/__init__.py b/cloudcontrol/node/hypervisor/domains/__init__.py index 8773b2bed89cb181607f86c06ef359bbb6b8e820..38033fe4fd7ca6724f7015ec0b1a55b2acd72689 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