Skip to content

Commit e954a56

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "guestfs: With libguestfs >= v1.41.1 decode returned bytes to string" into stable/victoria
2 parents 4c1f43b + 210abc0 commit e954a56

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

nova/tests/unit/virt/disk/vfs/fakeguestfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def read_file(self, path):
109109
"mode": 0o700
110110
}
111111

112-
return self.files[path]["content"]
112+
return bytes(self.files[path]["content"].encode())
113113

114114
def write(self, path, content):
115115
if path not in self.files:

nova/virt/disk/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,8 @@ def _set_passwd(username, admin_passwd, passwd_data, shadow_data):
615615
616616
:param username: the username
617617
:param admin_passwd: the admin password
618-
:param passwd_data: path to the passwd file
619-
:param shadow_data: path to the shadow password file
618+
:param passwd_data: Data from the passwd file decoded as a string
619+
:param shadow_data: Data from the shadow file decoded as a string
620620
:returns: nothing
621621
:raises: exception.NovaException(), IOError()
622622

nova/virt/disk/vfs/guestfs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,14 @@ def replace_file(self, path, content):
308308
def read_file(self, path):
309309
LOG.debug("Read file path=%s", path)
310310
path = self._canonicalize_path(path)
311-
return self.handle.read_file(path)
311+
data = self.handle.read_file(path)
312+
# NOTE(lyarwood): libguestfs v1.41.1 (0ee02e0117527) switched the
313+
# return type of read_file from string to bytes and as such we need to
314+
# handle both here, decoding and returning a string if bytes is
315+
# provided. https://bugzilla.redhat.com/show_bug.cgi?id=1661871
316+
if isinstance(data, bytes):
317+
return data.decode()
318+
return data
312319

313320
def has_file(self, path):
314321
LOG.debug("Has file path=%s", path)

0 commit comments

Comments
 (0)