Skip to content

Commit

Permalink
storage: drop rename support
Browse files Browse the repository at this point in the history
Since VM name is immutable, rename method can be dropped from storage
API.

QubesOS/qubes-issues#2868
  • Loading branch information
marmarek committed Jul 4, 2017
1 parent dd1e05d commit 697eb05
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 51 deletions.
11 changes: 0 additions & 11 deletions qubes/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,6 @@ def outdated_volumes(self):

return result

def rename(self, old_name, new_name):
''' Notify the pools that the domain was renamed '''
volumes = self.vm.volumes
for name, volume in volumes.items():
pool = volume.pool
volumes[name] = pool.rename(volume, old_name, new_name)

@asyncio.coroutine
def verify(self):
'''Verify that the storage is sane.
Expand Down Expand Up @@ -722,10 +715,6 @@ def init_volume(self, vm, volume_config):
'''
raise self._not_implemented("init_volume")

def rename(self, volume, old_name, new_name):
''' Called when the domain changes its name '''
raise self._not_implemented("rename")

def setup(self):
''' Called when adding a pool to the system. Use this for implementation
specific set up.
Expand Down
20 changes: 0 additions & 20 deletions qubes/storage/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,6 @@ def init_volume(self, vm, volume_config):
self._volumes += [volume]
return volume

def rename(self, volume, old_name, new_name):
assert issubclass(volume.__class__, FileVolume)
subdir, _, volume_path = volume.vid.split('/', 2)

if volume._is_origin:
# TODO: Renaming the old revisions
new_path = os.path.join(self.dir_path, subdir, new_name)
if not os.path.exists(new_path):
os.mkdir(new_path, 0o755)
new_volume_path = os.path.join(new_path, self.name + '.img')
if not volume.backward_comp:
os.rename(volume.path, new_volume_path)
new_volume_path_cow = os.path.join(new_path, self.name + '-cow.img')
if os.path.exists(new_volume_path_cow) and not volume.backward_comp:
os.rename(volume.path_cow, new_volume_path_cow)

volume.vid = os.path.join(subdir, new_name, volume_path)

return volume

def destroy(self):
pass

Expand Down
3 changes: 0 additions & 3 deletions qubes/storage/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ def destroy(self):
def import_volume(self, dst_pool, dst_volume, src_pool, src_volume):
pass

def rename(self, volume, old_name, new_name):
return volume

def setup(self):
pass

Expand Down
17 changes: 0 additions & 17 deletions qubes/storage/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,6 @@ def init_volume(self, vm, volume_config):
volume_config['pool'] = self
return ThinVolume(**volume_config)

def rename(self, volume, old_name, new_name):
''' Called when the domain changes its name '''
new_vid = "{!s}/vm-{!s}-{!s}".format(self.volume_group, new_name,
volume.name)
if volume.save_on_stop:
cmd = ['clone', volume.vid, new_vid]
qubes_lvm(cmd, self.log)
cmd = ['remove', volume.vid]
qubes_lvm(cmd, self.log)

volume.vid = new_vid

if volume.snap_on_start:
volume._vid_snap = volume.vid + '-snap'
reset_cache()
return volume

def setup(self):
pass # TODO Should we create a non existing pool?

Expand Down

0 comments on commit 697eb05

Please sign in to comment.