Hyper-V: Connecting VMs through named pipe loses data

Martin v. Löwis picture Martin v. Löwis · Feb 11, 2011 · Viewed 13.9k times · Source

We are trying to connect two Hyper-V VMs through a serial port. Hyper-V exposes the serial port as a named pipe to the host system, and implements the server end of the named pipe. Consequentially, to connect them, we need to write a named-pipe client which connects to both VMs, and copies the data back and forth.

We have written such an application. Unfortunately, this application loses data.

If we connect two hyperterms, and have them exchange data, the transmission sometimes succeeds, but in many cases, the receiving end reports errors, or the transmission just deadlocks. Likewise, if we use the link to run a kernel debugger, it also seems to hang often.

What could be the cause of the data loss? What precautions must be taken when connecting named pipes in such a manner?

Edit: We have worked around the problem, using kdsrv.exe. The COM port of the debuggee continues to be exposed through a named pipe, however, the debugger end talks to kdserv via TCP.

Answer

John picture John · Feb 14, 2011

The data loss is not due to the named pipes. It is infact the COM ports (emulated and physical) that may lose data since they operate with a small buffer in the UART.

The named pipe receives all the data that is written to the COM port. Your program reads data from the named pipe and writes it to another named pipe. This is where data loss can originate if you write too fast the receiveing COM port's UART can overflow leading to data loss.

You may need to add some delay to avoid exceeding the baud rate expected by the receiving side.

In addition, you are missing ResetEvent() calls in your program.

For your KD issues, you may need to add resets=0 to the connection string.