Fix type passed to write function during backup restoration

Cinder backup throws a TypeError when trying to restore to a new volume,
because slicing a memoryview object does not return a byte string.

Closes-Bug: #2082587
Change-Id: Ibaf87af25dc33c59660be6e112ca78b993592385
(cherry picked from commit b5ac261e6a8f19b0bfbf93de0522f15b2cb79baf)
This commit is contained in:
Bertrand Lanson 2024-09-27 09:51:16 +02:00 committed by Cyprian Kleist
parent 3f15cd80c9
commit 1f9d111f84
2 changed files with 6 additions and 1 deletions

View File

@ -78,7 +78,7 @@ def _write_nonzero(volume_file, volume_offset, content):
# The len(chunk) may be smaller than chunk_length. It's okay.
if not volume_utils.is_all_zero(chunk):
volume_file.seek(volume_offset + chunk_offset)
volume_file.write(chunk)
volume_file.write(chunk.tobytes())
def _write_volume(volume_is_new, volume_file, volume_offset, content):

View File

@ -0,0 +1,5 @@
---
fixes:
- |
`Bug #2082587 <https://bugs.launchpad.net/cinder/+bug/2082587>` _: Fixed
backup restoration throwing TypeError on new volume.