[PATCH 3/4] kvmtool: Fix handling of POLLHUP when --tty is used

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The --tty option allows the redirection of a console (serial or virtio)
to a pseudo-terminal. As long as the slave port of this pseudo-terminal
is not opened by another process, a poll() call on the master port will
return POLLHUP in the .event field.

This confuses the virtio console code, as term_readable() returns
a positive value, indicating that something is available, while the
call to term_getc_iov will fail.

The fix is to check for the presence of the POLLIN flag in the .event
field. Note that this is only a partial fix, as kvmtool will still
consume vast amounts of CPU resource by spinning like crazy until
the slave port is actually opened.

Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
---
 tools/kvm/term.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/kvm/term.c b/tools/kvm/term.c
index 5c3e543..214f5e2 100644
--- a/tools/kvm/term.c
+++ b/tools/kvm/term.c
@@ -89,8 +89,10 @@ bool term_readable(int term)
 		.events	= POLLIN,
 		.revents = 0,
 	};
+	int err;
 
-	return poll(&pollfd, 1, 0) > 0;
+	err = poll(&pollfd, 1, 0);
+	return (err > 0 && (pollfd.revents & POLLIN));
 }
 
 static void *term_poll_thread_loop(void *param)
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux