[Users] [TRD] Guest tools in QEMU: vm enter/exec with pty/pipe stdio redirection

Yuriy Pudgorodskiy yur at virtuozzo.com
Fri Feb 19 08:00:16 PST 2016


1. Feature.
Guest tools in QEMU: vm_enter - implemented with 'prlctl enter' command.
Required build: psbm-7.0.0-1592

2. Description.

In additional to already used by qemu-ga, a new virtio serial channel is 
created:
with name "org.qemu.guest_agent.1" and port number 2.
This port is added automatically to VM created with latest PCS builds.
For previously created VMs with old PCS, either such channel should be
manually created or guest exec feature will not be available.

Additional channel is used for multiplexed I/O with stdin, stdout, 
stderr pipes
connected to guest process.

EXEC command changes.

Fully realtime in/out/err transfer is now implemented on top of this  
channel
instead of previous string-based redirection  (when stdin data was 
completely
sent from client as byte array before exec and out/err was received also as
byte arrays completely after exec).

Unlimited amount of data may now be transferred over any in/out/err 
redirection.
Client stdio is now reading by guest process in real time and output is 
now sending
back to client as soon as possible.

Test cases like

cat file | prlctl exec VM some-process
prlctl exec VM some-process | grep pattern

should now work in real-time with no delay in sending in or out.
The amount of data transferred is now unlimited, but flow control is not 
implemented
yet, see notice below.

ENTER command is implemented.

prlctl enter on linux guest - bash is connected to pty channels.
Fully  interactive shell should be available, including keyboard 
signals, ^D eof and
job control. For example, running cat within enter and pressing ^D will 
end the
cat, pressing ^Z will suspend cat inside guest (not the host prlctl):

host--prompt$ prlctl enter linux-vm
guest-prompt$ cat
^D
guest-prompt$

prlctl enter on windows guest - cmd is connected with pipes, so only limited
interactive behavior is available. ^D eof will ends clients stdio and so 
the whole
prlctl enter process. Job control will also be affected host prlctl.
Notice: the same behavior was implemented also on PCS6, so we should see
no degradation, but no improvements with enter to windows guests.

3. Tested by developers.

prlctl enter LIN-VM
(stty, job control, keyboard eof, intr, quit, top-like programs)

prlctl enter WIN-VM
(simple programs like net, ipconfig, tasklist, cygwin-cat)
(keyboard eof terminates whole process chain)

prlctl exec LIN-VM od /lib/

Sending large data to stdin, receiving large data from stdout/err:

prlctl exec centos7 od /lib64/libc-2.17.so | prlctl exec centos7 wc

4. Known problems:

4.1. Tty window size change made after 'prlctl enter' are not passed to
guest. Only initial window size at the time of 'prlctl enter' was
started is visible in guest process.

4.2. When sending unlimited data to process which is not able to read it 
with
sufficient speed, intermediate buffers in qemu-ga or dispatcher processes
may grow uncontrollably. It may result in tests with unlimited data
not fully passed or produce strange behaviour and out of memory error.

4.3. When qemu-ga agent in guest is restarted with active 'prlctl enter'
session, it will not be terminated. Since all keyboard signal processing
are redirected to guest process, it is not possible to kill such hunged
prlctl commands with keyboard from the same terminal.
Running "killall -TERM prlctl && killall -KILL prlctl" from another
host tty session will restore normal tty mode and kill hunged prlctl procs.




More information about the Users mailing list