oeqa/qemurunner: Handle files no longer existing gracefully

Files in /proc/xxx/map_files/ may no longer exist, just ignore this rather than
raising an exception.

(From OE-Core rev: fb1027896a263cd91e2378a4e97dbdf0807b306b)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2021-07-11 09:24:44 +01:00
parent 7f9f9a0c37
commit 9b4c0035d4

View File

@@ -359,13 +359,16 @@ class QemuRunner:
mapdir = "/proc/" + str(self.qemupid) + "/map_files/"
try:
for f in os.listdir(mapdir):
linktarget = os.readlink(os.path.join(mapdir, f))
if not linktarget.startswith("/") or linktarget.startswith("/dev") or "deleted" in linktarget:
try:
linktarget = os.readlink(os.path.join(mapdir, f))
if not linktarget.startswith("/") or linktarget.startswith("/dev") or "deleted" in linktarget:
continue
with open(linktarget, "rb") as readf:
data = True
while data:
data = readf.read(4096)
except FileNotFoundError:
continue
with open(linktarget, "rb") as readf:
data = True
while data:
data = readf.read(4096)
# Centos7 doesn't allow us to read /map_files/
except PermissionError:
pass