From f3d3b3d6c76d81d0621ff55f918450c453b683a3 Mon Sep 17 00:00:00 2001 From: sebastian Date: Tue, 29 Sep 2020 10:20:37 +0800 Subject: [PATCH] Fix event listener no attr _buffers error input_event_proxy: while base class _EventListener init, it will using axpect to start a subprocess to handle shell session.This will cause error because of subclass EventListenerLinux has not finished initialization.This change will do event listen after object has been initialized. Signed-off-by: zhanghao1 --- provider/input_event_proxy.py | 3 ++- qemu/tests/vioinput_keyboard.py | 1 + qemu/tests/vioinput_mice.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/provider/input_event_proxy.py b/provider/input_event_proxy.py index 74958a58..21e1e841 100644 --- a/provider/input_event_proxy.py +++ b/provider/input_event_proxy.py @@ -95,7 +95,6 @@ class _EventListener(object): self._agent_sh = None self._agent_state = AgentState.STOPPED self._install() - self._listen() def _install(self): '''Install (copy) the agent into VM.''' @@ -286,6 +285,8 @@ class EventListenerLinux(_EventListener): ebuf[EventTypeKey] = EventType.UNKNOWN self._buffers[dev] = ebuf + def listen(self): + self._listen() # XXX: we may need different map tables for different keyboard layouts, # or even the best solution is not using any mapping, but let us pick diff --git a/qemu/tests/vioinput_keyboard.py b/qemu/tests/vioinput_keyboard.py index 0ec1100f..0f8efb9f 100644 --- a/qemu/tests/vioinput_keyboard.py +++ b/qemu/tests/vioinput_keyboard.py @@ -78,6 +78,7 @@ def key_tap_test(test, params, vm): error_context.context("Start event listener in guest", logging.info) listener = input_event_proxy.EventListener(vm) + listener.listen() console = graphical_console.GraphicalConsole(vm) for key in key_check_cfg.keys(): diff --git a/qemu/tests/vioinput_mice.py b/qemu/tests/vioinput_mice.py index eba800c0..a9ad669f 100644 --- a/qemu/tests/vioinput_mice.py +++ b/qemu/tests/vioinput_mice.py @@ -233,6 +233,7 @@ def run(test, params, env): test.fail("%s does not worked currently" % mice_name) listener = input_event_proxy.EventListener(vm) + listener.listen() console = graphical_console.GraphicalConsole(vm) wait_time = float(params.get("wait_time", 0.2)) absolute = True if mice_info["absolute"] else False -- Gitee