diff mbox series

[master,langdale] qemurunner.py: Support fallback to older QEMU qmp library

Message ID 20221121192025.926659-1-mark.hatle@kernel.crashing.org
State New
Headers show
Series [master,langdale] qemurunner.py: Support fallback to older QEMU qmp library | expand

Commit Message

Mark Hatle Nov. 21, 2022, 7:20 p.m. UTC
From: Mark Hatle <mark.hatle@amd.com>

Some vendor versions of QEMU may be on older versions that do not have
qmp.legacy, but instead of qmp.  Default to the integrated library
versions, fall back to the older one and then if neither is available
catch the exception and provide a more human readable error.

Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
 meta/lib/oeqa/utils/qemurunner.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index f175f8a1de..436caef273 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -328,8 +328,14 @@  class QemuRunner:
-               from qmp.legacy import QEMUMonitorProtocol
+               try:
+                   from qmp.legacy import QEMUMonitorProtocol
+               except ModuleNotFoundError:
+                   from qmp import QEMUMonitorProtocol
                self.qmp = QEMUMonitorProtocol(os.path.basename(qmp_port))
+            except ModuleNotFoundError as msg:
+                self.logger.warning("Failed to load QEMUMonitorProtocol from qmp.legacy or qmp: %s" % (msg))
+                return False
             except OSError as msg:
                 self.logger.warning("Failed to initialize qemu monitor socket: %s File: %s" % (msg, msg.filename))
                 return False