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:
parent
5b4e30524a
commit
3f6c96ee39
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user