storage: fix VM rename
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
This commit is contained in:
parent
26f25aeecd
commit
fd3f19d4a6
@ -329,20 +329,26 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
raise qubes.storage.StoragePoolException(msg)
|
raise qubes.storage.StoragePoolException(msg)
|
||||||
|
|
||||||
if self._is_snapshot:
|
if self._is_snapshot:
|
||||||
self.path = os.path.join(self.dir_path, self.source + '.img')
|
|
||||||
img_name = self.source + '-cow.img'
|
img_name = self.source + '-cow.img'
|
||||||
self.path_source_cow = os.path.join(self.dir_path, img_name)
|
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:
|
elif self._is_volume or self._is_volatile:
|
||||||
self.path = os.path.join(self.dir_path, self.vid + '.img')
|
pass
|
||||||
elif self._is_origin:
|
elif self._is_origin:
|
||||||
self.path = os.path.join(self.dir_path, self.vid + '.img')
|
pass
|
||||||
img_name = self.vid + '-cow.img'
|
|
||||||
self.path_cow = os.path.join(self.dir_path, img_name)
|
|
||||||
else:
|
else:
|
||||||
assert False, 'This should not happen'
|
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):
|
def verify(self):
|
||||||
''' Verifies the volume. '''
|
''' Verifies the volume. '''
|
||||||
if not os.path.exists(self.path) and not self._is_volatile:
|
if not os.path.exists(self.path) and not self._is_volatile:
|
||||||
|
@ -362,12 +362,15 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
msg = msg.format(self.name)
|
msg = msg.format(self.name)
|
||||||
raise qubes.storage.StoragePoolException(msg)
|
raise qubes.storage.StoragePoolException(msg)
|
||||||
|
|
||||||
self.path = '/dev/' + self.vid
|
|
||||||
if self.snap_on_start:
|
if self.snap_on_start:
|
||||||
self._vid_snap = self.vid + '-snap'
|
self._vid_snap = self.vid + '-snap'
|
||||||
|
|
||||||
self._size = size
|
self._size = size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self):
|
||||||
|
return '/dev/' + self.vid
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def revisions(self):
|
def revisions(self):
|
||||||
path = self.path + '-back'
|
path = self.path + '-back'
|
||||||
|
Loading…
Reference in New Issue
Block a user