storage: reset_volatile_storage doesn't need source_template parameter
It shouldn't touch anything not already known to the VM object.
This commit is contained in:
parent
5f48b76b27
commit
c1bab3d094
@ -219,7 +219,7 @@ class Storage(object):
|
|||||||
os.mkdir(self.vm.dir_path)
|
os.mkdir(self.vm.dir_path)
|
||||||
self.create_on_disk_private_img(source_template)
|
self.create_on_disk_private_img(source_template)
|
||||||
self.create_on_disk_root_img(source_template)
|
self.create_on_disk_root_img(source_template)
|
||||||
self.reset_volatile_storage(source_template)
|
self.reset_volatile_storage()
|
||||||
|
|
||||||
os.umask(old_umask)
|
os.umask(old_umask)
|
||||||
|
|
||||||
@ -285,14 +285,14 @@ class Storage(object):
|
|||||||
shutil.rmtree(self.vm.dir_path)
|
shutil.rmtree(self.vm.dir_path)
|
||||||
|
|
||||||
|
|
||||||
def reset_volatile_storage(self, source_template=None):
|
def reset_volatile_storage(self):
|
||||||
if source_template is None:
|
|
||||||
source_template = self.vm.template
|
|
||||||
|
|
||||||
# Re-create only for template based VMs
|
# Re-create only for template based VMs
|
||||||
if source_template is not None and self.volatile_img:
|
try:
|
||||||
if os.path.exists(self.volatile_img):
|
if self.vm.template is not None and self.volatile_img:
|
||||||
os.remove(self.volatile_img)
|
if os.path.exists(self.volatile_img):
|
||||||
|
os.remove(self.volatile_img)
|
||||||
|
except AttributeError: # self.vm.template
|
||||||
|
pass
|
||||||
|
|
||||||
# For StandaloneVM create it only if not already exists
|
# For StandaloneVM create it only if not already exists
|
||||||
# (eg after backup-restore)
|
# (eg after backup-restore)
|
||||||
|
@ -226,23 +226,19 @@ class XenStorage(qubes.storage.Storage):
|
|||||||
os.umask(old_umask)
|
os.umask(old_umask)
|
||||||
|
|
||||||
|
|
||||||
def reset_volatile_storage(self, source_template=None):
|
def reset_volatile_storage(self):
|
||||||
if source_template is None:
|
try:
|
||||||
source_template = self.vm.template
|
# no template set, in any way (Standalone VM, Template VM)
|
||||||
|
if self.vm.template is None:
|
||||||
|
raise AttributeError
|
||||||
|
|
||||||
if source_template is not None:
|
# template-based HVM with only one device-mapper layer -
|
||||||
# template-based VM with only one device-mapper layer -
|
|
||||||
# volatile.img used as upper layer on root.img, no root-cow.img
|
# volatile.img used as upper layer on root.img, no root-cow.img
|
||||||
# intermediate layer
|
# intermediate layer
|
||||||
|
if self.vm.hvm:
|
||||||
# XXX marmarek says this is either always true or always false;
|
|
||||||
# rootcow_img got smashed in 35cb82 (#1573)
|
|
||||||
# this may have remain after HVM check
|
|
||||||
# this probably should have happen anyway
|
|
||||||
if not source_template.storage.rootcow_img:
|
|
||||||
if os.path.exists(self.volatile_img):
|
if os.path.exists(self.volatile_img):
|
||||||
if self.vm.debug:
|
if self.vm.debug:
|
||||||
if os.path.getmtime(source_template.storage.root_img) \
|
if os.path.getmtime(self.vm.template.storage.root_img) \
|
||||||
> os.path.getmtime(self.volatile_img):
|
> os.path.getmtime(self.volatile_img):
|
||||||
self.vm.log.warning(
|
self.vm.log.warning(
|
||||||
'Template have changed, resetting root.img')
|
'Template have changed, resetting root.img')
|
||||||
@ -258,16 +254,17 @@ class XenStorage(qubes.storage.Storage):
|
|||||||
|
|
||||||
# FIXME stat on f_root; with open() ...
|
# FIXME stat on f_root; with open() ...
|
||||||
f_volatile = open(self.volatile_img, "w")
|
f_volatile = open(self.volatile_img, "w")
|
||||||
f_root = open(source_template.storage.root_img, "r")
|
f_root = open(self.vm.template.storage.root_img, "r")
|
||||||
# make empty sparse file of the same size as root.img
|
# make empty sparse file of the same size as root.img
|
||||||
f_root.seek(0, os.SEEK_END)
|
f_root.seek(0, os.SEEK_END)
|
||||||
f_volatile.truncate(f_root.tell())
|
f_volatile.truncate(f_root.tell())
|
||||||
f_volatile.close()
|
f_volatile.close()
|
||||||
f_root.close()
|
f_root.close()
|
||||||
return # XXX why is that? super() does not run
|
return # XXX why is that? super() does not run
|
||||||
|
except AttributeError: # self.vm.template
|
||||||
|
pass
|
||||||
|
|
||||||
super(XenStorage, self).reset_volatile_storage(
|
super(XenStorage, self).reset_volatile_storage()
|
||||||
source_template=source_template)
|
|
||||||
|
|
||||||
|
|
||||||
def prepare_for_vm_startup(self):
|
def prepare_for_vm_startup(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user