From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark McLoughlin Subject: [PATCH 2/6] kvm: qemu: dup the qemu_eventfd() return Date: Thu, 30 Oct 2008 17:51:49 +0000 Message-ID: <1225389113-28332-3-git-send-email-markmc@redhat.com> References: <> <1225389113-28332-1-git-send-email-markmc@redhat.com> <1225389113-28332-2-git-send-email-markmc@redhat.com> Cc: kvm@vger.kernel.org, Mark McLoughlin To: Avi Kivity Return-path: Received: from mail16.svc.cra.dublin.eircom.net ([159.134.118.215]:33643 "HELO mail16.svc.cra.dublin.eircom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1756705AbYJ3RxZ (ORCPT ); Thu, 30 Oct 2008 13:53:25 -0400 In-Reply-To: <1225389113-28332-2-git-send-email-markmc@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: qemu_eventfd() returns two file descriptors, both of which must be closed when pipe() is used in the absence of eventfd(). Duplicate the eventfd() file descriptor so that closing both descriptors will work in that case. Signed-off-by: Mark McLoughlin --- qemu/compatfd.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/qemu/compatfd.c b/qemu/compatfd.c index cc5ced3..36e37e5 100644 --- a/qemu/compatfd.c +++ b/qemu/compatfd.c @@ -118,7 +118,11 @@ int qemu_eventfd(int *fds) ret = syscall(SYS_eventfd, 0); if (ret >= 0) { - fds[0] = fds[1] = ret; + fds[0] = ret; + if ((fds[1] = dup(ret)) == -1) { + close(ret); + return -1; + } return 0; } #endif -- 1.5.4.3