storage: use root-cow.img for HVM template, to support reverting changes

We still can't support running HVM template and its VMs simultaneously
(easily), but still, have root-cow.img handled for HVM template, to
allow qvm-revert-template-changes.

Fixes QubesOS/qubes-issues#1573
This commit is contained in:
Marek Marczykowski-Górecki 2016-01-06 03:43:32 +01:00
parent fa196f1350
commit 35cb82cd2b
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 17 additions and 8 deletions

View File

@ -100,8 +100,6 @@ class QubesHVm(QubesResizableVm):
(not 'xml_element' in kwargs or kwargs['xml_element'].get('guiagent_installed') is None):
self.services['meminfo-writer'] = False
self.storage.rootcow_img = None
@property
def type(self):
return "HVM"

View File

@ -29,7 +29,7 @@ import stat
import sys
import re
from qubes.qubes import QubesHVm,register_qubes_vm_class,dry_run
from qubes.qubes import QubesHVm,register_qubes_vm_class,dry_run,vmm
from qubes.qubes import QubesException,QubesVmCollection
from qubes.qubes import system_path,defaults
@ -96,7 +96,15 @@ class QubesTemplateHVm(QubesHVm):
def commit_changes (self, verbose = False):
self.log.debug('commit_changes()')
# nothing to do as long as root-cow.img is unused
pass
if not vmm.offline_mode:
assert not self.is_running(), "Attempt to commit changes on running Template VM!"
if verbose:
print >> sys.stderr, "--> Commiting template updates... COW: {0}...".format (self.rootcow_img)
if dry_run:
return
self.storage.commit_template_changes()
register_qubes_vm_class(QubesTemplateHVm)

View File

@ -70,9 +70,12 @@ class XenStorage(QubesVmStorage):
"{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
elif self.vm.template and not hasattr(self.vm, 'kernel'):
# HVM template-based VM - only one device-mapper layer, in dom0 (
# root+volatile)
# HVM detection based on 'kernel' property is massive hack,
# but taken from assumption that VM needs Qubes-specific kernel (
# actually initramfs) to assemble the second layer of device-mapper
return self.format_disk_dev(
"{root}:{volatile}".format(
root=self.vm.template.storage.root_img,