Skip to content
Snippets Groups Projects
Commit 2656d043 authored by Anael Beutot's avatar Anael Beutot
Browse files

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.
parent f287d531
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment