core: preserve 'autostart' setting during VM rename

Systemd unit name needs to be renamed.

Fixes QubesOS/qubes-issues#1256
This commit is contained in:
Marek Marczykowski-Górecki 2015-10-02 01:57:00 +02:00
parent d900b21dd8
commit 3cdae85254
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -558,6 +558,9 @@ class QubesVm(object):
return re.match(r"^[a-zA-Z][a-zA-Z0-9_.-]*$", name) is not None
def pre_rename(self, new_name):
if self.autostart:
subprocess.check_call(['sudo', 'systemctl', '-q', 'disable',
'qubes-vm@{}.service'.format(self.name)])
# fire hooks
for hook in self.hooks_pre_rename:
hook(self, new_name)
@ -603,6 +606,9 @@ class QubesVm(object):
self.post_rename(old_name)
def post_rename(self, old_name):
if self.autostart:
# force setter to be called again
self.autostart = self.autostart
# fire hooks
for hook in self.hooks_post_rename:
hook(self, old_name)