Skip to content

mouse support for QEMU - #603

Open
chombourger wants to merge 3 commits into
siemens:nextfrom
chombourger:ch/feat/qemu-mouse
Open

mouse support for QEMU#603
chombourger wants to merge 3 commits into
siemens:nextfrom
chombourger:ch/feat/qemu-mouse

Conversation

@chombourger

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread mtda/power/qemu.py Outdated
from mtda.power.controller import PowerController
from mtda.utils import Size, System

QMP_SOCKET = "/tmp/qemu-mtda.qmp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sockets should not be created under /tmp, but run or XDG_RUNTIME_DIR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this was a pre-existing issue with this PR adding one more /tmp artefact. commit 1 is now removing all uses of /tmp from power/qemu and console/qemu.

@fmoessbauer

Copy link
Copy Markdown
Member

Just out of curiosity: How is the performance of this implementation? Is this "good enough" to be exposed via the Web UI for interactive use (similar to PiKVM)?

@chombourger

Copy link
Copy Markdown
Collaborator Author

Just out of curiosity: How is the performance of this implementation? Is this "good enough" to be exposed via the Web UI for interactive use (similar to PiKVM)?

our web UI only sends events on a click - would otherwise be too slow but that would be worth looking into (as a separate task)

Runtime artifacts (monitor and serial fifos, swtpm state dir
and socket) were hard-coded under /tmp, colliding across users
and sessions and ignoring the system's runtime-file convention.

Derive their base directory from XDG_RUNTIME_DIR, falling back
to tempfile.gettempdir() when unset. Expose serial_in/serial_out
as public attributes so console.qemu, which opens the same
fifos, can read them from the power controller instead of
duplicating the hard-coded paths.

Signed-off-by: Cedric Hombourger <cedric.hombourger@siemens.com>
HMP over the hand-rolled named-pipe transport had no framing or error
reporting: commands and responses were matched by scanning output for
the "(qemu) " prompt, so a partial write or an unexpected line desyncs
the whole channel with no way to detect it.

Connect over QEMU's QMP unix socket instead and speak the native
JSON protocol: on()/off()/status() use system_reset/cont/stop/
query-status, and usb_add()/usb_rm() use blockdev-add/device_add/
device_del/blockdev-del, tracking attached ids locally instead of
scraping "info usb" text.

keyboard.qemu and video.qemu move to the native send-key and
screendump QMP commands for the same reason.

The free-form command() CLI passthrough (mtda-cli command ...) still
needs to accept arbitrary HMP strings (e.g. hostfwd_add), so it now
bridges through QMP's human-monitor-command instead of the raw pipe.

self.lock becomes an RLock: usb_add()/usb_rm() hold it across several
qmp() calls, and qmp() itself locks.

Signed-off-by: Cedric Hombourger <cedric.hombourger@siemens.com>
No mouse variant existed for QEMU (only the physical HID gadget),
so mtda-cli mouse move was a silent no-op against a qemu-backed
device.

Drive the target pointer over QMP's input-send-event, and add
-device usb-tablet so mouse_move's coordinates are read as absolute
positions instead of relative deltas.

input-send-event routes "abs" events to the usb-tablet automatically:
it's the only pointing device that declares absolute-axis support,
so position events reach it unambiguously with no selection step.
Button events are shared between the tablet and the default
machine's relative PS/2 mouse, and QEMU applies them to whichever
pointer it last made active; QMP has no command for that, so fall
fall back to the human-monitor-command bridge to select the tablet,
but only when query-mice (native QMP) reports it isn't already active.

Signed-off-by: Cedric Hombourger <cedric.hombourger@siemens.com>
@chombourger chombourger added check and removed check labels Aug 6, 2026
@chombourger chombourger added check and removed check labels Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants