Skip to content

Commit

Permalink
storage: fix VM rename
Browse files Browse the repository at this point in the history
When VM is renamed only volume.vid get updated, but not other attributes
calculated from it. Convert them to dynamic properties to not worry
about it.

QubesOS/qubes-issues#2256
  • Loading branch information
marmarek committed Jun 9, 2017
1 parent 26f25ae commit fd3f19d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
20 changes: 13 additions & 7 deletions qubes/storage/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,26 @@ def __init__(self, dir_path, backward_comp=False, **kwargs):
raise qubes.storage.StoragePoolException(msg)

if self._is_snapshot:
self.path = os.path.join(self.dir_path, self.source + '.img')
img_name = self.source + '-cow.img'
self.path_source_cow = os.path.join(self.dir_path, img_name)
img_name = self.vid + '-cow.img'
self.path_cow = os.path.join(self.dir_path, img_name)
elif self._is_volume or self._is_volatile:
self.path = os.path.join(self.dir_path, self.vid + '.img')
pass
elif self._is_origin:
self.path = os.path.join(self.dir_path, self.vid + '.img')
img_name = self.vid + '-cow.img'
self.path_cow = os.path.join(self.dir_path, img_name)
pass
else:
assert False, 'This should not happen'

@property
def path(self):
if self._is_snapshot:
return os.path.join(self.dir_path, self.source + '.img')
return os.path.join(self.dir_path, self.vid + '.img')

@property
def path_cow(self):
img_name = self.vid + '-cow.img'
return os.path.join(self.dir_path, img_name)

def verify(self):
''' Verifies the volume. '''
if not os.path.exists(self.path) and not self._is_volatile:
Expand Down
5 changes: 4 additions & 1 deletion qubes/storage/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,15 @@ def __init__(self, volume_group, size=0, **kwargs):
msg = msg.format(self.name)
raise qubes.storage.StoragePoolException(msg)

self.path = '/dev/' + self.vid
if self.snap_on_start:
self._vid_snap = self.vid + '-snap'

self._size = size

@property
def path(self):
return '/dev/' + self.vid

@property
def revisions(self):
path = self.path + '-back'
Expand Down

0 comments on commit fd3f19d

Please sign in to comment.