From fb1027896a263cd91e2378a4e97dbdf0807b306b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sun, 11 Jul 2021 09:24:44 +0100 Subject: 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. Signed-off-by: Richard Purdie --- meta/lib/oeqa/utils/qemurunner.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'meta/lib') diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 10c54d6afa..5c9d2b24a3 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py @@ -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 -- cgit 1.2.3-korg