vm: disable/enable qubes-vm@ service when domain is removed/created
If domain is set to autostart, qubes-vm@ systemd service is used to start it at boot. Cleanup the service when domain is removed, and similarly enable the service when domain is created and already have autostart=True. Fixes QubesOS/qubes-issues#4014
This commit is contained in:
parent
0b7aa546c6
commit
f13029219b
@ -874,6 +874,22 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
raise qubes.exc.QubesException(
|
||||
'Failed to reset autostart for VM in systemd')
|
||||
|
||||
@qubes.events.handler('domain-remove-from-disk')
|
||||
def on_remove_from_disk(self, event, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
if self.autostart:
|
||||
subprocess.call(
|
||||
['sudo', 'systemctl', 'disable',
|
||||
'qubes-vm@{}.service'.format(self.name)])
|
||||
|
||||
@qubes.events.handler('domain-create-on-disk')
|
||||
def on_create_on_disk(self, event, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
if self.autostart:
|
||||
subprocess.call(
|
||||
['sudo', 'systemctl', 'enable',
|
||||
'qubes-vm@{}.service'.format(self.name)])
|
||||
|
||||
#
|
||||
# methods for changing domain state
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user