core: preserve 'autostart' setting during VM rename
Systemd unit name needs to be renamed. Fixes QubesOS/qubes-issues#1256
This commit is contained in:
parent
d900b21dd8
commit
3cdae85254
@ -558,6 +558,9 @@ class QubesVm(object):
|
|||||||
return re.match(r"^[a-zA-Z][a-zA-Z0-9_.-]*$", name) is not None
|
return re.match(r"^[a-zA-Z][a-zA-Z0-9_.-]*$", name) is not None
|
||||||
|
|
||||||
def pre_rename(self, new_name):
|
def pre_rename(self, new_name):
|
||||||
|
if self.autostart:
|
||||||
|
subprocess.check_call(['sudo', 'systemctl', '-q', 'disable',
|
||||||
|
'qubes-vm@{}.service'.format(self.name)])
|
||||||
# fire hooks
|
# fire hooks
|
||||||
for hook in self.hooks_pre_rename:
|
for hook in self.hooks_pre_rename:
|
||||||
hook(self, new_name)
|
hook(self, new_name)
|
||||||
@ -603,6 +606,9 @@ class QubesVm(object):
|
|||||||
self.post_rename(old_name)
|
self.post_rename(old_name)
|
||||||
|
|
||||||
def post_rename(self, old_name):
|
def post_rename(self, old_name):
|
||||||
|
if self.autostart:
|
||||||
|
# force setter to be called again
|
||||||
|
self.autostart = self.autostart
|
||||||
# fire hooks
|
# fire hooks
|
||||||
for hook in self.hooks_post_rename:
|
for hook in self.hooks_post_rename:
|
||||||
hook(self, old_name)
|
hook(self, old_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user