The way to do that is to use an ordinary file or a named pipe.
Why not do the scp
in the original terminal in the first place (even in the background)?
If the host system uses proc
, in the second terminal do cd -P /proc/PID/cwd
then do your scp
from .
(where PID is that of the shell which is in the cwd/pwd that you are interested in).
In qemu
/kvm
, you only get a GUI if you attach a video card to your VM and if you don't expose it as SPICE/VNC.
For instance, you can do (zsh
syntax, with grub2
):
grub-mkimage -O i386-pc -c =(print -l serial 'terminal_input serial' \
'terminal_output serial'
) -o grub.img configfile biosdisk part_msdos part_gpt ext2 \
linux test serial halt minicmd cat
And start your VM with:
kvm -kernel grub.img -hda yourdisk.img -nographic
From the grub
prompt, load the kernel from the disk passing console=ttyS0
... option or equivalent on the system you're booting to have the console on serial. Remember to add a getty on the serial line as well.
Assuming you're running Linux in the VM, you can then update its grub config to display on serial and boot a kernel with serial console, and then you can boot your image disk directly without that grub.img.
To access the qemu "monitor", type Ctrl-Ac (where you can add/remove devices...).
You can have the serial
port as a unix domain or TCP socket, instead of stdio
if you like as well. Same for the qemu "monitor" interface.
Now, provided you have the sgabios.bin
firmware, and that your VM doesn't use graphics (just VGA BIOS text output), you can also just use the -curses
option:
kvm -hda yourdisk -curses
The VGA console is then shown in your terminal. If you need to access the qemu monitor, press Alt-2.
Best Answer
The TIOCSTI ioctl can inject characters into a terminal, or see instead uinput on Linux to generate keyboard (or mouse!) input.
ttywrite.c
- sample C implementationTerm::TtyWrite
- Perl implementation