aboutsummaryrefslogtreecommitdiffstats
path: root/ioeventfd.c
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2012-02-06 18:03:32 +1100
committerWill Deacon <will.deacon@arm.com>2015-06-01 16:39:51 +0100
commit55628a95bdf6c2c15de3f8fae5b5663eff46926a (patch)
tree287c46bc5d499aaa58136d10d8c819351d138360 /ioeventfd.c
parentdd7ce07b4cee83309c152aacebf39fb17b907675 (diff)
downloadkvmtool-55628a95bdf6c2c15de3f8fae5b5663eff46926a.tar.gz
kvm-tool: Don't try to cleanup ioeventfd if we never initialised it
Since 44287dd (Repair running on non ioeventfd-capable platforms) it's possible that ioeventfd__init() fails, but the VM still runs. This means we end up calling ioeventfd__exit(), which writes() and then reads() epoll_stop_fd. Because we failed the init, epoll_stop_fd is 0, so we end up writing/reading stdin, which exhibits as kvm-tool blocking until something is entered on the console. Once we break out of the read we close epoll_fd and epoll_stop_fd, both 0, and so term_exit() fails to cleanup the terminal properly. The fix is simply to check ioeventfd_avail in ioevetfd__exit() and do nothing if it is false. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'ioeventfd.c')
-rw-r--r--ioeventfd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ioeventfd.c b/ioeventfd.c
index f2d5a302..9b328cda 100644
--- a/ioeventfd.c
+++ b/ioeventfd.c
@@ -100,6 +100,9 @@ int ioeventfd__exit(struct kvm *kvm)
u64 tmp = 1;
int r;
+ if (!ioeventfd_avail)
+ return 0;
+
r = write(epoll_stop_fd, &tmp, sizeof(tmp));
if (r < 0)
return r;