[PATCH 1/2] kvm tools: Handle only relevant events in epoll

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

 



Handle only new incoming data for listener and stop fds, treat all other
events as error events which close the socket.

This fixes the bug where a 'kvm list' could have hanged because a close
event in the listener fd have been treated as a new connection.

Cc: Osier Yang <jyang@xxxxxxxxxx>
Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/kvm-ipc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
index 3131fe8..40ab457 100644
--- a/tools/kvm/kvm-ipc.c
+++ b/tools/kvm/kvm-ipc.c
@@ -112,7 +112,7 @@ static void *kvm_ipc__thread(void *param)
 		if (nfds > 0) {
 			int fd = event.data.fd;
 
-			if (fd == stop_fd) {
+			if (fd == stop_fd && event.events & EPOLLIN) {
 				break;
 			} else if (fd == server_fd) {
 				int client;
@@ -138,13 +138,13 @@ int kvm_ipc__start(int sock)
 
 	epoll_fd = epoll_create(KVM_IPC_MAX_MSGS);
 
-	ev.events = EPOLLIN | EPOLLOUT | EPOLLPRI;
+	ev.events = EPOLLIN | EPOLLET;
 	ev.data.fd = sock;
 	if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, sock, &ev) < 0)
 		die("Failed starting IPC thread");
 
 	stop_fd = eventfd(0, 0);
-	ev.events = EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLET;
+	ev.events = EPOLLIN | EPOLLET;
 	ev.data.fd = stop_fd;
 	if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, stop_fd, &ev) < 0)
 		die("Failed adding stop event to epoll");
-- 
1.7.7.1

--
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