qubes/vm: fix setting autostart property
This is actually workaround for systemd bug reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=1181922
qubesos/qubes-issues#925
This is migration of 9bfcb72722
commit to
core3.
This commit is contained in:
parent
b37bf55f5e
commit
5b5f290c23
@ -595,11 +595,20 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
def on_property_pre_set_autostart(self, event, prop, value,
|
def on_property_pre_set_autostart(self, event, prop, value,
|
||||||
oldvalue=None):
|
oldvalue=None):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
if subprocess.call(['sudo', 'systemctl',
|
# workaround https://bugzilla.redhat.com/show_bug.cgi?id=1181922
|
||||||
('enable' if value else 'disable'),
|
if value:
|
||||||
'qubes-vm@{}.service'.format(self.name)]):
|
retcode = subprocess.call(
|
||||||
|
["sudo", "ln", "-sf",
|
||||||
|
"/usr/lib/systemd/system/qubes-vm@.service",
|
||||||
|
"/etc/systemd/system/multi-user.target.wants/qubes-vm@{"
|
||||||
|
"}".format(self.name)])
|
||||||
|
else:
|
||||||
|
retcode = subprocess.call(
|
||||||
|
['sudo', 'systemctl', 'disable',
|
||||||
|
'qubes-vm@{}.service'.format(self.name)])
|
||||||
|
if retcode:
|
||||||
raise qubes.exc.QubesException(
|
raise qubes.exc.QubesException(
|
||||||
'Failed to set autostart for VM via systemctl')
|
'Failed to set autostart for VM in systemd')
|
||||||
|
|
||||||
|
|
||||||
@qubes.events.handler('device-pre-attach:pci')
|
@qubes.events.handler('device-pre-attach:pci')
|
||||||
|
Loading…
Reference in New Issue
Block a user