There is a solution.
Just after starting the VM, you can do :
Code:
sudo tail /var/log/libvirt/qemu/<vm_name>.log
Here is a sample reply :
Code:
/usr/bin/kvm -M pc -m 2048 -smp 4 -monitor pty -drive file=/var/lib/libvirt/images/<vm_name>.img,if=ide,boot=on -net nic,macaddr=00:16:ff:09:28:1e,vlan=0 -net tap,fd=4,script=,vlan=0 -usb -vnc 127.0.0.1:1
char device redirected to /dev/pts/1
The last line is really important. It tells you that kvm console is accessible to /dev/pts/X tty. Here, X is 1.
Install the socat command (sudo apt-get install socat) and type in :
Code:
sudo socat - /dev/pts/1
You are now connected to kvm console. Type for example :
or any other kvm command.
BE CAREFUL, to exit from that console, just press Ctrl+C (to quit socat actually).
My problem now is when the VM has run for a while, there is no more the
"char device redirected to /dev/pts/X" in the logs ... so I search a
method to retreive the actual pts which the VM points to.
If you look at the file descriptors of the kvm VM (lsof -p <kvm_process_number>, you found :
Code:
...
kvm 6249 root 10u CHR 5,2 1675 /dev/ptmx
...
The process has opened /dev/ptmx. The problem I'm facing is that I
don't know any mean of retreiving the pts part (the slave part) of that
opened master tty. There is just a C function called "ptsname", but I
didn't find a script command to do the same ... Does someone know about
that ?