core: use vm.absolute_path to parse paths in qubes.xml
This makes easier to handle some corner cases. One of them is having entry without `dir_path` defined. This may happen when migrating from R2 (using backup+restore or in-place) while some DisposableVM was running (even if not included in the backup itself). Fixes qubesos/qubes-issues#1124 Reported by @doncohen, thanks @wyory for providing more details.
This commit is contained in:
parent
226a144285
commit
76bddaa280
@ -376,8 +376,13 @@ class QubesVm(object):
|
||||
def absolute_path(self, arg, default):
|
||||
if arg is not None and os.path.isabs(arg):
|
||||
return arg
|
||||
else:
|
||||
elif self.dir_path is not None:
|
||||
return os.path.join(self.dir_path, (arg if arg is not None else default))
|
||||
else:
|
||||
# cannot provide any meaningful value without dir_path; this is
|
||||
# only to import some older format of `qubes.xml` (for example
|
||||
# during migration from older release)
|
||||
return None
|
||||
|
||||
def _absolute_path_gen(self, default):
|
||||
return lambda value: self.absolute_path(value, default)
|
||||
|
@ -55,12 +55,12 @@ class QubesVmStorage(object):
|
||||
else:
|
||||
self.root_img_size = defaults['root_img_size']
|
||||
|
||||
self.private_img = os.path.join(self.vmdir, vm_files["private_img"])
|
||||
self.private_img = vm.absolute_path(vm_files["private_img"], None)
|
||||
if self.vm.template:
|
||||
self.root_img = self.vm.template.root_img
|
||||
else:
|
||||
self.root_img = os.path.join(self.vmdir, vm_files["root_img"])
|
||||
self.volatile_img = os.path.join(self.vmdir, vm_files["volatile_img"])
|
||||
self.root_img = vm.absolute_path(vm_files["root_img"], None)
|
||||
self.volatile_img = vm.absolute_path(vm_files["volatile_img"], None)
|
||||
|
||||
# For now compute this path still in QubesVm
|
||||
self.modules_img = modules_img
|
||||
|
Loading…
Reference in New Issue
Block a user