UTM icon indicating copy to clipboard operation
UTM copied to clipboard

Problems about a Specific QMP Scripting Use Case

Open iblowmymind opened this issue 1 year ago • 3 comments

BEFORE SUBMITTING YOUR ISSUE, PLEASE LOOK AT THE PINNED ISSUES AND USE THE SEARCH FUNCTION TO MAKE SURE IT IS NOT ALREADY REPORTED. ALWAYS COMMENT ON AN EXISTING ISSUE INSTEAD OF MAKING A NEW ONE.

Describe the issue
Hello, I'm trying to run a program called GlobalView for X on a Solaris 2.6 Sparcstation-5 virtual machine on UTM. This specific program requires the use of the Sun keyboard's "function cluster" (the set of keys on the very left of a Sun Type 5 keyboard, Props and Copy for example) for some of its functionality. Now, I'm not in the posession of a Sun keyboard myself, bu I can invoke these keys by using the QEMU compat monitor and the "sendkey" command. However, this requires effort every time I want to press one of these keys. So, I thought I would try to make a soft keyboard panel using macOS's Accessibility Keyboard and its Panel Editor functionality, which I then added custom keys to and bound an AppleScript to each one. These keys (using the Help key as an example) invoke this shell command (through AppleScript "do shell script"):

cat <(echo "{ \"execute\": \"qmp_capabilities\" }"; echo ""; echo "{\"execute\": \"send-key\", \"arguments\": { 'keys': [{ \"type\": \"qcode\", \"data\": \"help\" }] }}") | nc localhost 5902

This is what the panel looks like: Screenshot of the key panel

I also added this argument to UTM manually: -qmp tcp::5902,server,nowait (I'm pretty sure UTM already defines its own QMP interface, but I think I can add multiple?) Basically, I'm using QMP scripting to send a send-key command that contains the key I want with netcat through a TCP socket.

Now, I've tested this on the latest stock QEMU (9.x) and it works just fine (I can send QMP commands alright), however on UTM after nc recieves the server handshake messages and sends the first character of the response, the remote side immediately closes the connection. The odd thing is, running nc or telnet interactively works just fine. However, I can't seem to do this headless no matter what! I've tried using ncat and socat, both the regular monitor (defined both from UTM and as a custom QEMU argument) and the QMP, and the outcome is the same: Nc recieves the server handshake stuff, but QEMU immediately close the connection without waiting for nc's full response (my command). There's nothing related to my QMP port being opened in the logs.

Would anyone be able to assist me? I'd prefer to use the UTM interface for managing my VM. Thanks!

Configuration

  • UTM Version: 4.5.3
  • macOS Version: 14.5
  • Mac Chip (Intel, M1, ...): M3

iblowmymind avatar Jul 06 '24 15:07 iblowmymind

Fixed my issue by using the command nc localhost 5902 < <(echo 'sendkey <key>'; sleep 0.01) with the monitor instead of QMP instead, but I think this issue should stay open because it's probably supposed to work the other way as well.

iblowmymind avatar Jul 06 '24 21:07 iblowmymind

We should provide an AppleScript interface to send key directly

osy avatar Aug 21 '24 15:08 osy

Yeah, that would be much more intuitive (and more native) imo.

iblowmymind avatar Aug 21 '24 16:08 iblowmymind

Awesome! Also just saw the custom keyboard shortcut feature here too. Many thanks!

iblowmymind avatar Aug 15 '25 17:08 iblowmymind