From 5b5f290c23b4cd993066d499de1448e1845ba6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 21 May 2016 03:54:10 +0200 Subject: [PATCH] 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 9bfcb72722170f7410cce1e4a2ab15ee3df11c89 commit to core3. --- qubes/vm/qubesvm.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 5efa730d..d22c2af8 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -595,11 +595,20 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): def on_property_pre_set_autostart(self, event, prop, value, oldvalue=None): # pylint: disable=unused-argument - if subprocess.call(['sudo', 'systemctl', - ('enable' if value else 'disable'), - 'qubes-vm@{}.service'.format(self.name)]): + # workaround https://bugzilla.redhat.com/show_bug.cgi?id=1181922 + if value: + 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( - 'Failed to set autostart for VM via systemctl') + 'Failed to set autostart for VM in systemd') @qubes.events.handler('device-pre-attach:pci')