Currently, PL011 is used by ARM virt board by default. It's possible to
block the system from booting. With below parameters in command line,
the
backend could run into endless attempts of transmitting packets, which
can't succeed because of running out of sending buffer. The socket
might
be not accepted n server side. It's not correct because disconnected
serial port shouldn't stop the system from booting.
-machine virt,gic-version=3 -cpu max -m 4096
-monitor none -serial tcp:127.0.0.1:50900
The issue can be reproduced by starting a program which listens on TCP
port 50900 and then sleep without accepting any incoming connections.
On
the other hand, a VM is started with above parameters and modified qemu
where the PL011 is flooded with 5000K data after it's created.
Eventually,
the flooding won't proceed and stops after transmitting 2574K data.
It's
basically to simulate tons of output from EDK-II and demonstrates how
the
tons of output can block the system from booting.
This fixes the issue by using newly added API
qemu_chr_fe_try_write_all(),
which provides another type of service (best-effort). It's different
from
qemu_chr_fe_write_all() as the data will be dropped if the backend has
been running into so-called broken state or 50 attempts of
transmissions.
The broken state is cleared if the data is transmitted at once.