Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/633'
Browse files Browse the repository at this point in the history
* origin/pr/633:
  Improve `qvm-prefs -D SOMEVM template` error message
  • Loading branch information
marmarek committed Nov 14, 2024
2 parents 7fea92f + 611b343 commit 7e57a47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qubes/tests/vm/appvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def test_004_template_reset(self):
vm = self.get_vm()
with self.assertRaises(qubes.exc.QubesValueError):
vm.template = qubes.property.DEFAULT
self.app.default_template = self.template
with self.assertRaises(qubes.exc.QubesValueError):
vm.template = qubes.property.DEFAULT
del self.app.default_template

def test_500_property_migrate_template_for_dispvms(self):
xml_template = '''
Expand Down
5 changes: 5 additions & 0 deletions qubes/vm/appvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def on_domain_loaded(self, event):
def on_property_pre_reset_template(self, event, name, oldvalue=None):
'''Forbid deleting template of running VM
''' # pylint: disable=unused-argument
default_template = getattr(self.app, 'default_template', None)
if default_template is not None:
raise qubes.exc.QubesValueError('Cannot unset template. ' \
'You can set it to the current default ' \
f'({default_template.name}) instead')
raise qubes.exc.QubesValueError('Cannot unset template')

@qubes.events.handler('property-pre-set:template')
Expand Down

0 comments on commit 7e57a47

Please sign in to comment.