[tip:tools/kvm] kvm-tool: Don' t try to cleanup ioeventfd if we never initialised it

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

 



Commit-ID:  3e6efe06a88ab1bdf6dc239b40df2f50dfc07b3a
Gitweb:     http://git.kernel.org/tip/3e6efe06a88ab1bdf6dc239b40df2f50dfc07b3a
Author:     Michael Ellerman <michael@xxxxxxxxxxxxxx>
AuthorDate: Mon, 6 Feb 2012 18:03:32 +1100
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Mon, 6 Feb 2012 12:22:36 +0200

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@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/ioeventfd.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c
index f2d5a30..9b328cd 100644
--- a/tools/kvm/ioeventfd.c
+++ b/tools/kvm/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;
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux