qvm-template-postprocess: do not remove VM on failed reinstall
If root volume import fails on template reinstall, do not remove it - keep it alone, with old volume content QubesOS/qubes-issues#3169
This commit is contained in:
parent
562137c36d
commit
96a32bd096
@ -195,6 +195,7 @@ def post_install(args):
|
|||||||
'''Handle post-installation tasks'''
|
'''Handle post-installation tasks'''
|
||||||
|
|
||||||
app = args.app
|
app = args.app
|
||||||
|
vm_created = False
|
||||||
try:
|
try:
|
||||||
# reinstall
|
# reinstall
|
||||||
vm = app.domains[args.name]
|
vm = app.domains[args.name]
|
||||||
@ -211,13 +212,15 @@ def post_install(args):
|
|||||||
vm = app.add_new_vm('TemplateVM',
|
vm = app.add_new_vm('TemplateVM',
|
||||||
name=args.name,
|
name=args.name,
|
||||||
label=qubesadmin.config.defaults['template_label'])
|
label=qubesadmin.config.defaults['template_label'])
|
||||||
|
vm_created = True
|
||||||
|
|
||||||
vm.log.info('Importing data')
|
vm.log.info('Importing data')
|
||||||
try:
|
try:
|
||||||
import_root_img(vm, args.dir)
|
import_root_img(vm, args.dir)
|
||||||
except:
|
except:
|
||||||
# if data import fails, remove half-created VM
|
# if data import fails, remove half-created VM
|
||||||
del app.domains[vm.name]
|
if vm_created:
|
||||||
|
del app.domains[vm.name]
|
||||||
raise
|
raise
|
||||||
vm.installed_by_rpm = True
|
vm.installed_by_rpm = True
|
||||||
import_appmenus(vm, args.dir)
|
import_appmenus(vm, args.dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user