From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NLb6D-0002jl-Dw for qemu-devel@nongnu.org; Fri, 18 Dec 2009 06:34:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NLb68-0002hs-7f for qemu-devel@nongnu.org; Fri, 18 Dec 2009 06:34:20 -0500 Received: from [199.232.76.173] (port=47123 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLb67-0002hm-Fm for qemu-devel@nongnu.org; Fri, 18 Dec 2009 06:34:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19597) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NLb62-0006rT-GH for qemu-devel@nongnu.org; Fri, 18 Dec 2009 06:34:15 -0500 Message-ID: <4B2B6855.4050909@redhat.com> Date: Fri, 18 Dec 2009 12:32:37 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] osdep: Fix runtime failure on older Linux kernels References: <1261129507-13244-1-git-send-email-andre.przywara@amd.com> In-Reply-To: <1261129507-13244-1-git-send-email-andre.przywara@amd.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andre Przywara Cc: qemu-devel@nongnu.org Am 18.12.2009 10:45, schrieb Andre Przywara: > If QEMU finds newer kernel header files on compilation time, it will use > advertised features like pipe2 or SOCK_CLOEXEC by just doing a compile test. > If later the executables are executed on an older kernel (<2.6.27, > like Xen Dom0 2.6.18), then QEMU will fail on opening sockets and creating > pipes and returns the rather unspecific "qemu_init_main_loop failed". > This patch fixes this by checking the return values of these calls > for EINVAL and ENOSYS and falling back to the older versions automatically. > > Signed-off-by: Andre Przywara > --- > osdep.c | 18 ++++++++++++------ > 1 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/osdep.c b/osdep.c > index 7509c5b..9949606 100644 > --- a/osdep.c > +++ b/osdep.c > @@ -262,13 +262,15 @@ int qemu_pipe(int pipefd[2]) > > #ifdef CONFIG_PIPE2 > ret = pipe2(pipefd, O_CLOEXEC); > -#else > + if (ret != -1 || errno != ENOSYS) { > + return ret; > + } > +#endif > ret = pipe(pipefd); > if (ret == 0) { > qemu_set_cloexec(pipefd[0]); > qemu_set_cloexec(pipefd[1]); > } > -#endif > > return ret; > } > @@ -283,12 +285,14 @@ int qemu_socket(int domain, int type, int protocol) > > #ifdef SOCK_CLOEXEC > ret = socket(domain, type | SOCK_CLOEXEC, protocol); > -#else > + if (ret != -1 || errno != EINVAL) { > + return ret; > + } > +#endif > ret = socket(domain, type, protocol); > if (ret >= 0) { > qemu_set_cloexec(ret); > } > -#endif > > return ret; > } > @@ -302,12 +306,14 @@ int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen) > > #ifdef CONFIG_ACCEPT4 > ret = accept4(s, addr, addrlen, SOCK_CLOEXEC); > -#else > + if (ret != -1 || errno != EINVAL) { Shouldn't this be an ENOSYS? Kevin