Qemu-kvm programming a few questions

  1. I can send a keyboard press from the host to the guest for example with this command:

virsh send-key GuestVM --codeset linux --holdtime 100 KEY_SPACE
or
virsh send-key GuestVM --codeset usb --holdtime 100 0x2c

How do I send a mouse click and move?

  1. How do I transfer data from the guest to the host via some emulated device? For example, my program in the guest send a few bytes to the device → my program in the host accept these bytes.

Any reason you couldn’t use the network - it’d probably be the easiest.

Perhaps maybe a serial port would work as well,

from qemu-system(1) — qemu-system-common — Debian unstable — Debian Manpages

-chardev stdio,mux=on,id=char0 \
-mon chardev=char0,mode=readline \
-serial chardev:char0 \
-serial chardev:char0

This tells qemu to connect the qemu command line studio to a new ‘char0’ device, and to use it as backing for a pair of virtual serial ports. If you look at the manual, it’ll show you how you can use things other than stdio.

I thought about the network, but in my case, the data will be transmitted over the Internet, and I don’t want that. I don’t want a second network either.

Thank you, I will try, but first I still need to solve question number 1

I don’t understand why it doesn’t work?

virsh send-key GuestVM --codeset win32 --holdtime 100 0x01

<input type="mouse" bus="usb">
  <address type="usb" bus="0" port="4"/>
</input>

or
<input type="mouse" bus="ps2"/>

Is there a way to control this device from a program on the host? Please show an example.