storage/file: simplify search for origin volume of snapshot/read-only

Check directly vm.template, throwing AttributeError when not found.
There may be some value in converting it to more descriptive error, but
since that's mostly for internal users (not user facing actions) don't
bother for now.

QubesOS/qubes-issues#1842
This commit is contained in:
Marek Marczykowski-Górecki 2016-05-20 23:56:02 +02:00 committed by Wojtek Porczyk
parent 07b72ef3fd
commit b119b2c36b

View File

@ -239,10 +239,8 @@ class FilePool(Pool):
if volume_type in ['snapshot', 'read-only']:
name = volume_config['name']
origin_vm = vm
while hasattr(origin_vm, 'template') and \
origin_vm.volume_config[name]['volume_type'] == \
volume_type:
origin_vm = vm.template
while origin_vm.volume_config[name]['volume_type'] == volume_type:
origin_vm = origin_vm.template
expected_origin_type = {