storage: actually use storage.root_img and such properties

Actual VM root disk used hardcoded image names, instead of properties
set for that purpose...
This commit is contained in:
Marek Marczykowski-Górecki 2016-01-06 03:27:50 +01:00
parent b26f2a73b4
commit fa196f1350
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -65,31 +65,31 @@ class XenStorage(QubesVmStorage):
self.volatile_img = os.path.join(vmdir, 'volatile.img')
def root_dev_config(self):
if self.vm.is_template() and \
os.path.exists(os.path.join(self.vmdir, "root-cow.img")):
if self.vm.is_template() and self.rootcow_img:
return self.format_disk_dev(
"{dir}/root.img:{dir}/root-cow.img".format(
dir=self.vmdir),
"{root}:{rootcow}".format(
root=self.root_img, rootcow=self.rootcow_img),
"block-origin", self.root_dev, True)
elif self.vm.template and not self.vm.template.storage.rootcow_img:
# HVM template-based VM - template doesn't have own
# root-cow.img, only one device-mapper layer
return self.format_disk_dev(
"{tpldir}/root.img:{vmdir}/volatile.img".format(
tpldir=self.vm.template.dir_path,
vmdir=self.vmdir),
"{root}:{volatile}".format(
root=self.vm.template.storage.root_img,
volatile=self.volatile_img),
"block-snapshot", self.root_dev, True)
elif self.vm.template:
# any other template-based VM - two device-mapper layers: one
# in dom0 (here) from root+root-cow, and another one from
# this+volatile.img
return self.format_disk_dev(
"{dir}/root.img:{dir}/root-cow.img".format(
dir=self.vm.template.dir_path),
"{root}:{rootcow}".format(
root=self.root_img,
rootcow=self.vm.template.storage.rootcow_img),
"block-snapshot", self.root_dev, False)
else:
return self.format_disk_dev(
"{dir}/root.img".format(dir=self.vmdir),
"{root}".format(root=self.root_img),
None, self.root_dev, True)
def private_dev_config(self):