Re-implement 8250 serial device
jserv opened this issue · 2 comments
tinybox is a neat tool for hosting KVM guests. Its 8250 serial implementation uses poll(2) along with kvm__irq_line for efficient handling. There is no POSIX thread needed. We might rework the existing 8250 serial in kvm-host.
I just reviewed the 8250 serial implementation of tinybox, and here's some discussion for it.
The problem of serial implementation is: If no condition which should be handled happens, VM will always run inside the loop of KVM_RUN ioctl. After a little time of trying, it looks like keyboard input is useless to interrupt KVM_RUN ioctl.
To solve the issue, the previous solution of kvm-host is using another thread to handle serial input. The solution in tinybox, on the other hand, is using a timer to periodically return from KVM_RUN ioctl, just like another approach that I have mentioned in #3. I don't think the latter solution is certainly more efficient. For example, although no POSIX thread is needed for the tinybox solution, the timer interrupt may cause extra cost if we return from KVM_RUN ioctl but there's nothing that needs to be handled.
But if we only consider the simplicity, yes, the tinybox's solution seems to be indeed better. So I'll still change the implementation first.
As Maeda says, "When in doubt, just remove. But be careful of what you remove."
Using single-threaded model with I/O multiplexor should be enough to implement efficient 8250 serial device. Regarding the pthread-based interrupt handling, I think we can leave it as further work.