qubes/vm: fix handling autostart set/reset

1. Service symlink must have ".service" extension
2. Disable service on property reset to default
This commit is contained in:
Marek Marczykowski-Górecki 2016-08-09 03:02:42 +02:00
parent 5b4e30524a
commit 3f6c96ee39
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -569,7 +569,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
["sudo", "ln", "-sf",
"/usr/lib/systemd/system/qubes-vm@.service",
"/etc/systemd/system/multi-user.target.wants/qubes-vm@{"
"}".format(self.name)])
"}.service".format(self.name)])
else:
retcode = subprocess.call(
['sudo', 'systemctl', 'disable',
@ -578,6 +578,17 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
raise qubes.exc.QubesException(
'Failed to set autostart for VM in systemd')
@qubes.events.handler('property-pre-del:autostart')
def on_property_pre_del_autostart(self, event, prop, oldvalue=None):
# pylint: disable=unused-argument
if oldvalue:
retcode = subprocess.call(
['sudo', 'systemctl', 'disable',
'qubes-vm@{}.service'.format(self.name)])
if retcode:
raise qubes.exc.QubesException(
'Failed to reset autostart for VM in systemd')
@qubes.events.handler('device-pre-attach:pci')
def on_device_pre_attached_pci(self, event, device):
# pylint: disable=unused-argument