diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 8ad21222..5f4e7292 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -564,8 +564,8 @@ class QubesVm(object): if os.path.exists(self.conf_file): os.rename(self.conf_file, new_conf) old_dirpath = self.dir_path - new_dirpath = os.path.join(os.path.dirname(self.dir_path), name) - os.rename(old_dirpath, new_dirpath) + self.storage.rename(self.name, name) + new_dirpath = self.storage.vmdir self.dir_path = new_dirpath old_name = self.name self.name = name diff --git a/core/storage/__init__.py b/core/storage/__init__.py index 52434f3e..33f3b5fe 100644 --- a/core/storage/__init__.py +++ b/core/storage/__init__.py @@ -139,6 +139,18 @@ class QubesVmStorage(object): # TODO: modules? + def rename(self, old_name, new_name): + old_vmdir = self.vmdir + new_vmdir = os.path.join(os.path.dirname(self.vmdir), new_name) + os.rename(self.vmdir, new_dirpath) + self.vmdir = new_dirpath + if self.private_img: + self.private_img = self.private_img.replace(old_vmdir, new_vmdir) + if self.root_img: + self.root_img = self.root_img.replace(old_vmdir, new_vmdir) + if self.volatile_img: + self.volatile_img = self.volatile_img.replace(old_vmdir, new_vmdir) + def verify_files(self): if not os.path.exists (self.vmdir): raise QubesException ( diff --git a/core/storage/wni.py b/core/storage/wni.py index 6331b146..52f80e35 100644 --- a/core/storage/wni.py +++ b/core/storage/wni.py @@ -59,6 +59,14 @@ class QubesWniVmStorage(QubesVmStorage): None, 0) super(QubesWniVmStorage, self).remove_from_disk() + def rename(self, old_name, new_name): + super(QubesWniVmStorage, self).rename(old_name, new_name) + win32api.ShellExecute(None, "runas", + "wmic", "useraccount where name='%s' rename '%s'" + % (self._get_username(old_name), self._get_username(new_name)), + None, 0) + + def verify_files(self): if not os.path.exists (self.vmdir): raise QubesException (