Skip to content

Commit 7e57a47

Browse files
committed
Merge remote-tracking branch 'origin/pr/633'
* origin/pr/633: Improve `qvm-prefs -D SOMEVM template` error message
2 parents 7fea92f + 611b343 commit 7e57a47

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

qubes/tests/vm/appvm.py

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ def test_004_template_reset(self):
147147
vm = self.get_vm()
148148
with self.assertRaises(qubes.exc.QubesValueError):
149149
vm.template = qubes.property.DEFAULT
150+
self.app.default_template = self.template
151+
with self.assertRaises(qubes.exc.QubesValueError):
152+
vm.template = qubes.property.DEFAULT
153+
del self.app.default_template
150154

151155
def test_500_property_migrate_template_for_dispvms(self):
152156
xml_template = '''

qubes/vm/appvm.py

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ def on_domain_loaded(self, event):
120120
def on_property_pre_reset_template(self, event, name, oldvalue=None):
121121
'''Forbid deleting template of running VM
122122
''' # pylint: disable=unused-argument
123+
default_template = getattr(self.app, 'default_template', None)
124+
if default_template is not None:
125+
raise qubes.exc.QubesValueError('Cannot unset template. ' \
126+
'You can set it to the current default ' \
127+
f'({default_template.name}) instead')
123128
raise qubes.exc.QubesValueError('Cannot unset template')
124129

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

0 commit comments

Comments
 (0)